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