@@ -11,19 +11,19 @@ discard block |
||
11 | 11 | private |
12 | 12 | $tables; |
13 | 13 | |
14 | - public function __construct($table = null, ?string $alias = null) |
|
14 | + public function __construct($table = null, ? string $alias = null) |
|
15 | 15 | { |
16 | 16 | $this->tables = array(); |
17 | 17 | |
18 | - if(! empty($table)) |
|
18 | + if (!empty($table)) |
|
19 | 19 | { |
20 | 20 | $this->addTable($table, $alias); |
21 | 21 | } |
22 | 22 | } |
23 | 23 | |
24 | - public function addTable($table, ?string $alias = null): self |
|
24 | + public function addTable($table, ? string $alias = null) : self |
|
25 | 25 | { |
26 | - if(! $table instanceof TableName) |
|
26 | + if (!$table instanceof TableName) |
|
27 | 27 | { |
28 | 28 | $table = new TableName($table, $alias); |
29 | 29 | } |
@@ -35,14 +35,14 @@ discard block |
||
35 | 35 | |
36 | 36 | public function toString(): string |
37 | 37 | { |
38 | - if(empty($this->tables)) |
|
38 | + if (empty($this->tables)) |
|
39 | 39 | { |
40 | 40 | return ''; |
41 | 41 | } |
42 | 42 | |
43 | 43 | $tables = array(); |
44 | 44 | |
45 | - foreach($this->tables as $table) |
|
45 | + foreach ($this->tables as $table) |
|
46 | 46 | { |
47 | 47 | $tables[] = $table->toString(); |
48 | 48 | } |
@@ -11,9 +11,9 @@ |
||
11 | 11 | private |
12 | 12 | $columnName; |
13 | 13 | |
14 | - public function __construct(?string $columnName) |
|
14 | + public function __construct(? string $columnName) |
|
15 | 15 | { |
16 | - if(empty($columnName)) |
|
16 | + if (empty($columnName)) |
|
17 | 17 | { |
18 | 18 | throw new \InvalidArgumentException('Empty column name.'); |
19 | 19 | } |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | $tableName, |
13 | 13 | $alias; |
14 | 14 | |
15 | - public function __construct(?string $tableName, ?string $alias = null) |
|
15 | + public function __construct(? string $tableName, ? string $alias = null) |
|
16 | 16 | { |
17 | - if(empty($tableName)) |
|
17 | + if (empty($tableName)) |
|
18 | 18 | { |
19 | 19 | throw new \InvalidArgumentException('Empty table name.'); |
20 | 20 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | public function toString(): string |
28 | 28 | { |
29 | - if(empty($this->alias)) |
|
29 | + if (empty($this->alias)) |
|
30 | 30 | { |
31 | 31 | return $this->tableName; |
32 | 32 | } |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * @param TableName|string $table |
26 | 26 | */ |
27 | - public function __construct($table = null, ?string $alias = null) |
|
27 | + public function __construct($table = null, ? string $alias = null) |
|
28 | 28 | { |
29 | - if(!empty($table)) |
|
29 | + if (!empty($table)) |
|
30 | 30 | { |
31 | 31 | $this->from($table, $alias); |
32 | 32 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * @param TableName|string $table |
54 | 54 | */ |
55 | - public function from($table, ?string $alias = null): self |
|
55 | + public function from($table, ? string $alias = null) : self |
|
56 | 56 | { |
57 | 57 | $this->from = new Snippets\From($table, $alias); |
58 | 58 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | private function buildFrom(): string |
63 | 63 | { |
64 | - if(!$this->from instanceof Snippet) |
|
64 | + if (!$this->from instanceof Snippet) |
|
65 | 65 | { |
66 | 66 | throw new \LogicException('No column for FROM clause'); |
67 | 67 | } |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | $insertPart, |
16 | 16 | $valuesPart; |
17 | 17 | |
18 | - public function __construct(?string $table = null) |
|
18 | + public function __construct(? string $table = null) |
|
19 | 19 | { |
20 | 20 | $this->valuesPart = new Snippets\Values(); |
21 | 21 | |
22 | - if(! empty($table)) |
|
22 | + if (!empty($table)) |
|
23 | 23 | { |
24 | 24 | $this->insert($table); |
25 | 25 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | return implode(' ', $queryParts); |
36 | 36 | } |
37 | 37 | |
38 | - public function insert(?string $table): self |
|
38 | + public function insert(? string $table) : self |
|
39 | 39 | { |
40 | 40 | $this->insertPart = new Snippets\TableName($table); |
41 | 41 |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * @param Snippets\TableName|string|null $table |
26 | 26 | */ |
27 | - public function __construct($table = null, ?string $alias = null) |
|
27 | + public function __construct($table = null, ? string $alias = null) |
|
28 | 28 | { |
29 | 29 | $this->updatePart = new Snippets\Update(); |
30 | 30 | $this->where = new Snippets\Where(); |
31 | 31 | $this->sets = new Snippets\Set(); |
32 | 32 | $this->orderBy = new Snippets\OrderBy(); |
33 | 33 | |
34 | - if(! empty($table)) |
|
34 | + if (!empty($table)) |
|
35 | 35 | { |
36 | 36 | $this->update($table, $alias); |
37 | 37 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | /** |
55 | 55 | * @param Snippets\TableName|string $table |
56 | 56 | */ |
57 | - public function update($table, ?string $alias = null): self |
|
57 | + public function update($table, ? string $alias = null) : self |
|
58 | 58 | { |
59 | 59 | $this->updatePart->addTable($table, $alias); |
60 | 60 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | { |
73 | 73 | $updateString = $this->updatePart->toString(); |
74 | 74 | |
75 | - if(empty($updateString)) |
|
75 | + if (empty($updateString)) |
|
76 | 76 | { |
77 | 77 | throw new \RuntimeException('No table defined'); |
78 | 78 | } |
@@ -17,22 +17,22 @@ |
||
17 | 17 | { |
18 | 18 | $type = new TString($columnName); |
19 | 19 | |
20 | - if(is_bool($value)) |
|
20 | + if (is_bool($value)) |
|
21 | 21 | { |
22 | 22 | $type = new TBool($columnName); |
23 | 23 | } |
24 | 24 | |
25 | - if(is_int($value)) |
|
25 | + if (is_int($value)) |
|
26 | 26 | { |
27 | 27 | $type = new TInt($columnName); |
28 | 28 | } |
29 | 29 | |
30 | - if(is_float($value)) |
|
30 | + if (is_float($value)) |
|
31 | 31 | { |
32 | 32 | $type = new TFloat($columnName); |
33 | 33 | } |
34 | 34 | |
35 | - if($value instanceof \DateTime) |
|
35 | + if ($value instanceof \DateTime) |
|
36 | 36 | { |
37 | 37 | $type = new TDatetime($columnName); |
38 | 38 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | public function toString(Escaper $escaper): string |
26 | 26 | { |
27 | - if($this->isEmpty()) |
|
27 | + if ($this->isEmpty()) |
|
28 | 28 | { |
29 | 29 | return ''; |
30 | 30 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | { |
42 | 42 | $columnName = $this->column->getName(); |
43 | 43 | |
44 | - if(empty($columnName) || empty($this->start) || empty($this->end)) |
|
44 | + if (empty($columnName) || empty($this->start) || empty($this->end)) |
|
45 | 45 | { |
46 | 46 | return true; |
47 | 47 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | $value = $this->column->format($value); |
55 | 55 | |
56 | - if($this->column->isEscapeRequired()) |
|
56 | + if ($this->column->isEscapeRequired()) |
|
57 | 57 | { |
58 | 58 | $value = $escaper->escape($value); |
59 | 59 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | public function toString(Escaper $escaper): string |
23 | 23 | { |
24 | - if($this->isEmpty()) |
|
24 | + if ($this->isEmpty()) |
|
25 | 25 | { |
26 | 26 | return ''; |
27 | 27 | } |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | |
41 | 41 | public function isEmpty(): bool |
42 | 42 | { |
43 | - foreach($this->conditions as $condition) |
|
43 | + foreach ($this->conditions as $condition) |
|
44 | 44 | { |
45 | - if(! $condition->isEmpty()) |
|
45 | + if (!$condition->isEmpty()) |
|
46 | 46 | { |
47 | 47 | return false; |
48 | 48 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | $compositeCondition = array_shift($conditions); |
59 | 59 | |
60 | - foreach($conditions as $condition) |
|
60 | + foreach ($conditions as $condition) |
|
61 | 61 | { |
62 | 62 | $compositeCondition = $this->joinConditions($compositeCondition, $condition); |
63 | 63 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | private function getNotEmptyConditions(): array |
69 | 69 | { |
70 | - return array_filter($this->conditions, function (Condition $item) { |
|
70 | + return array_filter($this->conditions, function(Condition $item) { |
|
71 | 71 | return $item->isEmpty() === false; |
72 | 72 | }); |
73 | 73 | } |