@@ -21,7 +21,7 @@ |
||
21 | 21 | * @return string |
22 | 22 | */ |
23 | 23 | protected function buildOffset($query) { |
24 | - if($this->offset !== null) { |
|
24 | + if ($this->offset !== null) { |
|
25 | 25 | $query .= "OFFSET\n\t{$this->offset}\n"; |
26 | 26 | } |
27 | 27 | return $query; |
@@ -30,21 +30,21 @@ |
||
30 | 30 | * @return string |
31 | 31 | */ |
32 | 32 | protected function buildUnions($query) { |
33 | - $wrap = function ($query) { |
|
33 | + $wrap = function($query) { |
|
34 | 34 | $query = trim($query); |
35 | 35 | $query = join("\n\t", explode("\n", $query)); |
36 | 36 | return sprintf("(\n\t%s\n)", $query); |
37 | 37 | }; |
38 | 38 | $queries = [$wrap($query)]; |
39 | - foreach($this->unions as $unionQuery) { |
|
40 | - if($unionQuery[0] === 'ALL') { |
|
39 | + foreach ($this->unions as $unionQuery) { |
|
40 | + if ($unionQuery[0] === 'ALL') { |
|
41 | 41 | $queries[] = 'UNION ALL'; |
42 | 42 | } else { |
43 | 43 | $queries[] = 'UNION'; |
44 | 44 | } |
45 | 45 | $queries[] = $wrap($unionQuery[1]); |
46 | 46 | } |
47 | - if(count($queries) > 1) { |
|
47 | + if (count($queries) > 1) { |
|
48 | 48 | return join(" ", $queries); |
49 | 49 | } |
50 | 50 | return $query; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @return $this |
30 | 30 | */ |
31 | 31 | public function from($alias, $table = null) { |
32 | - if($table !== null) { |
|
32 | + if ($table !== null) { |
|
33 | 33 | $this->aliases[] = $alias; |
34 | 34 | } |
35 | 35 | $this->addTable($alias, $table); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | public function __toString() { |
44 | 44 | $query = "DELETE "; |
45 | 45 | $query .= join(', ', $this->aliases); |
46 | - $query = trim($query) . " FROM\n"; |
|
46 | + $query = trim($query)." FROM\n"; |
|
47 | 47 | $query = $this->buildTables($query); |
48 | 48 | $query = $this->buildJoins($query); |
49 | 49 | $query = $this->buildWhereConditions($query); |
@@ -8,8 +8,8 @@ |
||
8 | 8 | * @return array |
9 | 9 | */ |
10 | 10 | public static function convertValues(array $row, array $columnDefinitions) { |
11 | - foreach($row as $key => &$value) { |
|
12 | - if($value !== null) { |
|
11 | + foreach ($row as $key => &$value) { |
|
12 | + if ($value !== null) { |
|
13 | 13 | $value = self::convertValue($value, $columnDefinitions[$key]); |
14 | 14 | } |
15 | 15 | } |
@@ -12,15 +12,15 @@ |
||
12 | 12 | * @return string |
13 | 13 | */ |
14 | 14 | public static function build(Database $db, $query, array $conditions, $token) { |
15 | - if(!count($conditions)) { |
|
15 | + if (!count($conditions)) { |
|
16 | 16 | return $query; |
17 | 17 | } |
18 | 18 | $query .= "{$token}\n"; |
19 | 19 | $arr = []; |
20 | - foreach($conditions as $condition) { |
|
20 | + foreach ($conditions as $condition) { |
|
21 | 21 | list($expression, $arguments) = $condition; |
22 | - if(is_array($expression)) { |
|
23 | - foreach($expression as $key => $value) { |
|
22 | + if (is_array($expression)) { |
|
23 | + foreach ($expression as $key => $value) { |
|
24 | 24 | $arr = self::buildCondition($arr, "`{$key}`=?", [$value], $db); |
25 | 25 | } |
26 | 26 | } else { |
@@ -27,8 +27,8 @@ |
||
27 | 27 | * @return DBExprFilter |
28 | 28 | */ |
29 | 29 | public function __invoke($expression, $keyPath, $validator = null) { |
30 | - return new DBExprFilter($expression, $this->map, $keyPath, $validator, function ($result, array $data) { |
|
31 | - if(!$result) { |
|
30 | + return new DBExprFilter($expression, $this->map, $keyPath, $validator, function($result, array $data) { |
|
31 | + if (!$result) { |
|
32 | 32 | throw new RequiredValueNotFoundException(sprintf("Required value %s not found", $data['key'])); |
33 | 33 | } |
34 | 34 | }); |
@@ -74,7 +74,7 @@ |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
77 | - * @return mixed |
|
77 | + * @return integer |
|
78 | 78 | */ |
79 | 79 | public function key() { |
80 | 80 | return $this->idx; |
@@ -42,16 +42,16 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function current() { |
44 | 44 | $row = $this->currentItem; |
45 | - if($this->preserveTypes) { |
|
45 | + if ($this->preserveTypes) { |
|
46 | 46 | $columnDefinitions = FieldTypeProvider::getFieldTypes($this->getStmt()); |
47 | 47 | $row = FieldValueConverter::convertValues($row, $columnDefinitions); |
48 | 48 | } |
49 | 49 | $callback = $this->callback; |
50 | - if($callback !== null) { |
|
50 | + if ($callback !== null) { |
|
51 | 51 | $result = $callback($row); |
52 | - if($result instanceof DBIgnoreRow) { |
|
52 | + if ($result instanceof DBIgnoreRow) { |
|
53 | 53 | // Do nothing in this case |
54 | - } elseif($result !== null) { |
|
54 | + } elseif ($result !== null) { |
|
55 | 55 | return $result; |
56 | 56 | } else { |
57 | 57 | return $row; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function valid() { |
81 | 81 | $result = !!$this->currentItem; |
82 | - if(!$result) { |
|
82 | + if (!$result) { |
|
83 | 83 | $this->closeCursor(); |
84 | 84 | } |
85 | 85 | return $result; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | /** |
89 | 89 | */ |
90 | 90 | public function rewind() { |
91 | - if($this->stmt !== null) { |
|
91 | + if ($this->stmt !== null) { |
|
92 | 92 | throw new RuntimeException("It's not possible to rewind this iterator"); |
93 | 93 | } |
94 | 94 | $this->stmt = call_user_func($this->statementFactory); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @return QueryStatement |
101 | 101 | */ |
102 | 102 | private function getStmt() { |
103 | - if($this->stmt === null) { |
|
103 | + if ($this->stmt === null) { |
|
104 | 104 | $this->rewind(); |
105 | 105 | } |
106 | 106 | return $this->stmt; |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | /** |
110 | 110 | */ |
111 | 111 | private function closeCursor() { |
112 | - if($this->stmt instanceof QueryStatement) { |
|
112 | + if ($this->stmt instanceof QueryStatement) { |
|
113 | 113 | $this->stmt->closeCursor(); |
114 | 114 | } |
115 | 115 | $this->stmt = null; |
@@ -78,7 +78,7 @@ |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
81 | - * @return array |
|
81 | + * @return string[] |
|
82 | 82 | */ |
83 | 83 | public function getFields() { |
84 | 84 | return $this->fields; |
@@ -28,10 +28,10 @@ |
||
28 | 28 | */ |
29 | 29 | protected function buildLimit($query, $offset = null) { |
30 | 30 | $limit = $this->limit; |
31 | - if($limit === null && $offset !== null) { |
|
31 | + if ($limit === null && $offset !== null) { |
|
32 | 32 | $limit = '18446744073709551615'; |
33 | 33 | } |
34 | - if($limit !== null) { |
|
34 | + if ($limit !== null) { |
|
35 | 35 | $query .= "LIMIT\n\t{$limit}\n"; |
36 | 36 | } |
37 | 37 | return $query; |