@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | return false; |
81 | 81 | } |
82 | 82 | |
83 | - return (array)$this->array; |
|
83 | + return (array) $this->array; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -293,8 +293,8 @@ discard block |
||
293 | 293 | } |
294 | 294 | |
295 | 295 | // php cast "bool"-index into "int"-index |
296 | - if ((bool)$offset === $offset) { |
|
297 | - $offset = (int)$offset; |
|
296 | + if ((bool) $offset === $offset) { |
|
297 | + $offset = (int) $offset; |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | $tmpReturn = \array_key_exists($offset, $this->array); |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | ( |
306 | 306 | $tmpReturn === false |
307 | 307 | && |
308 | - strpos((string)$offset, $this->pathSeparator) === false |
|
308 | + strpos((string) $offset, $this->pathSeparator) === false |
|
309 | 309 | ) |
310 | 310 | ) { |
311 | 311 | return $tmpReturn; |
@@ -313,16 +313,16 @@ discard block |
||
313 | 313 | |
314 | 314 | $offsetExists = false; |
315 | 315 | |
316 | - if (strpos((string)$offset, $this->pathSeparator) !== false) { |
|
316 | + if (strpos((string) $offset, $this->pathSeparator) !== false) { |
|
317 | 317 | |
318 | 318 | $offsetExists = false; |
319 | - $explodedPath = explode($this->pathSeparator, (string)$offset); |
|
319 | + $explodedPath = explode($this->pathSeparator, (string) $offset); |
|
320 | 320 | $lastOffset = \array_pop($explodedPath); |
321 | 321 | $containerPath = implode($this->pathSeparator, $explodedPath); |
322 | 322 | |
323 | 323 | $this->callAtPath( |
324 | 324 | $containerPath, |
325 | - function ($container) use ($lastOffset, &$offsetExists) { |
|
325 | + function($container) use ($lastOffset, &$offsetExists) { |
|
326 | 326 | $offsetExists = \array_key_exists($lastOffset, $container); |
327 | 327 | } |
328 | 328 | ); |
@@ -375,14 +375,14 @@ discard block |
||
375 | 375 | return; |
376 | 376 | } |
377 | 377 | |
378 | - if (strpos((string)$offset, $this->pathSeparator) !== false) { |
|
378 | + if (strpos((string) $offset, $this->pathSeparator) !== false) { |
|
379 | 379 | |
380 | - $path = explode($this->pathSeparator, (string)$offset); |
|
380 | + $path = explode($this->pathSeparator, (string) $offset); |
|
381 | 381 | $pathToUnset = \array_pop($path); |
382 | 382 | |
383 | 383 | $this->callAtPath( |
384 | 384 | implode($this->pathSeparator, $path), |
385 | - function (&$offset) use ($pathToUnset) { |
|
385 | + function(&$offset) use ($pathToUnset) { |
|
386 | 386 | unset($offset[$pathToUnset]); |
387 | 387 | } |
388 | 388 | ); |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | } |
419 | 419 | |
420 | 420 | if (strpos($class, '\\') === 0) { |
421 | - $class = '\\' . $class; |
|
421 | + $class = '\\'.$class; |
|
422 | 422 | if (class_exists($class)) { |
423 | 423 | $this->iteratorClass = $class; |
424 | 424 | |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | } |
427 | 427 | } |
428 | 428 | |
429 | - throw new \InvalidArgumentException('The iterator class does not exist: ' . $class); |
|
429 | + throw new \InvalidArgumentException('The iterator class does not exist: '.$class); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | /** |
@@ -491,11 +491,11 @@ discard block |
||
491 | 491 | $result = array(); |
492 | 492 | foreach ($this->array as $key => $item) { |
493 | 493 | if ($item instanceof self) { |
494 | - $result[$prefix . $key] = $item->appendToEachKey($prefix); |
|
494 | + $result[$prefix.$key] = $item->appendToEachKey($prefix); |
|
495 | 495 | } elseif (is_array($item)) { |
496 | - $result[$prefix . $key] = self::create($item)->appendToEachKey($prefix)->toArray(); |
|
496 | + $result[$prefix.$key] = self::create($item)->appendToEachKey($prefix)->toArray(); |
|
497 | 497 | } else { |
498 | - $result[$prefix . $key] = $item; |
|
498 | + $result[$prefix.$key] = $item; |
|
499 | 499 | } |
500 | 500 | } |
501 | 501 | |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | } elseif (is_object($item)) { |
521 | 521 | $result[$key] = $item; |
522 | 522 | } else { |
523 | - $result[$key] = $prefix . $item; |
|
523 | + $result[$key] = $prefix.$item; |
|
524 | 524 | } |
525 | 525 | } |
526 | 526 | |
@@ -686,8 +686,8 @@ discard block |
||
686 | 686 | public function clean() |
687 | 687 | { |
688 | 688 | return $this->filter( |
689 | - function ($value) { |
|
690 | - return (bool)$value; |
|
689 | + function($value) { |
|
690 | + return (bool) $value; |
|
691 | 691 | } |
692 | 692 | ); |
693 | 693 | } |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | // trim all string in the array |
903 | 903 | \array_walk( |
904 | 904 | $array, |
905 | - function (&$val) { |
|
905 | + function(&$val) { |
|
906 | 906 | /** @noinspection ReferenceMismatchInspection */ |
907 | 907 | if (is_string($val)) { |
908 | 908 | $val = trim($val); |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | } |
1142 | 1142 | |
1143 | 1143 | if ($isObject && method_exists($array, '__toArray')) { |
1144 | - return (array)$array->__toArray(); |
|
1144 | + return (array) $array->__toArray(); |
|
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | /** @noinspection ReferenceMismatchInspection */ |
@@ -1150,7 +1150,7 @@ discard block |
||
1150 | 1150 | || |
1151 | 1151 | ($isObject && method_exists($array, '__toString')) |
1152 | 1152 | ) { |
1153 | - return array((string)$array); |
|
1153 | + return array((string) $array); |
|
1154 | 1154 | } |
1155 | 1155 | |
1156 | 1156 | throw new \InvalidArgumentException( |
@@ -1257,54 +1257,54 @@ discard block |
||
1257 | 1257 | } |
1258 | 1258 | |
1259 | 1259 | $ops = array( |
1260 | - 'eq' => function ($item, $prop, $value) { |
|
1260 | + 'eq' => function($item, $prop, $value) { |
|
1261 | 1261 | return $item[$prop] === $value; |
1262 | 1262 | }, |
1263 | - 'gt' => function ($item, $prop, $value) { |
|
1263 | + 'gt' => function($item, $prop, $value) { |
|
1264 | 1264 | return $item[$prop] > $value; |
1265 | 1265 | }, |
1266 | - 'ge' => function ($item, $prop, $value) { |
|
1266 | + 'ge' => function($item, $prop, $value) { |
|
1267 | 1267 | return $item[$prop] >= $value; |
1268 | 1268 | }, |
1269 | - 'gte' => function ($item, $prop, $value) { |
|
1269 | + 'gte' => function($item, $prop, $value) { |
|
1270 | 1270 | return $item[$prop] >= $value; |
1271 | 1271 | }, |
1272 | - 'lt' => function ($item, $prop, $value) { |
|
1272 | + 'lt' => function($item, $prop, $value) { |
|
1273 | 1273 | return $item[$prop] < $value; |
1274 | 1274 | }, |
1275 | - 'le' => function ($item, $prop, $value) { |
|
1275 | + 'le' => function($item, $prop, $value) { |
|
1276 | 1276 | return $item[$prop] <= $value; |
1277 | 1277 | }, |
1278 | - 'lte' => function ($item, $prop, $value) { |
|
1278 | + 'lte' => function($item, $prop, $value) { |
|
1279 | 1279 | return $item[$prop] <= $value; |
1280 | 1280 | }, |
1281 | - 'ne' => function ($item, $prop, $value) { |
|
1281 | + 'ne' => function($item, $prop, $value) { |
|
1282 | 1282 | return $item[$prop] !== $value; |
1283 | 1283 | }, |
1284 | - 'contains' => function ($item, $prop, $value) { |
|
1285 | - return in_array($item[$prop], (array)$value, true); |
|
1284 | + 'contains' => function($item, $prop, $value) { |
|
1285 | + return in_array($item[$prop], (array) $value, true); |
|
1286 | 1286 | }, |
1287 | - 'notContains' => function ($item, $prop, $value) { |
|
1288 | - return !in_array($item[$prop], (array)$value, true); |
|
1287 | + 'notContains' => function($item, $prop, $value) { |
|
1288 | + return !in_array($item[$prop], (array) $value, true); |
|
1289 | 1289 | }, |
1290 | - 'newer' => function ($item, $prop, $value) { |
|
1290 | + 'newer' => function($item, $prop, $value) { |
|
1291 | 1291 | return strtotime($item[$prop]) > strtotime($value); |
1292 | 1292 | }, |
1293 | - 'older' => function ($item, $prop, $value) { |
|
1293 | + 'older' => function($item, $prop, $value) { |
|
1294 | 1294 | return strtotime($item[$prop]) < strtotime($value); |
1295 | 1295 | }, |
1296 | 1296 | ); |
1297 | 1297 | |
1298 | 1298 | $result = \array_values( |
1299 | 1299 | \array_filter( |
1300 | - (array)$this->array, |
|
1301 | - function ($item) use ( |
|
1300 | + (array) $this->array, |
|
1301 | + function($item) use ( |
|
1302 | 1302 | $property, |
1303 | 1303 | $value, |
1304 | 1304 | $ops, |
1305 | 1305 | $comparisonOp |
1306 | 1306 | ) { |
1307 | - $item = (array)$item; |
|
1307 | + $item = (array) $item; |
|
1308 | 1308 | $itemArrayy = new Arrayy($item); |
1309 | 1309 | $item[$property] = $itemArrayy->get($property, array()); |
1310 | 1310 | |
@@ -1377,9 +1377,9 @@ discard block |
||
1377 | 1377 | { |
1378 | 1378 | if ($number === null) { |
1379 | 1379 | $arrayTmp = $this->array; |
1380 | - $array = (array)\array_shift($arrayTmp); |
|
1380 | + $array = (array) \array_shift($arrayTmp); |
|
1381 | 1381 | } else { |
1382 | - $number = (int)$number; |
|
1382 | + $number = (int) $number; |
|
1383 | 1383 | $arrayTmp = $this->array; |
1384 | 1384 | $array = \array_splice($arrayTmp, 0, $number, true); |
1385 | 1385 | } |
@@ -1397,9 +1397,9 @@ discard block |
||
1397 | 1397 | public function firstsMutable($number = null) |
1398 | 1398 | { |
1399 | 1399 | if ($number === null) { |
1400 | - $this->array = (array)\array_shift($this->array); |
|
1400 | + $this->array = (array) \array_shift($this->array); |
|
1401 | 1401 | } else { |
1402 | - $number = (int)$number; |
|
1402 | + $number = (int) $number; |
|
1403 | 1403 | $this->array = \array_splice($this->array, 0, $number, true); |
1404 | 1404 | } |
1405 | 1405 | |
@@ -1445,8 +1445,8 @@ discard block |
||
1445 | 1445 | } |
1446 | 1446 | |
1447 | 1447 | // php cast "bool"-index into "int"-index |
1448 | - if ((bool)$key === $key) { |
|
1449 | - $key = (int)$key; |
|
1448 | + if ((bool) $key === $key) { |
|
1449 | + $key = (int) $key; |
|
1450 | 1450 | } |
1451 | 1451 | |
1452 | 1452 | if (\array_key_exists($key, $usedArray) === true) { |
@@ -1458,7 +1458,7 @@ discard block |
||
1458 | 1458 | } |
1459 | 1459 | |
1460 | 1460 | // Crawl through array, get key according to object or not |
1461 | - foreach (explode($this->pathSeparator, (string)$key) as $segment) { |
|
1461 | + foreach (explode($this->pathSeparator, (string) $key) as $segment) { |
|
1462 | 1462 | if (!isset($usedArray[$segment])) { |
1463 | 1463 | return $fallback instanceof \Closure ? $fallback() : $fallback; |
1464 | 1464 | } |
@@ -1630,7 +1630,7 @@ discard block |
||
1630 | 1630 | */ |
1631 | 1631 | public function group($grouper, $saveKeys = false) |
1632 | 1632 | { |
1633 | - $array = (array)$this->array; |
|
1633 | + $array = (array) $this->array; |
|
1634 | 1634 | $result = array(); |
1635 | 1635 | |
1636 | 1636 | // Iterate over values, group by property/results from closure |
@@ -1673,7 +1673,7 @@ discard block |
||
1673 | 1673 | public function has($key) |
1674 | 1674 | { |
1675 | 1675 | // Generate unique string to use as marker. |
1676 | - $unFound = (string)uniqid('arrayy', true); |
|
1676 | + $unFound = (string) uniqid('arrayy', true); |
|
1677 | 1677 | |
1678 | 1678 | return $this->get($key, $unFound) !== $unFound; |
1679 | 1679 | } |
@@ -1796,7 +1796,7 @@ discard block |
||
1796 | 1796 | */ |
1797 | 1797 | protected function internalRemove($key) |
1798 | 1798 | { |
1799 | - $path = explode($this->pathSeparator, (string)$key); |
|
1799 | + $path = explode($this->pathSeparator, (string) $key); |
|
1800 | 1800 | |
1801 | 1801 | // Crawl though the keys |
1802 | 1802 | while (count($path) > 1) { |
@@ -1831,8 +1831,8 @@ discard block |
||
1831 | 1831 | } |
1832 | 1832 | |
1833 | 1833 | // init |
1834 | - $array =& $this->array; |
|
1835 | - $path = explode($this->pathSeparator, (string)$key); |
|
1834 | + $array = & $this->array; |
|
1835 | + $path = explode($this->pathSeparator, (string) $key); |
|
1836 | 1836 | |
1837 | 1837 | // Crawl through the keys |
1838 | 1838 | while (count($path) > 1) { |
@@ -1845,7 +1845,7 @@ discard block |
||
1845 | 1845 | $array[$key] = static::create(array()); |
1846 | 1846 | } |
1847 | 1847 | |
1848 | - $array =& $array[$key]; |
|
1848 | + $array = & $array[$key]; |
|
1849 | 1849 | } |
1850 | 1850 | |
1851 | 1851 | $array[\array_shift($path)] = $value; |
@@ -2049,12 +2049,12 @@ discard block |
||
2049 | 2049 | if ($poppedValue === null) { |
2050 | 2050 | $poppedValue = array($poppedValue); |
2051 | 2051 | } else { |
2052 | - $poppedValue = (array)$poppedValue; |
|
2052 | + $poppedValue = (array) $poppedValue; |
|
2053 | 2053 | } |
2054 | 2054 | |
2055 | 2055 | $arrayy = static::create($poppedValue); |
2056 | 2056 | } else { |
2057 | - $number = (int)$number; |
|
2057 | + $number = (int) $number; |
|
2058 | 2058 | $arrayy = $this->rest(-$number); |
2059 | 2059 | } |
2060 | 2060 | |
@@ -2080,12 +2080,12 @@ discard block |
||
2080 | 2080 | if ($poppedValue === null) { |
2081 | 2081 | $poppedValue = array($poppedValue); |
2082 | 2082 | } else { |
2083 | - $poppedValue = (array)$poppedValue; |
|
2083 | + $poppedValue = (array) $poppedValue; |
|
2084 | 2084 | } |
2085 | 2085 | |
2086 | 2086 | $this->array = static::create($poppedValue)->array; |
2087 | 2087 | } else { |
2088 | - $number = (int)$number; |
|
2088 | + $number = (int) $number; |
|
2089 | 2089 | $this->array = $this->rest(-$number)->array; |
2090 | 2090 | } |
2091 | 2091 | |
@@ -2422,7 +2422,7 @@ discard block |
||
2422 | 2422 | } elseif (is_array($item)) { |
2423 | 2423 | $result[$key] = self::create($item)->prependToEachKey($suffix)->toArray(); |
2424 | 2424 | } else { |
2425 | - $result[$key . $suffix] = $item; |
|
2425 | + $result[$key.$suffix] = $item; |
|
2426 | 2426 | } |
2427 | 2427 | |
2428 | 2428 | } |
@@ -2448,7 +2448,7 @@ discard block |
||
2448 | 2448 | } elseif (is_object($item)) { |
2449 | 2449 | $result[$key] = $item; |
2450 | 2450 | } else { |
2451 | - $result[$key] = $item . $suffix; |
|
2451 | + $result[$key] = $item.$suffix; |
|
2452 | 2452 | } |
2453 | 2453 | } |
2454 | 2454 | |
@@ -2524,7 +2524,7 @@ discard block |
||
2524 | 2524 | */ |
2525 | 2525 | public function randomKeys($number) |
2526 | 2526 | { |
2527 | - $number = (int)$number; |
|
2527 | + $number = (int) $number; |
|
2528 | 2528 | $count = $this->count(); |
2529 | 2529 | |
2530 | 2530 | if ($number === 0 || $number > $count) { |
@@ -2537,7 +2537,7 @@ discard block |
||
2537 | 2537 | ); |
2538 | 2538 | } |
2539 | 2539 | |
2540 | - $result = (array)\array_rand($this->array, $number); |
|
2540 | + $result = (array) \array_rand($this->array, $number); |
|
2541 | 2541 | |
2542 | 2542 | return static::create($result); |
2543 | 2543 | } |
@@ -2592,7 +2592,7 @@ discard block |
||
2592 | 2592 | */ |
2593 | 2593 | public function randomValues($number) |
2594 | 2594 | { |
2595 | - $number = (int)$number; |
|
2595 | + $number = (int) $number; |
|
2596 | 2596 | |
2597 | 2597 | return $this->randomMutable($number); |
2598 | 2598 | } |
@@ -2636,7 +2636,7 @@ discard block |
||
2636 | 2636 | if ($result === null) { |
2637 | 2637 | $this->array = array(); |
2638 | 2638 | } else { |
2639 | - $this->array = (array)$result; |
|
2639 | + $this->array = (array) $result; |
|
2640 | 2640 | } |
2641 | 2641 | |
2642 | 2642 | return static::create($this->array); |
@@ -2762,7 +2762,7 @@ discard block |
||
2762 | 2762 | return new static(); |
2763 | 2763 | } |
2764 | 2764 | |
2765 | - return static::create(\array_fill(0, (int)$times, $this->array)); |
|
2765 | + return static::create(\array_fill(0, (int) $times, $this->array)); |
|
2766 | 2766 | } |
2767 | 2767 | |
2768 | 2768 | /** |
@@ -2855,7 +2855,7 @@ discard block |
||
2855 | 2855 | public function replaceValues($search, $replacement = '') |
2856 | 2856 | { |
2857 | 2857 | $array = $this->each( |
2858 | - function ($value) use ($search, $replacement) { |
|
2858 | + function($value) use ($search, $replacement) { |
|
2859 | 2859 | return UTF8::str_replace($search, $replacement, $value); |
2860 | 2860 | } |
2861 | 2861 | ); |
@@ -2936,8 +2936,8 @@ discard block |
||
2936 | 2936 | } |
2937 | 2937 | |
2938 | 2938 | // php cast "bool"-index into "int"-index |
2939 | - if ((bool)$index === $index) { |
|
2940 | - $index = (int)$index; |
|
2939 | + if ((bool) $index === $index) { |
|
2940 | + $index = (int) $index; |
|
2941 | 2941 | } |
2942 | 2942 | |
2943 | 2943 | if (\array_key_exists($index, $this->array) === true) { |
@@ -3110,7 +3110,7 @@ discard block |
||
3110 | 3110 | */ |
3111 | 3111 | public function sorter($sorter = null, $direction = SORT_ASC, $strategy = SORT_REGULAR) |
3112 | 3112 | { |
3113 | - $array = (array)$this->array; |
|
3113 | + $array = (array) $this->array; |
|
3114 | 3114 | $direction = $this->getDirection($direction); |
3115 | 3115 | |
3116 | 3116 | // Transform all values into their results. |
@@ -3119,7 +3119,7 @@ discard block |
||
3119 | 3119 | |
3120 | 3120 | $that = $this; |
3121 | 3121 | $results = $arrayy->each( |
3122 | - function ($value) use ($sorter, $that) { |
|
3122 | + function($value) use ($sorter, $that) { |
|
3123 | 3123 | return is_callable($sorter) ? $sorter($value) : $that->get($sorter, null, $value); |
3124 | 3124 | } |
3125 | 3125 | ); |
@@ -3216,8 +3216,8 @@ discard block |
||
3216 | 3216 | if ($arrayCount === 0) { |
3217 | 3217 | $result = array(); |
3218 | 3218 | } else { |
3219 | - $numberOfPieces = (int)$numberOfPieces; |
|
3220 | - $splitSize = (int)ceil($arrayCount / $numberOfPieces); |
|
3219 | + $numberOfPieces = (int) $numberOfPieces; |
|
3220 | + $splitSize = (int) ceil($arrayCount / $numberOfPieces); |
|
3221 | 3221 | $result = \array_chunk($this->array, $splitSize, $keepKeys); |
3222 | 3222 | } |
3223 | 3223 | |
@@ -3232,12 +3232,12 @@ discard block |
||
3232 | 3232 | public function stripEmpty() |
3233 | 3233 | { |
3234 | 3234 | return $this->filter( |
3235 | - function ($item) { |
|
3235 | + function($item) { |
|
3236 | 3236 | if ($item === null) { |
3237 | 3237 | return false; |
3238 | 3238 | } |
3239 | 3239 | |
3240 | - return (bool)trim((string)$item); |
|
3240 | + return (bool) trim((string) $item); |
|
3241 | 3241 | } |
3242 | 3242 | ); |
3243 | 3243 | } |
@@ -3305,7 +3305,7 @@ discard block |
||
3305 | 3305 | |
3306 | 3306 | $this->array = \array_reduce( |
3307 | 3307 | $this->array, |
3308 | - function ($resultArray, $value) { |
|
3308 | + function($resultArray, $value) { |
|
3309 | 3309 | if (!in_array($value, $resultArray, true)) { |
3310 | 3310 | $resultArray[] = $value; |
3311 | 3311 | } |
@@ -3318,7 +3318,7 @@ discard block |
||
3318 | 3318 | if ($this->array === null) { |
3319 | 3319 | $this->array = array(); |
3320 | 3320 | } else { |
3321 | - $this->array = (array)$this->array; |
|
3321 | + $this->array = (array) $this->array; |
|
3322 | 3322 | } |
3323 | 3323 | |
3324 | 3324 | return $this; |
@@ -3338,7 +3338,7 @@ discard block |
||
3338 | 3338 | |
3339 | 3339 | $this->array = \array_reduce( |
3340 | 3340 | \array_keys($array), |
3341 | - function ($resultArray, $key) use ($array) { |
|
3341 | + function($resultArray, $key) use ($array) { |
|
3342 | 3342 | if (!in_array($array[$key], $resultArray, true)) { |
3343 | 3343 | $resultArray[$key] = $array[$key]; |
3344 | 3344 | } |
@@ -3351,7 +3351,7 @@ discard block |
||
3351 | 3351 | if ($this->array === null) { |
3352 | 3352 | $this->array = array(); |
3353 | 3353 | } else { |
3354 | - $this->array = (array)$this->array; |
|
3354 | + $this->array = (array) $this->array; |
|
3355 | 3355 | } |
3356 | 3356 | |
3357 | 3357 | return $this; |
@@ -3391,7 +3391,7 @@ discard block |
||
3391 | 3391 | */ |
3392 | 3392 | public function values() |
3393 | 3393 | { |
3394 | - return static::create(\array_values((array)$this->array)); |
|
3394 | + return static::create(\array_values((array) $this->array)); |
|
3395 | 3395 | } |
3396 | 3396 | |
3397 | 3397 | /** |