Passed
Push — master ( 81361e...ca0b43 )
by Ron
02:20
created
src/Databases/MySQL.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 * @param array $options
42 42
 	 */
43 43
 	public function __construct(PDO $pdo, array $options = []) {
44
-		if($pdo->getAttribute(PDO::ATTR_ERRMODE) === PDO::ERRMODE_SILENT) {
44
+		if ($pdo->getAttribute(PDO::ATTR_ERRMODE) === PDO::ERRMODE_SILENT) {
45 45
 			$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
46 46
 		}
47 47
 		$this->pdo = $pdo;
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 * @return VirtualTables
76 76
 	 */
77 77
 	public function getVirtualTables(): VirtualTables {
78
-		if($this->virtualTables === null) {
78
+		if ($this->virtualTables === null) {
79 79
 			$this->virtualTables = new VirtualTables();
80 80
 		}
81 81
 		return $this->virtualTables;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 * @return QueryStatement
87 87
 	 */
88 88
 	public function query(string $query) {
89
-		return $this->buildQueryStatement($query, function ($query) {
89
+		return $this->buildQueryStatement($query, function($query) {
90 90
 			return $this->pdo->query($query);
91 91
 		});
92 92
 	}
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 * @return QueryStatement
97 97
 	 */
98 98
 	public function prepare(string $query) {
99
-		return $this->buildQueryStatement((string) $query, function ($query) {
99
+		return $this->buildQueryStatement((string) $query, function($query) {
100 100
 			return $this->pdo->prepare($query);
101 101
 		});
102 102
 	}
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 	 * @return int
108 108
 	 */
109 109
 	public function exec(string $query, array $params = []): int {
110
-		return $this->exceptionHandler(function () use ($query, $params) {
110
+		return $this->exceptionHandler(function() use ($query, $params) {
111 111
 			$stmt = $this->pdo->prepare($query);
112 112
 			$timer = microtime(true);
113 113
 			$stmt->execute($params);
114
-			$this->queryLoggers->log($query, microtime(true) - $timer);
114
+			$this->queryLoggers->log($query, microtime(true)-$timer);
115 115
 			$result = $stmt->rowCount();
116 116
 			$stmt->closeCursor();
117 117
 			return $result;
@@ -132,12 +132,12 @@  discard block
 block discarded – undo
132 132
 	 */
133 133
 	public function getTableFields(string $table): array {
134 134
 		$table = $this->select()->aliasReplacer()->replace($table);
135
-		if(array_key_exists($table, self::$tableFields)) {
135
+		if (array_key_exists($table, self::$tableFields)) {
136 136
 			return self::$tableFields[$table];
137 137
 		}
138 138
 		$stmt = $this->pdo->query("DESCRIBE {$table}");
139 139
 		$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
140
-		self::$tableFields[$table] = array_map(static function ($row) { return $row['Field']; }, $rows);
140
+		self::$tableFields[$table] = array_map(static function($row) { return $row['Field']; }, $rows);
141 141
 		$stmt->closeCursor();
142 142
 		return self::$tableFields[$table];
143 143
 	}
@@ -149,12 +149,12 @@  discard block
 block discarded – undo
149 149
 	 */
150 150
 	public function quoteExpression($expression, array $arguments = []): string {
151 151
 		$index = -1;
152
-		$func = function () use ($arguments, &$index) {
152
+		$func = function() use ($arguments, &$index) {
153 153
 			$index++;
154
-			if(array_key_exists($index, $arguments)) {
154
+			if (array_key_exists($index, $arguments)) {
155 155
 				$argument = $arguments[$index];
156 156
 				$value = $this->quote($argument);
157
-			} elseif(count($arguments) > 0) {
157
+			} elseif (count($arguments) > 0) {
158 158
 				$args = $arguments;
159 159
 				$value = array_pop($args);
160 160
 				$value = $this->quote($value);
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
 	 * @return string
173 173
 	 */
174 174
 	public function quote($value): string {
175
-		if(is_null($value)) {
175
+		if (is_null($value)) {
176 176
 			$result = 'NULL';
177
-		} elseif($value instanceof Builder\DBExpr) {
177
+		} elseif ($value instanceof Builder\DBExpr) {
178 178
 			$result = $value->getExpression();
179
-		} elseif($value instanceof Builder\Select) {
179
+		} elseif ($value instanceof Builder\Select) {
180 180
 			$result = sprintf('(%s)', (string) $value);
181
-		} elseif(is_array($value)) {
182
-			$result = implode(', ', array_map(function ($value) { return $this->quote($value); }, $value));
181
+		} elseif (is_array($value)) {
182
+			$result = implode(', ', array_map(function($value) { return $this->quote($value); }, $value));
183 183
 		} else {
184 184
 			$result = $this->pdo->quote($value);
185 185
 		}
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 		if (is_numeric($field) || !is_string($field)) {
195 195
 			throw new UnexpectedValueException('Field name is invalid');
196 196
 		}
197
-		if(strpos($field, '`') !== false) {
197
+		if (strpos($field, '`') !== false) {
198 198
 			return $field;
199 199
 		}
200 200
 		$parts = explode('.', $field);
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 		$select = array_key_exists('select-factory', $this->options)
210 210
 			? call_user_func($this->options['select-factory'], $this, $this->options['select-options'])
211 211
 			: new Builder\RunnableSelect($this, $this->options['select-options']);
212
-		if($fields !== null) {
212
+		if ($fields !== null) {
213 213
 			$select->fields($fields);
214 214
 		}
215 215
 		return $select;
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 		$insert = array_key_exists('insert-factory', $this->options)
224 224
 			? call_user_func($this->options['insert-factory'], $this, $this->options['insert-options'])
225 225
 			: new Builder\RunnableInsert($this, $this->options['insert-options']);
226
-		if($fields !== null) {
226
+		if ($fields !== null) {
227 227
 			$insert->addAll($fields);
228 228
 		}
229 229
 		return $insert;
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 		$update = array_key_exists('update-factory', $this->options)
238 238
 			? call_user_func($this->options['update-factory'], $this, $this->options['update-options'])
239 239
 			: new Builder\RunnableUpdate($this, $this->options['update-options']);
240
-		if($fields !== null) {
240
+		if ($fields !== null) {
241 241
 			$update->setAll($fields);
242 242
 		}
243 243
 		return $update;
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 	 * @return $this
257 257
 	 */
258 258
 	public function transactionStart() {
259
-		if($this->transactionLevel === 0) {
260
-			if($this->pdo->inTransaction()) {
259
+		if ($this->transactionLevel === 0) {
260
+			if ($this->pdo->inTransaction()) {
261 261
 				$this->outerTransaction = true;
262 262
 			} else {
263 263
 				$this->pdo->beginTransaction();
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 * @return $this
272 272
 	 */
273 273
 	public function transactionCommit() {
274
-		return $this->transactionEnd(function () {
274
+		return $this->transactionEnd(function() {
275 275
 			$this->pdo->commit();
276 276
 		});
277 277
 	}
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	 * @return $this
281 281
 	 */
282 282
 	public function transactionRollback() {
283
-		return $this->transactionEnd(function () {
283
+		return $this->transactionEnd(function() {
284 284
 			$this->pdo->rollBack();
285 285
 		});
286 286
 	}
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 * @return mixed
291 291
 	 */
292 292
 	public function dryRun($callback = null) {
293
-		if(!$this->pdo->inTransaction()) {
293
+		if (!$this->pdo->inTransaction()) {
294 294
 			$this->transactionStart();
295 295
 			try {
296 296
 				return $callback($this);
@@ -314,14 +314,14 @@  discard block
 block discarded – undo
314 314
 	 */
315 315
 	public function transaction(callable $callback = null) {
316 316
 		$result = null;
317
-		if(!$this->pdo->inTransaction()) {
317
+		if (!$this->pdo->inTransaction()) {
318 318
 			$this->transactionStart();
319 319
 			try {
320 320
 				$result = $callback($this);
321 321
 				$this->transactionCommit();
322 322
 				return $result;
323 323
 			} catch (Throwable $e) {
324
-				if($this->pdo->inTransaction()) {
324
+				if ($this->pdo->inTransaction()) {
325 325
 					$this->transactionRollback();
326 326
 				}
327 327
 				throw $e;
@@ -345,11 +345,11 @@  discard block
 block discarded – undo
345 345
 	 */
346 346
 	private function transactionEnd(callable $fn) {
347 347
 		$this->transactionLevel--;
348
-		if($this->transactionLevel < 0) {
348
+		if ($this->transactionLevel < 0) {
349 349
 			throw new RuntimeException("Transaction-Nesting-Problem: Trying to invoke commit on a already closed transaction");
350 350
 		}
351
-		if($this->transactionLevel < 1) {
352
-			if($this->outerTransaction) {
351
+		if ($this->transactionLevel < 1) {
352
+			if ($this->outerTransaction) {
353 353
 				$this->outerTransaction = false;
354 354
 			} else {
355 355
 				$fn();
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	 */
366 366
 	private function buildQueryStatement(string $query, callable $fn): QueryStatement {
367 367
 		$stmt = $fn($query);
368
-		if(!$stmt) {
368
+		if (!$stmt) {
369 369
 			throw new RuntimeException("Could not execute statement:\n{$query}");
370 370
 		}
371 371
 		return new QueryStatement($stmt, $query, $this->exceptionInterpreter, $this->queryLoggers);
Please login to merge, or discard this patch.
src/Tools/VirtualTables.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@
 block discarded – undo
31 31
 	 * @return Select|null
32 32
 	 */
33 33
 	public function get($tableName): ?Select {
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
 				}
Please login to merge, or discard this patch.
src/Builder/Internal/ConditionBuilder.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -12,15 +12,15 @@
 block discarded – undo
12 12
 	 * @return string
13 13
 	 */
14 14
 	public static function build(Database $db, string $query, array $conditions, string $token): string {
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 list($expression, $arguments)) {
21
-			if(is_array($expression)) {
22
-				foreach($expression as $key => $value) {
23
-					if($value === null) {
20
+		foreach ($conditions as list($expression, $arguments)) {
21
+			if (is_array($expression)) {
22
+				foreach ($expression as $key => $value) {
23
+					if ($value === null) {
24 24
 						$arr = self::buildCondition($arr, "ISNULL(`{$key}`)", [$value], $db);
25 25
 					} else {
26 26
 						$arr = self::buildCondition($arr, "`{$key}`=?", [$value], $db);
Please login to merge, or discard this patch.
src/Builder/RunnableSelect.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	 * @return mixed[]
93 93
 	 */
94 94
 	public function fetchRow(Closure $callback = null): array {
95
-		return $this->fetch($callback, PDO::FETCH_ASSOC, null, static function ($row) {
95
+		return $this->fetch($callback, PDO::FETCH_ASSOC, null, static function($row) {
96 96
 			return ['valid' => is_array($row), 'default' => []];
97 97
 		});
98 98
 	}
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * @return object[]
122 122
 	 */
123 123
 	public function fetchObject($className = null, Closure $callback = null): array {
124
-		return $this->fetch($callback, PDO::FETCH_CLASS, $className ?: $this->defaultClassName, static function ($row) {
124
+		return $this->fetch($callback, PDO::FETCH_CLASS, $className ?: $this->defaultClassName, static function($row) {
125 125
 			return ['valid' => is_object($row), 'default' => null];
126 126
 		});
127 127
 	}
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
 	 * @return mixed[]
132 132
 	 */
133 133
 	public function fetchKeyValue($treatValueAsArray = false): array {
134
-		return $this->createTempStatement(static function (QueryStatement $statement) use ($treatValueAsArray) {
135
-			if($treatValueAsArray) {
134
+		return $this->createTempStatement(static function(QueryStatement $statement) use ($treatValueAsArray) {
135
+			if ($treatValueAsArray) {
136 136
 				$rows = $statement->fetchAll(PDO::FETCH_ASSOC);
137 137
 				$result = [];
138
-				foreach($rows as $row) {
138
+				foreach ($rows as $row) {
139 139
 					list($key) = array_values($row);
140 140
 					$result[$key] = $row;
141 141
 				}
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
 	public function fetchGroups(array $fields): array {
153 153
 		$rows = $this->fetchRows();
154 154
 		$result = [];
155
-		foreach($rows as $row) {
155
+		foreach ($rows as $row) {
156 156
 			/** @var array $tmp */
157 157
 			$tmp = &$result;
158
-			foreach($fields as $field) {
158
+			foreach ($fields as $field) {
159 159
 				$value = (string) $row[$field];
160
-				if(!array_key_exists($value, $tmp)) {
160
+				if (!array_key_exists($value, $tmp)) {
161 161
 					$tmp[$value] = [];
162 162
 				}
163 163
 				$tmp = &$tmp[$value];
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	 * @return string[]
172 172
 	 */
173 173
 	public function fetchArray(): array {
174
-		return $this->createTempStatement(static function (QueryStatement $stmt) {
174
+		return $this->createTempStatement(static function(QueryStatement $stmt) {
175 175
 			return $stmt->fetchAll(PDO::FETCH_COLUMN);
176 176
 		});
177 177
 	}
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
 	 * @return null|bool|string|int|float
182 182
 	 */
183 183
 	public function fetchValue($default = null) {
184
-		return $this->createTempStatement(static function (QueryStatement $stmt) use ($default) {
184
+		return $this->createTempStatement(static function(QueryStatement $stmt) use ($default) {
185 185
 			$result = $stmt->fetch(PDO::FETCH_NUM);
186
-			if($result !== false) {
186
+			if ($result !== false) {
187 187
 				return $result[0];
188 188
 			}
189 189
 			return $default;
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 		$query = $this->__toString();
219 219
 		$statement = $db->prepare($query);
220 220
 		$statement->execute($this->values);
221
-		if($this->getCalcFoundRows()) {
221
+		if ($this->getCalcFoundRows()) {
222 222
 			$this->foundRows = (int) $db->query('SELECT FOUND_ROWS()')->fetchColumn();
223 223
 		}
224 224
 		return $statement;
@@ -240,18 +240,18 @@  discard block
 block discarded – undo
240 240
 	 * @return mixed
241 241
 	 */
242 242
 	private function fetchAll(Closure $callback = null, int $mode = 0, $arg0 = null) {
243
-		return $this->createTempStatement(function (QueryStatement $statement) use ($callback, $mode, $arg0) {
243
+		return $this->createTempStatement(function(QueryStatement $statement) use ($callback, $mode, $arg0) {
244 244
 			$statement->setFetchMode($mode, $arg0);
245 245
 			$data = $statement->fetchAll();
246
-			if($this->preserveTypes) {
246
+			if ($this->preserveTypes) {
247 247
 				$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
248
-				$data = array_map(static function ($row) use ($columnDefinitions) { return FieldValueConverter::convertValues($row, $columnDefinitions); }, $data);
248
+				$data = array_map(static function($row) use ($columnDefinitions) { return FieldValueConverter::convertValues($row, $columnDefinitions); }, $data);
249 249
 			}
250
-			if($callback !== null) {
251
-				return call_user_func(static function ($resultData = []) use ($data, $callback) {
252
-					foreach($data as $row) {
250
+			if ($callback !== null) {
251
+				return call_user_func(static function($resultData = []) use ($data, $callback) {
252
+					foreach ($data as $row) {
253 253
 						$result = $callback($row);
254
-						if($result !== null && !($result instanceof DBIgnoreRow)) {
254
+						if ($result !== null && !($result instanceof DBIgnoreRow)) {
255 255
 							$resultData[] = $result;
256 256
 						} else {
257 257
 							$resultData[] = $row;
@@ -285,20 +285,20 @@  discard block
 block discarded – undo
285 285
 	 * @return mixed
286 286
 	 */
287 287
 	private function fetch(Closure $callback = null, int $mode = PDO::FETCH_ASSOC, $arg0 = null, Closure $resultValidator = null) {
288
-		return $this->createTempStatement(function (QueryStatement $statement) use ($callback, $mode, $arg0, $resultValidator) {
288
+		return $this->createTempStatement(function(QueryStatement $statement) use ($callback, $mode, $arg0, $resultValidator) {
289 289
 			$statement->setFetchMode($mode, $arg0);
290 290
 			$row = $statement->fetch();
291 291
 			$result = $resultValidator($row);
292
-			if(!$result['valid']) {
292
+			if (!$result['valid']) {
293 293
 				return $result['default'];
294 294
 			}
295
-			if($this->preserveTypes) {
295
+			if ($this->preserveTypes) {
296 296
 				$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
297 297
 				$row = FieldValueConverter::convertValues($row, $columnDefinitions);
298 298
 			}
299
-			if($callback !== null) {
299
+			if ($callback !== null) {
300 300
 				$result = $callback($row);
301
-				if($result !== null) {
301
+				if ($result !== null) {
302 302
 					$row = $result;
303 303
 				}
304 304
 			}
Please login to merge, or discard this patch.
src/Builder/Insert.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 * @return $this
87 87
 	 */
88 88
 	public function addExpr(string $str, ...$args) {
89
-		if(count($args) > 0) {
89
+		if (count($args) > 0) {
90 90
 			$this->fields[] = func_get_args();
91 91
 		} else {
92 92
 			$this->fields[] = $str;
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * @return $this
101 101
 	 */
102 102
 	public function updateExpr(string $str, ...$args) {
103
-		if(count($args) > 0) {
103
+		if (count($args) > 0) {
104 104
 			$this->update[] = func_get_args();
105 105
 		} else {
106 106
 			$this->update[] = $str;
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 * @return $this
115 115
 	 */
116 116
 	public function addOrUpdateExpr(string $expr, ...$args) {
117
-		if(count($args) > 0) {
117
+		if (count($args) > 0) {
118 118
 			$this->fields[] = func_get_args();
119 119
 			$this->update[] = func_get_args();
120 120
 		} else {
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @return $this
132 132
 	 */
133 133
 	public function addAll(array $data, array $mask = null, array $excludeFields = null) {
134
-		$this->addAllTo($data, $mask, $excludeFields, function ($field, $value) {
134
+		$this->addAllTo($data, $mask, $excludeFields, function($field, $value) {
135 135
 			$this->add($field, $value);
136 136
 		});
137 137
 		return $this;
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 * @return $this
145 145
 	 */
146 146
 	public function updateAll(array $data, array $mask = null, array $excludeFields = null) {
147
-		$this->addAllTo($data, $mask, $excludeFields, function ($field, $value) {
147
+		$this->addAllTo($data, $mask, $excludeFields, function($field, $value) {
148 148
 			if ($field !== $this->keyField) {
149 149
 				$this->update($field, $value);
150 150
 			}
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 		$ignoreStr = $this->ignore ? ' IGNORE' : '';
188 188
 		$queryArr[] = "INSERT{$ignoreStr} INTO\n\t{$tableName}\n";
189 189
 
190
-		if($this->from !== null) {
190
+		if ($this->from !== null) {
191 191
 			$fields = $this->from->getFields();
192 192
 			$queryArr[] = sprintf("\t(%s)\n", implode(', ', array_keys($fields)));
193 193
 			$queryArr[] = $this->from;
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 		}
202 202
 
203 203
 		$updateData = $this->buildUpdate();
204
-		if($updateData) {
204
+		if ($updateData) {
205 205
 			$queryArr[] = "{$updateData}\n";
206 206
 		}
207 207
 
@@ -232,12 +232,12 @@  discard block
 block discarded – undo
232 232
 	 * @return $this
233 233
 	 */
234 234
 	private function addAllTo(array $data, ?array $mask = null, ?array $excludeFields = null, $fn = null) {
235
-		if($mask !== null) {
235
+		if ($mask !== null) {
236 236
 			$data = array_intersect_key($data, array_combine($mask, $mask));
237 237
 		}
238
-		if($excludeFields !== null) {
239
-			foreach($excludeFields as $excludeField) {
240
-				if(array_key_exists($excludeField, $data)) {
238
+		if ($excludeFields !== null) {
239
+			foreach ($excludeFields as $excludeField) {
240
+				if (array_key_exists($excludeField, $data)) {
241 241
 					unset($data[$excludeField]);
242 242
 				}
243 243
 			}
@@ -254,10 +254,10 @@  discard block
 block discarded – undo
254 254
 	 */
255 255
 	private function buildUpdate(): string {
256 256
 		$queryArr = [];
257
-		if(!empty($this->update)) {
257
+		if (!empty($this->update)) {
258 258
 			$queryArr[] = "ON DUPLICATE KEY UPDATE\n";
259 259
 			$updateArr = [];
260
-			if($this->keyField !== null) {
260
+			if ($this->keyField !== null) {
261 261
 				$updateArr[] = "\t`{$this->keyField}` = LAST_INSERT_ID({$this->keyField})";
262 262
 			}
263 263
 			$updateArr = $this->buildFieldList($this->update, $updateArr);
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	 * @return array
281 281
 	 */
282 282
 	private function clearValues(array $values): array {
283
-		if(!count($values)) {
283
+		if (!count($values)) {
284 284
 			return [];
285 285
 		}
286 286
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 		$result = [];
290 290
 
291 291
 		foreach ($values as $fieldName => $fieldValue) {
292
-			if(in_array($fieldName, $fields)) {
292
+			if (in_array($fieldName, $fields)) {
293 293
 				$result[$fieldName] = $fieldValue;
294 294
 			}
295 295
 		}
Please login to merge, or discard this patch.
src/Builder/Expr/DBExprFilter.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,16 +27,16 @@  discard block
 block discarded – undo
27 27
 		$this->value = $data;
28 28
 		$this->keyPath = $this->buildKey($keyPath);
29 29
 		$this->value = $this->recursiveGet($data, $this->keyPath, null);
30
-		if($validator === null) {
31
-			$validator = function ($data) {
32
-				if(is_array($data)) {
30
+		if ($validator === null) {
31
+			$validator = function($data) {
32
+				if (is_array($data)) {
33 33
 					return $this->isValidArray($data);
34 34
 				}
35 35
 				return (string) $data !== '';
36 36
 			};
37 37
 		}
38
-		if($validationResultHandler === null) {
39
-			$validationResultHandler = static function () {};
38
+		if ($validationResultHandler === null) {
39
+			$validationResultHandler = static function() {};
40 40
 		}
41 41
 		$this->validator = $validator;
42 42
 		$this->validationResultHandler = $validationResultHandler;
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
 	 * @return string[]
74 74
 	 */
75 75
 	private function buildKey($keyPath): array {
76
-		if(is_string($keyPath)) {
76
+		if (is_string($keyPath)) {
77 77
 			$keyPath = explode('.', $keyPath);
78 78
 		}
79
-		if(!is_array($keyPath)) {
79
+		if (!is_array($keyPath)) {
80 80
 			throw new RuntimeException('Invalid key');
81 81
 		}
82 82
 		return $keyPath;
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 * @return bool
88 88
 	 */
89 89
 	private function isValidArray(array $array): bool {
90
-		$data = array_filter($array, function ($value) {
91
-			if(is_array($value)) {
90
+		$data = array_filter($array, function($value) {
91
+			if (is_array($value)) {
92 92
 				return $this->isValidArray($value);
93 93
 			}
94 94
 			return (string) $value !== '';
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
 		if (!$count) {
108 108
 			return $default;
109 109
 		}
110
-		foreach($path as $idxValue) {
110
+		foreach ($path as $idxValue) {
111 111
 			$part = $idxValue;
112
-			if(!array_key_exists($part, $array)) {
112
+			if (!array_key_exists($part, $array)) {
113 113
 				return $default;
114 114
 			}
115 115
 			$array = $array[$part];
Please login to merge, or discard this patch.
src/Builder/Expr/RequiredDBFilterMap.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,8 +34,8 @@
 block discarded – undo
34 34
 	 * @return DBExprFilter
35 35
 	 */
36 36
 	public function __invoke(string $expression, $keyPath, $validator = null) {
37
-		return new DBExprFilter($expression, $this->map, $keyPath, $validator, static function ($result, array $data) {
38
-			if(!$result) {
37
+		return new DBExprFilter($expression, $this->map, $keyPath, $validator, static function($result, array $data) {
38
+			if (!$result) {
39 39
 				throw new RequiredValueNotFoundException(sprintf("Required value %s not found", $data['key']));
40 40
 			}
41 41
 		});
Please login to merge, or discard this patch.
src/Builder/Expr/DBExprOrderBySpec.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,16 +11,16 @@
 block discarded – undo
11 11
 	 */
12 12
 	public function __construct(array $spec, array $sortFieldsSpec) {
13 13
 		$expressions = [];
14
-		foreach($spec as $specReference => $dbExpr) {
15
-			if(is_int($specReference)) {
14
+		foreach ($spec as $specReference => $dbExpr) {
15
+			if (is_int($specReference)) {
16 16
 				$specReference = $dbExpr;
17 17
 			}
18 18
 			$expressions[$specReference] = $dbExpr;
19 19
 		}
20
-		foreach($sortFieldsSpec as $sortFieldSpec) {
21
-			if(array_key_exists(0, $sortFieldSpec) && array_key_exists($sortFieldSpec[0], $expressions)) {
20
+		foreach ($sortFieldsSpec as $sortFieldSpec) {
21
+			if (array_key_exists(0, $sortFieldSpec) && array_key_exists($sortFieldSpec[0], $expressions)) {
22 22
 				$direction = 'ASC';
23
-				if(array_key_exists(1, $sortFieldSpec) && strtoupper($sortFieldSpec[1]) !== 'ASC') {
23
+				if (array_key_exists(1, $sortFieldSpec) && strtoupper($sortFieldSpec[1]) !== 'ASC') {
24 24
 					$direction = 'DESC';
25 25
 				}
26 26
 				$this->fields[] = [
Please login to merge, or discard this patch.
src/Builder/Helpers/LazyRowGenerator.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -22,17 +22,17 @@
 block discarded – undo
22 22
 	 * @return Generator|mixed[]
23 23
 	 */
24 24
 	public function generate(QueryStatement $statement, Closure $callback = null) {
25
-		while($row = $statement->fetch()) {
26
-			if($this->preserveTypes) {
25
+		while ($row = $statement->fetch()) {
26
+			if ($this->preserveTypes) {
27 27
 				$columnDefinitions = FieldTypeProvider::getFieldTypes($statement);
28 28
 				$row = FieldValueConverter::convertValues($row, $columnDefinitions);
29 29
 			}
30
-			if($callback !== null) {
30
+			if ($callback !== null) {
31 31
 				$result = $callback($row);
32
-				if($result instanceof DBIgnoreRow) {
32
+				if ($result instanceof DBIgnoreRow) {
33 33
 					// Do nothing in this case
34 34
 					continue;
35
-				} elseif($result !== null) {
35
+				} elseif ($result !== null) {
36 36
 					yield $result;
37 37
 				} else {
38 38
 					yield $row;
Please login to merge, or discard this patch.