Skip to content

Commit 32bb133

Browse files
authored
[10.x] Use match expression in compileHaving (#47548)
1 parent 973b54e commit 32bb133

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

src/Illuminate/Database/Query/Grammars/Grammar.php

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -754,23 +754,16 @@ protected function compileHaving(array $having)
754754
// If the having clause is "raw", we can just return the clause straight away
755755
// without doing any more processing on it. Otherwise, we will compile the
756756
// clause into SQL based on the components that make it up from builder.
757-
if ($having['type'] === 'Raw') {
758-
return $having['sql'];
759-
} elseif ($having['type'] === 'between') {
760-
return $this->compileHavingBetween($having);
761-
} elseif ($having['type'] === 'Null') {
762-
return $this->compileHavingNull($having);
763-
} elseif ($having['type'] === 'NotNull') {
764-
return $this->compileHavingNotNull($having);
765-
} elseif ($having['type'] === 'bit') {
766-
return $this->compileHavingBit($having);
767-
} elseif ($having['type'] === 'Expression') {
768-
return $this->compileHavingExpression($having);
769-
} elseif ($having['type'] === 'Nested') {
770-
return $this->compileNestedHavings($having);
771-
}
772-
773-
return $this->compileBasicHaving($having);
757+
return match ($having['type']) {
758+
'Raw' => $having['sql'],
759+
'between' => $this->compileHavingBetween($having),
760+
'Null' => $this->compileHavingNull($having),
761+
'NotNull' => $this->compileHavingNotNull($having),
762+
'bit' => $this->compileHavingBit($having),
763+
'Expression' => $this->compileHavingExpression($having),
764+
'Nested' => $this->compileNestedHavings($having),
765+
default => $this->compileBasicHaving($having),
766+
};
774767
}
775768

776769
/**

0 commit comments

Comments
 (0)