Completed
Push — master ( 17fe6b...d39ec0 )
by Lars
03:26
created
src/Arrayy.php 1 patch
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
       return false;
82 82
     }
83 83
 
84
-    return (array)$this->array;
84
+    return (array) $this->array;
85 85
   }
86 86
 
87 87
   /**
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
     }
359 359
 
360 360
     // php cast "bool"-index into "int"-index
361
-    if ((bool)$offset === $offset) {
362
-      $offset = (int)$offset;
361
+    if ((bool) $offset === $offset) {
362
+      $offset = (int) $offset;
363 363
     }
364 364
 
365 365
     $tmpReturn = \array_key_exists($offset, $this->array);
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
         (
371 371
             $tmpReturn === false
372 372
             &&
373
-            \strpos((string)$offset, $this->pathSeparator) === false
373
+            \strpos((string) $offset, $this->pathSeparator) === false
374 374
         )
375 375
     ) {
376 376
       return $tmpReturn;
@@ -378,16 +378,16 @@  discard block
 block discarded – undo
378 378
 
379 379
     $offsetExists = false;
380 380
 
381
-    if (\strpos((string)$offset, $this->pathSeparator) !== false) {
381
+    if (\strpos((string) $offset, $this->pathSeparator) !== false) {
382 382
 
383 383
       $offsetExists = false;
384
-      $explodedPath = \explode($this->pathSeparator, (string)$offset);
384
+      $explodedPath = \explode($this->pathSeparator, (string) $offset);
385 385
       $lastOffset = \array_pop($explodedPath);
386 386
       $containerPath = \implode($this->pathSeparator, $explodedPath);
387 387
 
388 388
       $this->callAtPath(
389 389
           $containerPath,
390
-          function ($container) use ($lastOffset, &$offsetExists) {
390
+          function($container) use ($lastOffset, &$offsetExists) {
391 391
             $offsetExists = \array_key_exists($lastOffset, $container);
392 392
           }
393 393
       );
@@ -440,14 +440,14 @@  discard block
 block discarded – undo
440 440
       return;
441 441
     }
442 442
 
443
-    if (\strpos((string)$offset, $this->pathSeparator) !== false) {
443
+    if (\strpos((string) $offset, $this->pathSeparator) !== false) {
444 444
 
445
-      $path = \explode($this->pathSeparator, (string)$offset);
445
+      $path = \explode($this->pathSeparator, (string) $offset);
446 446
       $pathToUnset = \array_pop($path);
447 447
 
448 448
       $this->callAtPath(
449 449
           \implode($this->pathSeparator, $path),
450
-          function (&$offset) use ($pathToUnset) {
450
+          function(&$offset) use ($pathToUnset) {
451 451
             unset($offset[$pathToUnset]);
452 452
           }
453 453
       );
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
     }
484 484
 
485 485
     if (\strpos($class, '\\') === 0) {
486
-      $class = '\\' . $class;
486
+      $class = '\\'.$class;
487 487
       if (\class_exists($class)) {
488 488
         $this->iteratorClass = $class;
489 489
 
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
       }
492 492
     }
493 493
 
494
-    throw new \InvalidArgumentException('The iterator class does not exist: ' . $class);
494
+    throw new \InvalidArgumentException('The iterator class does not exist: '.$class);
495 495
   }
496 496
 
497 497
   /**
@@ -556,11 +556,11 @@  discard block
 block discarded – undo
556 556
     $result = [];
557 557
     foreach ($this->array as $key => $item) {
558 558
       if ($item instanceof self) {
559
-        $result[$prefix . $key] = $item->appendToEachKey($prefix);
559
+        $result[$prefix.$key] = $item->appendToEachKey($prefix);
560 560
       } elseif (\is_array($item)) {
561
-        $result[$prefix . $key] = self::create($item)->appendToEachKey($prefix)->toArray();
561
+        $result[$prefix.$key] = self::create($item)->appendToEachKey($prefix)->toArray();
562 562
       } else {
563
-        $result[$prefix . $key] = $item;
563
+        $result[$prefix.$key] = $item;
564 564
       }
565 565
     }
566 566
 
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
       } elseif (\is_object($item)) {
586 586
         $result[$key] = $item;
587 587
       } else {
588
-        $result[$key] = $prefix . $item;
588
+        $result[$key] = $prefix.$item;
589 589
       }
590 590
     }
591 591
 
@@ -796,8 +796,8 @@  discard block
 block discarded – undo
796 796
   public function clean()
797 797
   {
798 798
     return $this->filter(
799
-        function ($value) {
800
-          return (bool)$value;
799
+        function($value) {
800
+          return (bool) $value;
801 801
         }
802 802
     );
803 803
   }
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
       return $this->in_array_recursive(
847 847
           UTF8::strtoupper($value),
848 848
           $this->walk(
849
-              function (&$val) {
849
+              function(&$val) {
850 850
                 $val = UTF8::strtoupper($val);
851 851
               },
852 852
               true
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
     return \in_array(
859 859
         UTF8::strtoupper($value),
860 860
         $this->walk(
861
-            function (&$val) {
861
+            function(&$val) {
862 862
               $val = UTF8::strtoupper($val);
863 863
             },
864 864
             false
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
     // trim all string in the array
1081 1081
     \array_walk(
1082 1082
         $array,
1083
-        function (&$val) {
1083
+        function(&$val) {
1084 1084
           /** @noinspection ReferenceMismatchInspection */
