| Conditions | 5 |
| Paths | 6 |
| Total Lines | 19 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 23 | public function orderBy($orderBy, string $keyword = KeywordEnum::ASC) |
||
| 24 | { |
||
| 25 | if (empty($orderBy)) { |
||
| 26 | throw new QueryBuilderException('You must pass $orderBy to orderBy method!'); |
||
| 27 | } |
||
| 28 | |||
| 29 | if (!\in_array($keyword, [KeywordEnum::ASC, KeywordEnum::DESC])) { |
||
| 30 | throw new QueryBuilderException(\sprintf('Invalid $keyword "%s" for orderBy!', $keyword)); |
||
| 31 | } |
||
| 32 | |||
| 33 | if (!\is_array($orderBy)) { |
||
| 34 | $orderBy = [$orderBy]; |
||
| 35 | } |
||
| 36 | |||
| 37 | foreach ($orderBy as $orderByColumn) { |
||
| 38 | $this->orderBy[] = \sprintf('%s %s', $orderByColumn, $keyword); |
||
| 39 | } |
||
| 40 | |||
| 41 | return $this; |
||
| 42 | } |
||
| 55 |