@@ -8,7 +8,6 @@ |
||
8 | 8 | use Puzzle\QueryBuilder\Condition; |
9 | 9 | use Puzzle\QueryBuilder\Conditions; |
10 | 10 | use Puzzle\QueryBuilder\Traits\EscaperAware; |
11 | -use Puzzle\QueryBuilder\Escaper; |
|
12 | 11 | |
13 | 12 | class Having implements Snippet |
14 | 13 | { |
@@ -32,7 +32,7 @@ |
||
32 | 32 | |
33 | 33 | public function toString(): string |
34 | 34 | { |
35 | - if($this->condition->isEmpty()) |
|
35 | + if ($this->condition->isEmpty()) |
|
36 | 36 | { |
37 | 37 | return ''; |
38 | 38 | } |
@@ -16,7 +16,7 @@ |
||
16 | 16 | |
17 | 17 | public function format($value) |
18 | 18 | { |
19 | - if($value instanceof \DateTime) |
|
19 | + if ($value instanceof \DateTime) |
|
20 | 20 | { |
21 | 21 | return $value->format(self::MYSQL_DATETIME_FORMAT); |
22 | 22 | } |
@@ -14,12 +14,12 @@ discard block |
||
14 | 14 | { |
15 | 15 | use Traits\EscaperAware; |
16 | 16 | |
17 | - public function delete(?string $table = null, ?string $alias = null): Delete |
|
17 | + public function delete(? string $table = null, ? string $alias = null) : Delete |
|
18 | 18 | { |
19 | 19 | return (new Delete($table, $alias))->setEscaper($this->escaper); |
20 | 20 | } |
21 | 21 | |
22 | - public function insert(?string $table = null): Insert |
|
22 | + public function insert(? string $table = null) : Insert |
|
23 | 23 | { |
24 | 24 | return (new Insert($table))->setEscaper($this->escaper); |
25 | 25 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | return (new Select($columns))->setEscaper($this->escaper); |
33 | 33 | } |
34 | 34 | |
35 | - public function update(?string $table = null, ?string $alias = null): Update |
|
35 | + public function update(? string $table = null, ? string $alias = null) : Update |
|
36 | 36 | { |
37 | 37 | return (new Update($table, $alias))->setEscaper($this->escaper); |
38 | 38 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * @param Snippet|string $columnName |
42 | 42 | */ |
43 | - public function count($columnName, ?string $alias = null): Snippets\Count |
|
43 | + public function count($columnName, ? string $alias = null) : Snippets\Count |
|
44 | 44 | { |
45 | 45 | return (new Snippets\Count($columnName, $alias)); |
46 | 46 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | /** |
60 | 60 | * @param Snippets\TableName|string $table |
61 | 61 | */ |
62 | - public function from($table, ?string $alias = null): self |
|
62 | + public function from($table, ? string $alias = null) : self |
|
63 | 63 | { |
64 | 64 | $this->from = new Snippets\From($table, $alias); |
65 | 65 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | private function buildFrom(): string |
92 | 92 | { |
93 | - if(!$this->from instanceof Snippet) |
|
93 | + if (!$this->from instanceof Snippet) |
|
94 | 94 | { |
95 | 95 | throw new \LogicException('No column for FROM clause'); |
96 | 96 | } |
@@ -31,15 +31,15 @@ discard block |
||
31 | 31 | { |
32 | 32 | $orders = []; |
33 | 33 | |
34 | - foreach($this->orders as $column => $direction) |
|
34 | + foreach ($this->orders as $column => $direction) |
|
35 | 35 | { |
36 | - if(! empty($column)) |
|
36 | + if (!empty($column)) |
|
37 | 37 | { |
38 | - $orders[] = $column . ' ' . $direction; |
|
38 | + $orders[] = $column.' '.$direction; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | - if(empty($orders)) |
|
42 | + if (empty($orders)) |
|
43 | 43 | { |
44 | 44 | return ''; |
45 | 45 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | { |
52 | 52 | $availableDirections = [self::ASC, self::DESC]; |
53 | 53 | |
54 | - if(! in_array($direction, $availableDirections)) |
|
54 | + if (!in_array($direction, $availableDirections)) |
|
55 | 55 | { |
56 | 56 | throw new \InvalidArgumentException(sprintf('Unsupported ORDER BY direction "%s"', $direction)); |
57 | 57 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | { |
20 | 20 | $this->conditions = array(); |
21 | 21 | |
22 | - if($condition instanceof Condition) |
|
22 | + if ($condition instanceof Condition) |
|
23 | 23 | { |
24 | 24 | $this->addCondition($condition); |
25 | 25 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | public function toString(): string |
36 | 36 | { |
37 | 37 | $conditionString = $this->buildConditionString(); |
38 | - if(empty($conditionString)) |
|
38 | + if (empty($conditionString)) |
|
39 | 39 | { |
40 | 40 | return ''; |
41 | 41 | } |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | private function buildConditionString(): string |
47 | 47 | { |
48 | 48 | $whereConditions = array(); |
49 | - foreach($this->conditions as $condition) |
|
49 | + foreach ($this->conditions as $condition) |
|
50 | 50 | { |
51 | 51 | $conditionString = $condition->toString($this->escaper); |
52 | - if(! empty($conditionString)) |
|
52 | + if (!empty($conditionString)) |
|
53 | 53 | { |
54 | 54 | $whereConditions[] = $conditionString; |
55 | 55 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | { |
27 | 27 | $usingColumns = implode(', ', array_filter($this->columns)); |
28 | 28 | |
29 | - if(empty($usingColumns)) |
|
29 | + if (empty($usingColumns)) |
|
30 | 30 | { |
31 | 31 | return ''; |
32 | 32 | } |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | |
40 | 40 | private function convertToArray($input): array |
41 | 41 | { |
42 | - if(! is_array($input)) |
|
42 | + if (!is_array($input)) |
|
43 | 43 | { |
44 | - if(! $this->isConvertibleToString($input)) |
|
44 | + if (!$this->isConvertibleToString($input)) |
|
45 | 45 | { |
46 | 46 | throw new \InvalidArgumentException("Using argument must be a string (or an array of string)"); |
47 | 47 | } |
@@ -16,9 +16,9 @@ discard block |
||
16 | 16 | $this->groupBy = array(); |
17 | 17 | } |
18 | 18 | |
19 | - public function addGroupBy(?string $column): self |
|
19 | + public function addGroupBy(? string $column) : self |
|
20 | 20 | { |
21 | - if(!empty($column)) |
|
21 | + if (!empty($column)) |
|
22 | 22 | { |
23 | 23 | $this->groupBy[$column] = $column; |
24 | 24 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | public function toString(): string |
30 | 30 | { |
31 | - if(empty($this->groupBy)) |
|
31 | + if (empty($this->groupBy)) |
|
32 | 32 | { |
33 | 33 | return ''; |
34 | 34 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | public function toString(): string |
26 | 26 | { |
27 | - if(is_null($this->limit)) |
|
27 | + if (is_null($this->limit)) |
|
28 | 28 | { |
29 | 29 | return ''; |
30 | 30 | } |
@@ -35,14 +35,14 @@ discard block |
||
35 | 35 | ); |
36 | 36 | } |
37 | 37 | |
38 | - private function convertToInteger($value): ?int |
|
38 | + private function convertToInteger($value): ? int |
|
39 | 39 | { |
40 | - if($this->isConvertibleToString($value) === false) |
|
40 | + if ($this->isConvertibleToString($value) === false) |
|
41 | 41 | { |
42 | 42 | throw new \InvalidArgumentException("Limit argument must be an integer or an integer wrapped into a string"); |
43 | 43 | } |
44 | 44 | |
45 | - if(preg_match('~^[\d]+$~', (string) $value)) |
|
45 | + if (preg_match('~^[\d]+$~', (string) $value)) |
|
46 | 46 | { |
47 | 47 | return (int) $value; |
48 | 48 | } |