1085 1085
           if (\is_string($val)) {
1086 1086
             $val = \trim($val);
@@ -1317,7 +1317,7 @@  discard block
 block discarded – undo
1317 1317
     }
1318 1318
 
1319 1319
     if ($isObject && \method_exists($array, '__toArray')) {
1320
-      return (array)$array->__toArray();
1320
+      return (array) $array->__toArray();
1321 1321
     }
1322 1322
 
1323 1323
     /** @noinspection ReferenceMismatchInspection */
@@ -1326,7 +1326,7 @@  discard block
 block discarded – undo
1326 1326
         ||
1327 1327
         ($isObject && \method_exists($array, '__toString'))
1328 1328
     ) {
1329
-      return [(string)$array];
1329
+      return [(string) $array];
1330 1330
     }
1331 1331
 
1332 1332
     throw new \InvalidArgumentException(
@@ -1428,54 +1428,54 @@  discard block
 block discarded – undo
1428 1428
     }
1429 1429
 
1430 1430
     $ops = [
1431
-        'eq'          => function ($item, $prop, $value) {
1431
+        'eq'          => function($item, $prop, $value) {
1432 1432
           return $item[$prop] === $value;
1433 1433
         },
1434
-        'gt'          => function ($item, $prop, $value) {
1434
+        'gt'          => function($item, $prop, $value) {
1435 1435
           return $item[$prop] > $value;
1436 1436
         },
1437
-        'ge'          => function ($item, $prop, $value) {
1437
+        'ge'          => function($item, $prop, $value) {
1438 1438
           return $item[$prop] >= $value;
1439 1439
         },
1440
-        'gte'         => function ($item, $prop, $value) {
1440
+        'gte'         => function($item, $prop, $value) {
1441 1441
           return $item[$prop] >= $value;
1442 1442
         },
1443
-        'lt'          => function ($item, $prop, $value) {
1443
+        'lt'          => function($item, $prop, $value) {
1444 1444
           return $item[$prop] < $value;
1445 1445
         },
1446
-        'le'          => function ($item, $prop, $value) {
1446
+        'le'          => function($item, $prop, $value) {
1447 1447
           return $item[$prop] <= $value;
1448 1448
         },
1449
-        'lte'         => function ($item, $prop, $value) {
1449
+        'lte'         => function($item, $prop, $value) {
1450 1450
           return $item[$prop] <= $value;
1451 1451
         },
1452
-        'ne'          => function ($item, $prop, $value) {
1452
+        'ne'          => function($item, $prop, $value) {
1453 1453
           return $item[$prop] !== $value;
1454 1454
         },
1455
-        'contains'    => function ($item, $prop, $value) {
1456
-          return \in_array($item[$prop], (array)$value, true);
1455
+        'contains'    => function($item, $prop, $value) {
1456
+          return \in_array($item[$prop], (array) $value, true);
1457 1457
         },
1458
-        'notContains' => function ($item, $prop, $value) {
1459
-          return !\in_array($item[$prop], (array)$value, true);
1458
+        'notContains' => function($item, $prop, $value) {
1459
+          return !\in_array($item[$prop], (array) $value, true);
1460 1460
         },
1461
-        'newer'       => function ($item, $prop, $value) {
1461
+        'newer'       => function($item, $prop, $value) {
1462 1462
           return \strtotime($item[$prop]) > \strtotime($value);
1463 1463
         },
1464
-        'older'       => function ($item, $prop, $value) {
1464
+        'older'       => function($item, $prop, $value) {
1465 1465
           return \strtotime($item[$prop]) < \strtotime($value);
1466 1466
         },
1467 1467
     ];
1468 1468
 
1469 1469
     $result = \array_values(
1470 1470
         \array_filter(
1471
-            (array)$this->array,
1472
-            function ($item) use (
1471
+            (array) $this->array,
1472
+            function($item) use (
1473 1473
                 $property,
1474 1474
                 $value,
1475 1475
                 $ops,
1476 1476
                 $comparisonOp
1477 1477
             ) {
1478
-              $item = (array)$item;
1478
+              $item = (array) $item;
1479 1479
               $itemArrayy = new Arrayy($item);
1480 1480
               $item[$property] = $itemArrayy->get($property, []);
1481 1481
 
@@ -1548,9 +1548,9 @@  discard block
 block discarded – undo
1548 1548
   {
1549 1549
     if ($number === null) {
1550 1550
       $arrayTmp = $this->array;
1551
-      $array = (array)\array_shift($arrayTmp);
1551
+      $array = (array) \array_shift($arrayTmp);
1552 1552
     } else {
1553
-      $number = (int)$number;
1553
+      $number = (int) $number;
1554 1554
       $arrayTmp = $this->array;
1555 1555
       $array = \array_splice($arrayTmp, 0, $number, true);
1556 1556
     }
@@ -1568,9 +1568,9 @@  discard block
 block discarded – undo
1568 1568
   public function firstsMutable(int $number = null)
1569 1569
   {
1570 1570
     if ($number === null) {
1571
-      $this->array = (array)\array_shift($this->array);
1571
+      $this->array = (array) \array_shift($this->array);
1572 1572
     } else {
1573
-      $number = (int)$number;
1573
+      $number = (int) $number;
1574 1574
       $this->array = \array_splice($this->array, 0, $number, true);
1575 1575
     }
1576 1576
 
@@ -1612,8 +1612,8 @@  discard block
 block discarded – undo
1612 1612
     }
1613 1613
 
1614 1614
     // php cast "bool"-index into "int"-index
1615
-    if ((bool)$key === $key) {
1616
-      $key = (int)$key;
1615
+    if ((bool) $key === $key) {
1616
+      $key = (int) $key;
1617 1617
     }
1618 1618
 
1619 1619
     if (\array_key_exists($key, $usedArray) === true) {
@@ -1625,7 +1625,7 @@  discard block
 block discarded – undo
1625 1625
     }
1626 1626
 
1627 1627
     // Crawl through array, get key according to object or not
1628
-    foreach (\explode($this->pathSeparator, (string)$key) as $segment) {
1628
+    foreach (\explode($this->pathSeparator, (string) $key) as $segment) {
1629 1629
       if (!isset($usedArray[$segment])) {
1630 1630
         return $fallback instanceof \Closure ? $fallback() : $fallback;
1631 1631
       }
@@ -1803,7 +1803,7 @@  discard block
 block discarded – undo
1803 1803
    */
1804 1804
   public function group($grouper, bool $saveKeys = false)
1805 1805
   {
1806
-    $array = (array)$this->array;
1806
+    $array = (array) $this->array;
1807 1807
     $result = [];
1808 1808
 
1809 1809
     // Iterate over values, group by property/results from closure.
@@ -1906,7 +1906,7 @@  discard block
 block discarded – undo
1906 1906
       );
1907 1907
     }
1908 1908
 
1909
-    return (string)$pieces;
1909
+    return (string) $pieces;
1910 1910
   }
1911 1911
 
1912 1912
   /**
@@ -2029,7 +2029,7 @@  discard block
 block discarded – undo
2029 2029
    */
2030 2030
   protected function internalRemove($key): bool
2031 2031
   {
2032
-    $path = \explode($this->pathSeparator, (string)$key);
2032
+    $path = \explode($this->pathSeparator, (string) $key);
2033 2033
 
2034 2034
     // Crawl though the keys
2035 2035
     while (\count($path, COUNT_NORMAL) > 1) {
@@ -2064,14 +2064,14 @@  discard block
 block discarded – undo
2064 2064
     }
2065 2065
 
2066 2066
     // init
2067
-    $array =& $this->array;
2068
-    $path = \explode($this->pathSeparator, (string)$key);
2067
+    $array = & $this->array;
2068
+    $path = \explode($this->pathSeparator, (string) $key);
2069 2069
 
2070 2070
     // Crawl through the keys
2071 2071
     while (\count($path, COUNT_NORMAL) > 1) {
2072 2072
       $key = \array_shift($path);
2073 2073
 
2074
-      $array =& $array[$key];
2074
+      $array = & $array[$key];
2075 2075
     }
2076 2076
 
2077 2077
     $array[\array_shift($path)] = $value;
@@ -2330,12 +2330,12 @@  discard block
 block discarded – undo
2330 2330
       if ($poppedValue === null) {
2331 2331
         $poppedValue = [$poppedValue];
2332 2332
       } else {
2333
-        $poppedValue = (array)$poppedValue;
2333
+        $poppedValue = (array) $poppedValue;
2334 2334
       }
2335 2335
 
2336 2336
       $arrayy = static::create($poppedValue);
2337 2337
     } else {
2338
-      $number = (int)$number;
2338
+      $number = (int) $number;
2339 2339
       $arrayy = $this->rest(-$number);
2340 2340
     }
2341 2341
 
@@ -2361,12 +2361,12 @@  discard block
 block discarded – undo
2361 2361
       if ($poppedValue === null) {
2362 2362
         $poppedValue = [$poppedValue];
2363 2363
       } else {
2364
-        $poppedValue = (array)$poppedValue;
2364
+        $poppedValue = (array) $poppedValue;
2365 2365
       }
2366 2366
 
2367 2367
       $this->array = static::create($poppedValue)->array;
2368 2368
     } else {
2369
-      $number = (int)$number;
2369
+      $number = (int) $number;
2370 2370
       $this->array = $this->rest(-$number)->array;
2371 2371
     }
2372 2372
 
@@ -2705,7 +2705,7 @@  discard block
 block discarded – undo
2705 2705
       } elseif (\is_array($item)) {
2706 2706
         $result[$key] = self::create($item)->prependToEachKey($suffix)->toArray();
2707 2707
       } else {
2708
-        $result[$key . $suffix] = $item;
2708
+        $result[$key.$suffix] = $item;
2709 2709
       }
2710 2710
 
2711 2711
     }
@@ -2731,7 +2731,7 @@  discard block
 block discarded – undo
2731 2731
       } elseif (\is_object($item)) {
2732 2732
         $result[$key] = $item;
2733 2733
       } else {
2734
-        $result[$key] = $item . $suffix;
2734
+        $result[$key] = $item.$suffix;
2735 2735
       }
2736 2736
     }
2737 2737
 
@@ -2821,7 +2821,7 @@  discard block
 block discarded – undo
2821 2821
       );
2822 2822
     }
2823 2823
 
2824
-    $result = (array)\array_rand($this->array, $number);
2824
+    $result = (array) \array_rand($this->array, $number);
2825 2825
 
2826 2826
     return static::create($result);
2827 2827
   }
@@ -2920,7 +2920,7 @@  discard block
 block discarded – undo
2920 2920
     if ($result === null) {
2921 2921
       $this->array = [];
2922 2922
     } else {
2923
-      $this->array = (array)$result;
2923
+      $this->array = (array) $result;
2924 2924
     }
2925 2925
 
2926 2926
     return static::create($this->array);
@@ -3046,7 +3046,7 @@  discard block
 block discarded – undo
3046 3046
       return new static();
3047 3047
     }
3048 3048
 
3049
-    return static::create(\array_fill(0, (int)$times, $this->array));
3049
+    return static::create(\array_fill(0, (int) $times, $this->array));
3050 3050
   }
3051 3051
 
3052 3052
   /**
@@ -3139,7 +3139,7 @@  discard block
 block discarded – undo
3139 3139
   public function replaceValues($search, $replacement = '')
3140 3140
   {
3141 3141
     $array = $this->each(
3142
-        function ($value) use ($search, $replacement) {
3142
+        function($value) use ($search, $replacement) {
3143 3143
           return UTF8::str_replace($search, $replacement, $value);
3144 3144
         }
3145 3145
     );
@@ -3220,8 +3220,8 @@  discard block
 block discarded – undo
3220 3220
     }
3221 3221
 
3222 3222
     // php cast "bool"-index into "int"-index
3223
-    if ((bool)$index === $index) {
3224
-      $index = (int)$index;
3223
+    if ((bool) $index === $index) {
3224
+      $index = (int) $index;
3225 3225
     }
3226 3226
 
3227 3227
     if (\array_key_exists($index, $this->array) === true) {
@@ -3463,7 +3463,7 @@  discard block
 block discarded – undo
3463 3463
    */
3464 3464
   public function sorter($sorter = null, $direction = SORT_ASC, int $strategy = SORT_REGULAR)
3465 3465
   {
3466
-    $array = (array)$this->array;
3466
+    $array = (array) $this->array;
3467 3467
     $direction = $this->getDirection($direction);
3468 3468
 
3469 3469
     // Transform all values into their results.
@@ -3472,7 +3472,7 @@  discard block
 block discarded – undo
3472 3472
 
3473 3473
       $that = $this;
3474 3474
       $results = $arrayy->each(
3475
-          function ($value) use ($sorter, $that) {
3475
+          function($value) use ($sorter, $that) {
3476 3476
             return \is_callable($sorter) ? $sorter($value) : $that->get($sorter, null, $value);
3477 3477
           }
3478 3478
       );
@@ -3570,7 +3570,7 @@  discard block
 block discarded – undo
3570 3570
     if ($arrayCount === 0) {
3571 3571
       $result = [];
3572 3572
     } else {
3573
-      $splitSize = (int)\ceil($arrayCount / $numberOfPieces);
3573
+      $splitSize = (int) \ceil($arrayCount / $numberOfPieces);
3574 3574
       $result = \array_chunk($this->array, $splitSize, $keepKeys);
3575 3575
     }
3576 3576
 
@@ -3585,12 +3585,12 @@  discard block
 block discarded – undo
3585 3585
   public function stripEmpty()
3586 3586
   {
3587 3587
     return $this->filter(
3588
-        function ($item) {
3588
+        function($item) {
3589 3589
           if ($item === null) {
3590 3590
             return false;
3591 3591
           }
3592 3592
 
3593
-          return (bool)\trim((string)$item);
3593
+          return (bool) \trim((string) $item);
3594 3594
         }
3595 3595
     );
3596 3596
   }
@@ -3658,7 +3658,7 @@  discard block
 block discarded – undo
3658 3658
 
3659 3659
     $this->array = \array_reduce(
3660 3660
         $this->array,
3661
-        function ($resultArray, $value) {
3661
+        function($resultArray, $value) {
3662 3662
           if (!\in_array($value, $resultArray, true)) {
3663 3663
             $resultArray[] = $value;
3664 3664
           }
@@ -3671,7 +3671,7 @@  discard block
 block discarded – undo
3671 3671
     if ($this->array === null) {
3672 3672
       $this->array = [];
3673 3673
     } else {
3674
-      $this->array = (array)$this->array;
3674
+      $this->array = (array) $this->array;
3675 3675
     }
3676 3676
 
3677 3677
     return $this;
@@ -3691,7 +3691,7 @@  discard block
 block discarded – undo
3691 3691
 
3692 3692
     $this->array = \array_reduce(
3693 3693
         \array_keys($array),
3694
-        function ($resultArray, $key) use ($array) {
3694
+        function($resultArray, $key) use ($array) {
3695 3695
           if (!\in_array($array[$key], $resultArray, true)) {
3696 3696
             $resultArray[$key] = $array[$key];
3697 3697
           }
@@ -3704,7 +3704,7 @@  discard block
 block discarded – undo
3704 3704
     if ($this->array === null) {
3705 3705
       $this->array = [];
3706 3706
     } else {
3707
-      $this->array = (array)$this->array;
3707
+      $this->array = (array) $this->array;
3708 3708
     }
3709 3709
 
3710 3710
     return $this;
@@ -3744,7 +3744,7 @@  discard block
 block discarded – undo
3744 3744
    */
3745 3745
   public function values()
3746 3746
   {
3747
-    return static::create(\array_values((array)$this->array));
3747
+    return static::create(\array_values((array) $this->array));
3748 3748
   }
3749 3749
 
3750 3750
   /**
Please login to merge, or discard this patch.