|
2 | 2 |
|
3 | 3 | namespace ipl\Sql; |
4 | 4 |
|
5 | | -use InvalidArgumentException; |
6 | 5 | use ipl\Sql\Adapter\Mssql; |
7 | 6 | use ipl\Sql\Contract\Adapter; |
8 | 7 | use ipl\Stdlib\Events; |
9 | 8 |
|
10 | | -use function ipl\Stdlib\get_php_type; |
11 | | - |
12 | 9 | class QueryBuilder |
13 | 10 | { |
14 | 11 | use Events; |
@@ -163,26 +160,15 @@ public function __construct(Adapter $adapter) |
163 | 160 | * @param Delete|Insert|Select|Update $stmt |
164 | 161 | * |
165 | 162 | * @return array |
166 | | - * |
167 | | - * @throw InvalidArgumentException If statement type is invalid |
168 | 163 | */ |
169 | 164 | public function assemble(Select|Insert|Update|Delete $stmt): array |
170 | 165 | { |
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 | | - } |
| 166 | + return match (true) { |
| 167 | + $stmt instanceof Delete => $this->assembleDelete($stmt), |
| 168 | + $stmt instanceof Insert => $this->assembleInsert($stmt), |
| 169 | + $stmt instanceof Select => $this->assembleSelect($stmt), |
| 170 | + $stmt instanceof Update => $this->assembleUpdate($stmt) |
| 171 | + }; |
186 | 172 | } |
187 | 173 |
|
188 | 174 | /** |
|
0 commit comments