Conditions | 4 |
Paths | 6 |
Total Lines | 30 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 17 |
CRAP Score | 4 |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
30 | 2 | public function compile(QueryBuilder $queryBuilder): string |
|
31 | { |
||
32 | /** @var array<array<Expression>> $groups */ |
||
33 | 2 | $groups = []; |
|
34 | /** @var array<int, string|null> $group */ |
||
35 | 2 | foreach ($this->groups as $key => $group) { |
|
36 | 2 | $groups[$key][0] = $queryBuilder->normalizeArgument( |
|
37 | 2 | $group[0], |
|
38 | 'Variable' |
||
39 | ); |
||
40 | 2 | $queryBuilder->registerVariable($groups[$key][0]); |
|
41 | |||
42 | 2 | $groups[$key][1] = $queryBuilder->normalizeArgument( |
|
43 | 2 | $group[1], |
|
44 | 2 | ['Reference', 'Function', 'Query', 'Bind'] |
|
45 | ); |
||
46 | } |
||
47 | |||
48 | 2 | $output = 'COLLECT'; |
|
49 | 2 | $groupOutput = ''; |
|
50 | 2 | foreach ($groups as $group) { |
|
51 | 2 | if ($groupOutput !== '') { |
|
52 | 1 | $groupOutput .= ','; |
|
53 | } |
||
54 | 2 | $groupOutput .= ' ' . $group[0]->compile($queryBuilder); |
|
55 | /** @psalm-suppress PossiblyUndefinedArrayOffset */ |
||
56 | 2 | $groupOutput .= ' = ' . $group[1]->compile($queryBuilder); |
|
57 | } |
||
58 | |||
59 | 2 | return $output . $groupOutput; |
|
60 | } |
||
62 |