Conditions | 4 |
Paths | 6 |
Total Lines | 19 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
38 | protected function buildUnions(string $query): string { |
||
39 | $wrap = static function ($query) { |
||
40 | $query = trim($query); |
||
41 | $query = implode("\n\t", explode("\n", $query)); |
||
42 | return sprintf("(\n\t%s\n)", $query); |
||
43 | }; |
||
44 | $queries = [$wrap($query)]; |
||
45 | foreach($this->unions as $unionQuery) { |
||
46 | if($unionQuery[0] === 'ALL') { |
||
47 | $queries[] = 'UNION ALL'; |
||
48 | } else { |
||
49 | $queries[] = 'UNION'; |
||
50 | } |
||
51 | $queries[] = $wrap($unionQuery[1]); |
||
52 | } |
||
53 | if(count($queries) > 1) { |
||
54 | return implode(' ', $queries); |
||
55 | } |
||
56 | return $query; |
||
57 | } |
||
59 |