Skip to content

Commit e1a3680

Browse files
Replace switch statement with match expression
1 parent ecab475 commit e1a3680

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

src/QueryBuilder.php

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -168,21 +168,12 @@ public function __construct(Adapter $adapter)
168168
*/
169169
public function assemble(Select|Insert|Update|Delete $stmt): array
170170
{
171-
switch (true) {
172-
case $stmt instanceof Delete:
173-
return $this->assembleDelete($stmt);
174-
case $stmt instanceof Insert:
175-
return $this->assembleInsert($stmt);
176-
case $stmt instanceof Select:
177-
return $this->assembleSelect($stmt);
178-
case $stmt instanceof Update:
179-
return $this->assembleUpdate($stmt);
180-
default:
181-
throw new InvalidArgumentException(sprintf(
182-
__METHOD__ . ' expects instances of Delete, Insert, Select or Update. Got %s instead.',
183-
get_php_type($stmt)
184-
));
185-
}
171+
return match (true) {
172+
$stmt instanceof Delete => $this->assembleDelete($stmt),
173+
$stmt instanceof Insert => $this->assembleInsert($stmt),
174+
$stmt instanceof Select => $this->assembleSelect($stmt),
175+
$stmt instanceof Update => $this->assembleUpdate($stmt)
176+
};
186177
}
187178

188179
/**

0 commit comments

Comments
 (0)