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