@@ -125,7 +125,7 @@ |
||
| 125 | 125 | * @return $this |
| 126 | 126 | */ |
| 127 | 127 | public function from(?string $alias, $table = null) { |
| 128 | - if($table === null) { |
|
| 128 | + if ($table === null) { |
|
| 129 | 129 | [$alias, $table] = [$table, $alias]; |
| 130 | 130 | $this->addTable($alias, (string) $table); |
| 131 | 131 | } else { |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | * @return $this |
| 20 | 20 | */ |
| 21 | 21 | public function having($expression, ...$args) { |
| 22 | - $fn = function ($expression, $args) { $this->having[] = [$expression, $args]; }; |
|
| 22 | + $fn = function($expression, $args) { $this->having[] = [$expression, $args]; }; |
|
| 23 | 23 | ConditionAddHelper::addCondition($fn, $expression, $args); |
| 24 | 24 | return $this; |
| 25 | 25 | } |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | * @return $this |
| 20 | 20 | */ |
| 21 | 21 | public function where($expression, ...$args) { |
| 22 | - $fn = function ($expression, $args) { $this->where[] = [$expression, $args]; }; |
|
| 22 | + $fn = function($expression, $args) { $this->where[] = [$expression, $args]; }; |
|
| 23 | 23 | ConditionAddHelper::addCondition($fn, $expression, $args); |
| 24 | 24 | return $this; |
| 25 | 25 | } |
@@ -15,8 +15,8 @@ discard block |
||
| 15 | 15 | * @return $this |
| 16 | 16 | */ |
| 17 | 17 | public function orderBy($expression, string $direction = 'ASC') { |
| 18 | - if($expression instanceof OrderBySpecification) { |
|
| 19 | - foreach($expression->getFields() as $field) { |
|
| 18 | + if ($expression instanceof OrderBySpecification) { |
|
| 19 | + foreach ($expression->getFields() as $field) { |
|
| 20 | 20 | $this->addOrder($field[0], $field[1]); |
| 21 | 21 | } |
| 22 | 22 | return $this; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public function orderByValues(string $fieldName, array $values) { |
| 34 | 34 | $expr = []; |
| 35 | - foreach(array_values($values) as $idx => $value) { |
|
| 35 | + foreach (array_values($values) as $idx => $value) { |
|
| 36 | 36 | $expr[] = $this->db()->quoteExpression("WHEN ? THEN ?", [$value, $idx]); |
| 37 | 37 | } |
| 38 | 38 | $this->orderBy[] = [sprintf("CASE %s\n\t\t%s\n\tEND", $this->db()->quoteField($fieldName), implode("\n\t\t", $expr)), 'ASC']; |
@@ -44,12 +44,12 @@ discard block |
||
| 44 | 44 | * @return string |
| 45 | 45 | */ |
| 46 | 46 | protected function buildOrder(string $query): string { |
| 47 | - if(!count($this->orderBy)) { |
|
| 47 | + if (!count($this->orderBy)) { |
|
| 48 | 48 | return $query; |
| 49 | 49 | } |
| 50 | 50 | $query .= "ORDER BY\n"; |
| 51 | 51 | $arr = []; |
| 52 | - foreach($this->orderBy as [$expression, $direction]) { |
|
| 52 | + foreach ($this->orderBy as [$expression, $direction]) { |
|
| 53 | 53 | $arr[] = sprintf("\t%s %s", $expression, strtoupper($direction)); |
| 54 | 54 | } |
| 55 | 55 | return $query.implode(",\n", $arr)."\n"; |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | private function addOrder($expression, string $direction): void { |
| 63 | 63 | $direction = $this->fixDirection($direction); |
| 64 | - if(is_array($expression)) { |
|
| 65 | - if(count($expression) < 1) { |
|
| 64 | + if (is_array($expression)) { |
|
| 65 | + if (count($expression) < 1) { |
|
| 66 | 66 | return; |
| 67 | 67 | } |
| 68 | 68 | $expr = (string) $expression[0]; |