| Conditions | 6 |
| Paths | 6 |
| Total Lines | 24 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 6 |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | 1 | public function compile(QueryBuilder $queryBuilder): string |
|
| 23 | { |
||
| 24 | 1 | if (empty($this->references[0])) { |
|
| 25 | 1 | return 'SORT null'; |
|
| 26 | } |
||
| 27 | |||
| 28 | $this->references = array_map(function ($reference) use ($queryBuilder) { |
||
| 29 | 1 | if (!$queryBuilder->grammar->isSortDirection($reference)) { |
|
| 30 | 1 | return $queryBuilder->normalizeArgument($reference, ['Reference', 'Null', 'Query', 'Bind']); |
|
| 31 | } |
||
| 32 | 1 | return $reference; |
|
| 33 | 1 | }, $this->references); |
|
| 34 | |||
| 35 | 1 | $output = ''; |
|
| 36 | 1 | foreach ($this->references as $value) { |
|
| 37 | 1 | if ($value instanceof ExpressionInterface) { |
|
| 38 | 1 | $output .= ', ' . $value->compile($queryBuilder); |
|
| 39 | } |
||
| 40 | 1 | if (is_string($value)) { |
|
| 41 | 1 | $output .= ' ' . $value; |
|
| 42 | } |
||
| 43 | } |
||
| 44 | |||
| 45 | 1 | return 'SORT ' . ltrim($output, ', '); |
|
| 46 | } |
||
| 48 |