@@ -10,7 +10,7 @@ |
||
10 | 10 | */ |
11 | 11 | public static function getFieldTypes(QueryStatement $statement) { |
12 | 12 | $fieldTypes = []; |
13 | - for($i = 0; $column = $statement->getColumnMeta($i); $i++) { |
|
13 | + for ($i = 0; $column = $statement->getColumnMeta($i); $i++) { |
|
14 | 14 | $fieldTypes[$column['name']] = self::getTypeFromNativeType($column['native_type']); |
15 | 15 | } |
16 | 16 | return $fieldTypes; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @return mixed[] |
92 | 92 | */ |
93 | 93 | public function fetchRow(Closure $callback = null) { |
94 | - return $this->fetch($callback, PDO::FETCH_ASSOC, null, function ($row) { |
|
94 | + return $this->fetch($callback, PDO::FETCH_ASSOC, null, function($row) { |
|
95 | 95 | return ['valid' => is_array($row), 'default' => []]; |
96 | 96 | }); |
97 | 97 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * @return object[] |
121 | 121 | */ |
122 | 122 | public function fetchObject($className = null, Closure $callback = null) { |
123 | - return $this->fetch($callback, PDO::FETCH_CLASS, $className ?: $this->defaultClassName, function ($row) { |
|
123 | + return $this->fetch($callback, PDO::FETCH_CLASS, $className ?: $this->defaultClassName, function($row) { |
|
124 | 124 | return ['valid' => is_object($row), 'default' => null]; |
125 | 125 | }); |
126 | 126 | } |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | * @return mixed[] |
131 | 131 | */ |
132 | 132 | public function fetchKeyValue($treatValueAsArray = false) { |
133 | - return $this->createTempStatement(function (QueryStatement $statement) use ($treatValueAsArray) { |
|
134 | - if($treatValueAsArray) { |
|
133 | + return $this->createTempStatement(function(QueryStatement $statement) use ($treatValueAsArray) { |
|
134 | + if ($treatValueAsArray) { |
|
135 | 135 | $rows = $statement->fetchAll(\PDO::FETCH_ASSOC); |
136 | 136 | $result = []; |
137 | - foreach($rows as $row) { |
|
137 | + foreach ($rows as $row) { |
|
138 | 138 | list($key) = array_values($row); |
139 | 139 | $result[$key] = $row; |
140 | 140 | } |
@@ -151,11 +151,11 @@ discard block |
||
151 | 151 | public function fetchGroups(array $fields) { |
152 | 152 | $rows = $this->fetchRows(); |
153 | 153 | $result = []; |
154 | - foreach($rows as $row) { |
|
154 | + foreach ($rows as $row) { |
|
155 | 155 | $tmp = &$result; |
156 | - foreach($fields as $field) { |
|
156 | + foreach ($fields as $field) { |
|
157 | 157 | $value = $row[$field]; |
158 | - if(!array_key_exists($value, $tmp)) { |
|
158 | + if (!array_key_exists($value, $tmp)) { |
|
159 | 159 | $tmp[$value] = []; |
160 | 160 | } |
161 | 161 | $tmp = &$tmp[$value]; |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @return string[] |
170 | 170 | */ |
171 | 171 | public function fetchArray() { |
172 | - return $this->createTempStatement(function (QueryStatement $stmt) { |
|
172 | + return $this->createTempStatement(function(QueryStatement $stmt) { |
|
173 | 173 | return $stmt->fetchAll(\PDO::FETCH_COLUMN); |
174 | 174 | }); |
175 | 175 | } |
@@ -179,9 +179,9 @@ discard block |
||
179 | 179 | * @return null|bool|string|int|float |
180 | 180 | */ |
181 | 181 | public function fetchValue($default = null) { |
182 | - return $this->createTempStatement(function (QueryStatement $stmt) use ($default) { |
|
182 | + return $this->createTempStatement(function(QueryStatement $stmt) use ($default) { |
|
183 | 183 | $result = $stmt->fetch(\PDO::FETCH_NUM); |
184 | - if($result !== false) { |
|
184 | + if ($result !== false) { |
|
185 | 185 | return $result[0]; |
186 | 186 | } |
187 | 187 | return $default; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | $query = $this->__toString(); |
220 | 220 | $statement = $db->prepare($query); |
221 | 221 | $statement->execute($this->values); |
222 | - if($this->getCalcFoundRows()) { |
|
222 | + if ($this->getCalcFoundRows()) { |
|
223 | 223 | $this->foundRows = (int) $db->query('SELECT FOUND_ROWS()')->fetchColumn(); |
224 | 224 | } |
225 | 225 | return $statement; |
@@ -239,20 +239,20 @@ discard block |
||
239 | 239 | * @return mixed |
240 | 240 | */ |
241 | 241 | private function fetchAll(Closure $callback = null, $mode, $arg0 = null) { |
242 | - return $this->createTempStatement(function (QueryStatement $statement) use ($callback, $mode, $arg0) { |
|
242 | + return $this->createTempStatement(function(QueryStatement $statement) use ($callback, $mode, $arg0) { |
|
243 | 243 | $statement->setFetchMode($mode, $arg0); |
244 | 244 | $data = $statement->fetchAll(); |
245 | - if($this->preserveTypes) { |
|
245 | + if ($this->preserveTypes) { |
|
246 | 246 | $columnDefinitions = FieldTypeProvider::getFieldTypes($statement); |
247 | - foreach($data as &$row) { |
|
247 | + foreach ($data as &$row) { |
|
248 | 248 | $row = FieldValueConverter::convertValues($row, $columnDefinitions); |
249 | 249 | } |
250 | 250 | } |
251 | - if($callback !== null) { |
|
252 | - return call_user_func(function ($resultData = []) use ($data, $callback) { |
|
253 | - foreach($data as $row) { |
|
251 | + if ($callback !== null) { |
|
252 | + return call_user_func(function($resultData = []) use ($data, $callback) { |
|
253 | + foreach ($data as $row) { |
|
254 | 254 | $result = $callback($row); |
255 | - if($result !== null && !($result instanceof DBIgnoreRow)) { |
|
255 | + if ($result !== null && !($result instanceof DBIgnoreRow)) { |
|
256 | 256 | $resultData[] = $result; |
257 | 257 | } else { |
258 | 258 | $resultData[] = $row; |
@@ -286,20 +286,20 @@ discard block |
||
286 | 286 | * @return mixed |
287 | 287 | */ |
288 | 288 | private function fetch(Closure $callback = null, $mode, $arg0 = null, Closure $resultValidator = null) { |
289 | - return $this->createTempStatement(function (QueryStatement $statement) use ($callback, $mode, $arg0, $resultValidator) { |
|
289 | + return $this->createTempStatement(function(QueryStatement $statement) use ($callback, $mode, $arg0, $resultValidator) { |
|
290 | 290 | $statement->setFetchMode($mode, $arg0); |
291 | 291 | $row = $statement->fetch(); |
292 | 292 | $result = $resultValidator($row); |
293 | - if(!$result['valid']) { |
|
293 | + if (!$result['valid']) { |
|
294 | 294 | return $result['default']; |
295 | 295 | } |
296 | - if($this->preserveTypes) { |
|
296 | + if ($this->preserveTypes) { |
|
297 | 297 | $columnDefinitions = FieldTypeProvider::getFieldTypes($statement); |
298 | 298 | $row = FieldValueConverter::convertValues($row, $columnDefinitions); |
299 | 299 | } |
300 | - if($callback !== null) { |
|
300 | + if ($callback !== null) { |
|
301 | 301 | $result = $callback($row); |
302 | - if($result !== null) { |
|
302 | + if ($result !== null) { |
|
303 | 303 | $row = $result; |
304 | 304 | } |
305 | 305 | } |
@@ -25,7 +25,7 @@ |
||
25 | 25 | public function run(array $params = []) { |
26 | 26 | $this->query->execute($params); |
27 | 27 | $response = $this->query->getStatement()->rowCount(); |
28 | - if($this->callbackFn !== null) { |
|
28 | + if ($this->callbackFn !== null) { |
|
29 | 29 | $response = call_user_func($this->callbackFn, $response); |
30 | 30 | } |
31 | 31 | return $response; |
@@ -22,16 +22,16 @@ |
||
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 | - } elseif($result !== null) { |
|
34 | + } elseif ($result !== null) { |
|
35 | 35 | yield $result; |
36 | 36 | } else { |
37 | 37 | yield $row; |
@@ -31,10 +31,10 @@ |
||
31 | 31 | * @return Select|null |
32 | 32 | */ |
33 | 33 | public function get($tableName) { |
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 call_user_func($table, $params); |
40 | 40 | } |
@@ -41,7 +41,7 @@ discard block |
||
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 |
||
75 | 75 | * @return VirtualTables |
76 | 76 | */ |
77 | 77 | public function getVirtualTables() { |
78 | - if($this->virtualTables === null) { |
|
78 | + if ($this->virtualTables === null) { |
|
79 | 79 | $this->virtualTables = new VirtualTables(); |
80 | 80 | } |
81 | 81 | return $this->virtualTables; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @return QueryStatement |
88 | 88 | */ |
89 | 89 | public function query($query) { |
90 | - return $this->buildQueryStatement($query, function ($query) { |
|
90 | + return $this->buildQueryStatement($query, function($query) { |
|
91 | 91 | $stmt = $this->pdo->query($query); |
92 | 92 | return $stmt; |
93 | 93 | }); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @return QueryStatement |
100 | 100 | */ |
101 | 101 | public function prepare($query) { |
102 | - return $this->buildQueryStatement((string) $query, function ($query) { |
|
102 | + return $this->buildQueryStatement((string) $query, function($query) { |
|
103 | 103 | $stmt = $this->pdo->prepare($query); |
104 | 104 | return $stmt; |
105 | 105 | }); |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | * @return int |
112 | 112 | */ |
113 | 113 | public function exec($query, array $params = []) { |
114 | - return $this->exceptionHandler(function () use ($query, $params) { |
|
114 | + return $this->exceptionHandler(function() use ($query, $params) { |
|
115 | 115 | $stmt = $this->pdo->prepare($query); |
116 | 116 | $timer = microtime(true); |
117 | 117 | $stmt->execute($params); |
118 | - $this->queryLoggers->log($query, microtime(true) - $timer); |
|
118 | + $this->queryLoggers->log($query, microtime(true)-$timer); |
|
119 | 119 | $result = $stmt->rowCount(); |
120 | 120 | $stmt->closeCursor(); |
121 | 121 | return $result; |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function getTableFields($table) { |
137 | 137 | $table = $this->select()->aliasReplacer()->replace($table); |
138 | - if(array_key_exists($table, self::$tableFields)) { |
|
138 | + if (array_key_exists($table, self::$tableFields)) { |
|
139 | 139 | return self::$tableFields[$table]; |
140 | 140 | } |
141 | 141 | $stmt = $this->pdo->query("DESCRIBE {$table}"); |
142 | 142 | $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC); |
143 | - self::$tableFields[$table] = array_map(function ($row) { return $row['Field']; }, $rows); |
|
143 | + self::$tableFields[$table] = array_map(function($row) { return $row['Field']; }, $rows); |
|
144 | 144 | $stmt->closeCursor(); |
145 | 145 | return self::$tableFields[$table]; |
146 | 146 | } |
@@ -152,12 +152,12 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function quoteExpression($expression, array $arguments = array()) { |
154 | 154 | $index = -1; |
155 | - $func = function () use ($arguments, &$index) { |
|
155 | + $func = function() use ($arguments, &$index) { |
|
156 | 156 | $index++; |
157 | - if(array_key_exists($index, $arguments)) { |
|
157 | + if (array_key_exists($index, $arguments)) { |
|
158 | 158 | $argument = $arguments[$index]; |
159 | 159 | $value = $this->quote($argument); |
160 | - } elseif(count($arguments) > 0) { |
|
160 | + } elseif (count($arguments) > 0) { |
|
161 | 161 | $args = $arguments; |
162 | 162 | $value = array_pop($args); |
163 | 163 | $value = $this->quote($value); |
@@ -175,14 +175,14 @@ discard block |
||
175 | 175 | * @return string |
176 | 176 | */ |
177 | 177 | public function quote($value) { |
178 | - if(is_null($value)) { |
|
178 | + if (is_null($value)) { |
|
179 | 179 | $result = 'NULL'; |
180 | - } elseif($value instanceof Builder\DBExpr) { |
|
180 | + } elseif ($value instanceof Builder\DBExpr) { |
|
181 | 181 | $result = $value->getExpression(); |
182 | - } elseif($value instanceof Builder\Select) { |
|
182 | + } elseif ($value instanceof Builder\Select) { |
|
183 | 183 | $result = sprintf('(%s)', (string) $value); |
184 | - } elseif(is_array($value)) { |
|
185 | - $result = join(', ', array_map(function ($value) { return $this->quote($value); }, $value)); |
|
184 | + } elseif (is_array($value)) { |
|
185 | + $result = join(', ', array_map(function($value) { return $this->quote($value); }, $value)); |
|
186 | 186 | } else { |
187 | 187 | $result = $this->pdo->quote($value); |
188 | 188 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | if (is_numeric($field) || !is_string($field)) { |
198 | 198 | throw new UnexpectedValueException('Field name is invalid'); |
199 | 199 | } |
200 | - if(strpos($field, '`') !== false) { |
|
200 | + if (strpos($field, '`') !== false) { |
|
201 | 201 | return (string) $field; |
202 | 202 | } |
203 | 203 | $parts = explode('.', $field); |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $select = array_key_exists('select-factory', $this->options) |
213 | 213 | ? call_user_func($this->options['select-factory'], $this, $this->options['select-options']) |
214 | 214 | : new Builder\RunnableSelect($this, $this->options['select-options']); |
215 | - if($fields !== null) { |
|
215 | + if ($fields !== null) { |
|
216 | 216 | $select->fields($fields); |
217 | 217 | } |
218 | 218 | return $select; |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $insert = array_key_exists('insert-factory', $this->options) |
227 | 227 | ? call_user_func($this->options['insert-factory'], $this, $this->options['insert-options']) |
228 | 228 | : new Builder\RunnableInsert($this, $this->options['insert-options']); |
229 | - if($fields !== null) { |
|
229 | + if ($fields !== null) { |
|
230 | 230 | $insert->addAll($fields); |
231 | 231 | } |
232 | 232 | return $insert; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | $update = array_key_exists('update-factory', $this->options) |
241 | 241 | ? call_user_func($this->options['update-factory'], $this, $this->options['update-options']) |
242 | 242 | : new Builder\RunnableUpdate($this, $this->options['update-options']); |
243 | - if($fields !== null) { |
|
243 | + if ($fields !== null) { |
|
244 | 244 | $update->setAll($fields); |
245 | 245 | } |
246 | 246 | return $update; |
@@ -259,8 +259,8 @@ discard block |
||
259 | 259 | * @return $this |
260 | 260 | */ |
261 | 261 | public function transactionStart() { |
262 | - if($this->transactionLevel === 0) { |
|
263 | - if($this->pdo->inTransaction()) { |
|
262 | + if ($this->transactionLevel === 0) { |
|
263 | + if ($this->pdo->inTransaction()) { |
|
264 | 264 | $this->outerTransaction = true; |
265 | 265 | } else { |
266 | 266 | $this->pdo->beginTransaction(); |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * @return $this |
275 | 275 | */ |
276 | 276 | public function transactionCommit() { |
277 | - return $this->transactionEnd(function () { |
|
277 | + return $this->transactionEnd(function() { |
|
278 | 278 | $this->pdo->commit(); |
279 | 279 | }); |
280 | 280 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @return $this |
284 | 284 | */ |
285 | 285 | public function transactionRollback() { |
286 | - return $this->transactionEnd(function () { |
|
286 | + return $this->transactionEnd(function() { |
|
287 | 287 | $this->pdo->rollBack(); |
288 | 288 | }); |
289 | 289 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * @return mixed |
294 | 294 | */ |
295 | 295 | public function dryRun($callback = null) { |
296 | - if(!$this->pdo->inTransaction()) { |
|
296 | + if (!$this->pdo->inTransaction()) { |
|
297 | 297 | $this->transactionStart(); |
298 | 298 | try { |
299 | 299 | return call_user_func($callback, $this); |
@@ -317,14 +317,14 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public function transaction(callable $callback = null) { |
319 | 319 | $result = null; |
320 | - if(!$this->pdo->inTransaction()) { |
|
320 | + if (!$this->pdo->inTransaction()) { |
|
321 | 321 | $this->transactionStart(); |
322 | 322 | try { |
323 | 323 | $result = call_user_func($callback, $this); |
324 | 324 | $this->transactionCommit(); |
325 | 325 | return $result; |
326 | 326 | } finally { |
327 | - if($this->pdo->inTransaction()) { |
|
327 | + if ($this->pdo->inTransaction()) { |
|
328 | 328 | $this->transactionRollback(); |
329 | 329 | } |
330 | 330 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | $rollback = false; |
338 | 338 | return $result; |
339 | 339 | } finally { |
340 | - if($rollback) { |
|
340 | + if ($rollback) { |
|
341 | 341 | $this->exec("ROLLBACK TO {$uniqueId}"); |
342 | 342 | } else { |
343 | 343 | $this->exec("RELEASE SAVEPOINT {$uniqueId}"); |
@@ -353,10 +353,10 @@ discard block |
||
353 | 353 | */ |
354 | 354 | private function transactionEnd($fn) { |
355 | 355 | $this->transactionLevel--; |
356 | - if($this->transactionLevel < 0) { |
|
356 | + if ($this->transactionLevel < 0) { |
|
357 | 357 | throw new RuntimeException("Transaction-Nesting-Problem: Trying to invoke commit on a already closed transaction"); |
358 | - } elseif($this->transactionLevel < 1) { |
|
359 | - if($this->outerTransaction) { |
|
358 | + } elseif ($this->transactionLevel < 1) { |
|
359 | + if ($this->outerTransaction) { |
|
360 | 360 | $this->outerTransaction = false; |
361 | 361 | } else { |
362 | 362 | call_user_func($fn); |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | */ |
374 | 374 | private function buildQueryStatement($query, $fn) { |
375 | 375 | $stmt = call_user_func($fn, $query); |
376 | - if(!$stmt) { |
|
376 | + if (!$stmt) { |
|
377 | 377 | throw new RuntimeException("Could not execute statement:\n{$query}"); |
378 | 378 | } |
379 | 379 | $stmtWrapper = new QueryStatement($stmt, $query, $this->exceptionInterpreter, $this->queryLoggers); |
@@ -19,7 +19,7 @@ |
||
19 | 19 | /** @link http://php.net/manual/en/class.exception.php#Hcom115813 (cHao's comment) */ |
20 | 20 | $code = is_array($errorInfo) && isset($errorInfo[1]) ? ((int) $errorInfo[1]) : ((int) $exception->getCode()); |
21 | 21 | $message = (string) $exception->getMessage(); |
22 | - switch($code) { |
|
22 | + switch ($code) { |
|
23 | 23 | case 2006: throw new DatabaseHasGoneAwayException($message, $code, $exception); |
24 | 24 | case 1213: throw new SqlDeadLockException($message, $code, $exception); |
25 | 25 | case 1205: throw new LockWaitTimeoutExceededException($message, $code, $exception); |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function setFetchMode($mode, $arg0 = null, array $arg1 = null) { |
49 | 49 | $args = [$mode]; |
50 | - if($arg0 !== null) { |
|
50 | + if ($arg0 !== null) { |
|
51 | 51 | $args[] = $arg0; |
52 | 52 | } |
53 | - if($arg1 !== null) { |
|
53 | + if ($arg1 !== null) { |
|
54 | 54 | $args[] = $arg1; |
55 | 55 | } |
56 | 56 | $this->statement->setFetchMode(...$args); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $timer = microtime(true); |
68 | 68 | $response = $this->statement->execute($params); |
69 | 69 | $this->queryLoggers->log($this->query, microtime(true)-$timer); |
70 | - if(!$response) { |
|
70 | + if (!$response) { |
|
71 | 71 | throw new SqlException('Execution returned with "false".'); |
72 | 72 | } |
73 | 73 | }); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function fetchAll($fetchStyle = null, $fetchArgument = null, array $ctorArgs = []) { |
84 | 84 | return $this->exceptionHandler(function() use ($fetchStyle, $fetchArgument, $ctorArgs) { |
85 | - if($fetchArgument !== null) { |
|
85 | + if ($fetchArgument !== null) { |
|
86 | 86 | return $this->statement->fetchAll($fetchStyle, $fetchArgument, $ctorArgs); |
87 | 87 | } |
88 | 88 | return $this->statement->fetchAll($fetchStyle); |
@@ -27,16 +27,16 @@ discard block |
||
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 = function () {}; |
|
38 | + if ($validationResultHandler === null) { |
|
39 | + $validationResultHandler = function() {}; |
|
40 | 40 | } |
41 | 41 | $this->validator = $validator; |
42 | 42 | $this->validationResultHandler = $validationResultHandler; |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | * @return string[] |
74 | 74 | */ |
75 | 75 | private function buildKey($keyPath) { |
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 |
||
87 | 87 | * @return bool |
88 | 88 | */ |
89 | 89 | private function isValidArray(array $array) { |
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 |
||
107 | 107 | if (!$count) { |
108 | 108 | return $default; |
109 | 109 | } |
110 | - for($idx = 0; $idx < $count; $idx++) { |
|
110 | + for ($idx = 0; $idx < $count; $idx++) { |
|
111 | 111 | $part = $path[$idx]; |
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]; |