@@ -14,34 +14,34 @@ |
||
14 | 14 | * @return string |
15 | 15 | */ |
16 | 16 | protected function buildTableName(?string $alias, $name): string { |
17 | - if(is_object($name) && !($name instanceof VirtualTable) && method_exists($name, '__toString')) { |
|
17 | + if (is_object($name) && !($name instanceof VirtualTable) && method_exists($name, '__toString')) { |
|
18 | 18 | $name = (string) $name; |
19 | 19 | $lines = explode("\n", $name); |
20 | - $lines = array_map(static function (string $line) { return "\t{$line}"; }, $lines); |
|
20 | + $lines = array_map(static function(string $line) { return "\t{$line}"; }, $lines); |
|
21 | 21 | $name = implode("\n", $lines); |
22 | - $name = '(' . trim(rtrim(trim($name), ';')) . ')'; |
|
22 | + $name = '('.trim(rtrim(trim($name), ';')).')'; |
|
23 | 23 | } |
24 | - if(is_array($name)) { |
|
24 | + if (is_array($name)) { |
|
25 | 25 | $parts = []; |
26 | - foreach($name as $index => $bucket) { |
|
27 | - if(is_scalar($bucket) && ctype_digit((string) $index)) { |
|
26 | + foreach ($name as $index => $bucket) { |
|
27 | + if (is_scalar($bucket) && ctype_digit((string) $index)) { |
|
28 | 28 | $parts[] = "SELECT {$this->db()->quote($bucket)} AS {$this->db()->quoteField('value')}"; |
29 | 29 | } else { |
30 | 30 | $values = []; |
31 | - foreach($bucket as $field => $value) { |
|
31 | + foreach ($bucket as $field => $value) { |
|
32 | 32 | $values[] = sprintf('%s AS %s', $this->db()->quote($value), $this->db()->quoteField($field)); |
33 | 33 | } |
34 | 34 | $parts[] = sprintf("SELECT %s", implode(', ', $values)); |
35 | 35 | } |
36 | 36 | } |
37 | - $name = '(' . implode("\n\tUNION ALL\n\t", $parts) . ')'; |
|
37 | + $name = '('.implode("\n\tUNION ALL\n\t", $parts).')'; |
|
38 | 38 | } |
39 | - if((is_string($name) || $name instanceof VirtualTable) && $this->db()->getVirtualTables()->has($name)) { |
|
39 | + if ((is_string($name) || $name instanceof VirtualTable) && $this->db()->getVirtualTables()->has($name)) { |
|
40 | 40 | $select = (string) $this->db()->getVirtualTables()->get($name); |
41 | 41 | $name = sprintf('(%s)', implode("\n\t", explode("\n", trim($select)))); |
42 | 42 | } |
43 | 43 | $name = $this->aliasReplacer()->replace((string) $name); |
44 | - if($alias !== null) { |
|
44 | + if ($alias !== null) { |
|
45 | 45 | return sprintf("%s %s", $name, $alias); |
46 | 46 | } |
47 | 47 | return $name; |