@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * @return $this |
14 | 14 | */ |
15 | 15 | protected function addTable($alias, $table = null) { |
16 | - if($table === null) { |
|
16 | + if ($table === null) { |
|
17 | 17 | list($alias, $table) = [$table, $alias]; |
18 | 18 | } |
19 | 19 | $this->tables[] = ['alias' => $alias, 'name' => $table]; |
@@ -26,10 +26,10 @@ discard block |
||
26 | 26 | */ |
27 | 27 | protected function buildTables($query) { |
28 | 28 | $arr = []; |
29 | - foreach($this->tables as $table) { |
|
29 | + foreach ($this->tables as $table) { |
|
30 | 30 | $arr[] = "\t".$this->buildTableName($table['alias'], $table['name']); |
31 | 31 | } |
32 | - if(count($arr)) { |
|
32 | + if (count($arr)) { |
|
33 | 33 | $query .= implode(",\n", $arr)."\n"; |
34 | 34 | } |
35 | 35 | return $query; |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | * @return $this |
13 | 13 | */ |
14 | 14 | public function groupBy(...$args) { |
15 | - foreach($args as $expression) { |
|
16 | - if(is_array($expression)) { |
|
17 | - if(!count($expression)) { |
|
15 | + foreach ($args as $expression) { |
|
16 | + if (is_array($expression)) { |
|
17 | + if (!count($expression)) { |
|
18 | 18 | continue; |
19 | 19 | } |
20 | 20 | $arguments = [ |
@@ -33,12 +33,12 @@ discard block |
||
33 | 33 | * @return string |
34 | 34 | */ |
35 | 35 | protected function buildGroups($query) { |
36 | - if(!count($this->groupBy)) { |
|
36 | + if (!count($this->groupBy)) { |
|
37 | 37 | return $query; |
38 | 38 | } |
39 | 39 | $query .= "GROUP BY\n"; |
40 | 40 | $arr = []; |
41 | - foreach($this->groupBy as $expression) { |
|
41 | + foreach ($this->groupBy as $expression) { |
|
42 | 42 | $arr[] = "\t{$expression}"; |
43 | 43 | } |
44 | 44 | return $query.implode(",\n", $arr)."\n"; |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @return $this |
15 | 15 | */ |
16 | 16 | public function union(...$queries) { |
17 | - foreach($queries as $query) { |
|
17 | + foreach ($queries as $query) { |
|
18 | 18 | $this->unions[] = ['', $query]; |
19 | 19 | } |
20 | 20 | return $this; |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @return $this |
26 | 26 | */ |
27 | 27 | public function unionAll(...$queries) { |
28 | - foreach($queries as $query) { |
|
28 | + foreach ($queries as $query) { |
|
29 | 29 | $this->unions[] = ['ALL', $query]; |
30 | 30 | } |
31 | 31 | return $this; |
@@ -36,21 +36,21 @@ discard block |
||
36 | 36 | * @return string |
37 | 37 | */ |
38 | 38 | protected function buildUnions($query) { |
39 | - $wrap = static function ($query) { |
|
39 | + $wrap = static function($query) { |
|
40 | 40 | $query = trim($query); |
41 | 41 | $query = implode("\n\t", explode("\n", $query)); |
42 | 42 | return sprintf("(\n\t%s\n)", $query); |
43 | 43 | }; |
44 | 44 | $queries = [$wrap($query)]; |
45 | - foreach($this->unions as $unionQuery) { |
|
46 | - if($unionQuery[0] === 'ALL') { |
|
45 | + foreach ($this->unions as $unionQuery) { |
|
46 | + if ($unionQuery[0] === 'ALL') { |
|
47 | 47 | $queries[] = 'UNION ALL'; |
48 | 48 | } else { |
49 | 49 | $queries[] = 'UNION'; |
50 | 50 | } |
51 | 51 | $queries[] = $wrap($unionQuery[1]); |
52 | 52 | } |
53 | - if(count($queries) > 1) { |
|
53 | + if (count($queries) > 1) { |
|
54 | 54 | return implode(' ', $queries); |
55 | 55 | } |
56 | 56 | return $query; |
@@ -31,10 +31,10 @@ |
||
31 | 31 | * @return Select|null |
32 | 32 | */ |
33 | 33 | public function get($tableName) { |
34 | - if($this->has($tableName)) { |
|
34 | + if ($this->has($tableName)) { |
|
35 | 35 | $table = $this->virtualTables[(string) $tableName]; |
36 | - if($table instanceof Closure) { |
|
37 | - if($tableName instanceof VirtualTable) { |
|
36 | + if ($table instanceof Closure) { |
|
37 | + if ($tableName instanceof VirtualTable) { |
|
38 | 38 | $params = $tableName->getParams(); |
39 | 39 | return $table($params); |
40 | 40 | } |