Skip to content

Commit

Permalink
[10.x] Use match expression in compileHaving (#47548)
Browse files Browse the repository at this point in the history
  • Loading branch information
osbre authored Jun 23, 2023
1 parent 973b54e commit 32bb133
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions src/Illuminate/Database/Query/Grammars/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -754,23 +754,16 @@ protected function compileHaving(array $having)
// If the having clause is "raw", we can just return the clause straight away
// without doing any more processing on it. Otherwise, we will compile the
// clause into SQL based on the components that make it up from builder.
if ($having['type'] === 'Raw') {
return $having['sql'];
} elseif ($having['type'] === 'between') {
return $this->compileHavingBetween($having);
} elseif ($having['type'] === 'Null') {
return $this->compileHavingNull($having);
} elseif ($having['type'] === 'NotNull') {
return $this->compileHavingNotNull($having);
} elseif ($having['type'] === 'bit') {
return $this->compileHavingBit($having);
} elseif ($having['type'] === 'Expression') {
return $this->compileHavingExpression($having);
} elseif ($having['type'] === 'Nested') {
return $this->compileNestedHavings($having);
}

return $this->compileBasicHaving($having);
return match ($having['type']) {
'Raw' => $having['sql'],
'between' => $this->compileHavingBetween($having),
'Null' => $this->compileHavingNull($having),
'NotNull' => $this->compileHavingNotNull($having),
'bit' => $this->compileHavingBit($having),
'Expression' => $this->compileHavingExpression($having),
'Nested' => $this->compileNestedHavings($having),
default => $this->compileBasicHaving($having),
};
}

/**
Expand Down

0 comments on commit 32bb133

Please sign in to comment.