Completed
Push — master ( fa4b94...514782 )
by Lars
01:47
created
src/Arrayy.php 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         &&
73 73
         \count(\array_diff_key($this->properties, $array)) > 0
74 74
     ) {
75
-      throw new \InvalidArgumentException('Property mismatch - input: ' . print_r(array_keys($array), true) . ' | expected: ' . print_r(array_keys($this->properties), true));
75
+      throw new \InvalidArgumentException('Property mismatch - input: '.print_r(array_keys($array), true).' | expected: '.print_r(array_keys($this->properties), true));
76 76
     }
77 77
 
78 78
     foreach ($array as $key => $value) {
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
       return false;
118 118
     }
119 119
 
120
-    return (array)$this->array;
120
+    return (array) $this->array;
121 121
   }
122 122
 
123 123
   /**
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
     }
362 362
 
363 363
     // php cast "bool"-index into "int"-index
364
-    if ((bool)$offset === $offset) {
365
-      $offset = (int)$offset;
364
+    if ((bool) $offset === $offset) {
365
+      $offset = (int) $offset;
366 366
     }
367 367
 
368 368
     $tmpReturn = \array_key_exists($offset, $this->array);
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
         (
374 374
             $tmpReturn === false
375 375
             &&
376
-            \strpos((string)$offset, $this->pathSeparator) === false
376
+            \strpos((string) $offset, $this->pathSeparator) === false
377 377
         )
378 378
     ) {
379 379
       return $tmpReturn;
@@ -381,16 +381,16 @@  discard block
 block discarded – undo
381 381
 
382 382
     $offsetExists = false;
383 383
 
384
-    if (\strpos((string)$offset, $this->pathSeparator) !== false) {
384
+    if (\strpos((string) $offset, $this->pathSeparator) !== false) {
385 385
 
386 386
       $offsetExists = false;
387
-      $explodedPath = \explode($this->pathSeparator, (string)$offset);
387
+      $explodedPath = \explode($this->pathSeparator, (string) $offset);
388 388
       $lastOffset = \array_pop($explodedPath);
389 389
       $containerPath = \implode($this->pathSeparator, $explodedPath);
390 390
 
391 391
       $this->callAtPath(
392 392
           $containerPath,
393
-          function ($container) use ($lastOffset, &$offsetExists) {
393
+          function($container) use ($lastOffset, &$offsetExists) {
394 394
             $offsetExists = \array_key_exists($lastOffset, $container);
395 395
           }
396 396
       );
@@ -443,14 +443,14 @@  discard block
 block discarded – undo
443 443
       return;
444 444
     }
445 445
 
446
-    if (\strpos((string)$offset, $this->pathSeparator) !== false) {
446
+    if (\strpos((string) $offset, $this->pathSeparator) !== false) {
447 447
 
448
-      $path = \explode($this->pathSeparator, (string)$offset);
448
+      $path = \explode($this->pathSeparator, (string) $offset);
449 449
       $pathToUnset = \array_pop($path);
450 450
 
451 451
       $this->callAtPath(
452 452
           \implode($this->pathSeparator, $path),
453
-          function (&$offset) use ($pathToUnset) {
453
+          function(&$offset) use ($pathToUnset) {
454 454
             unset($offset[$pathToUnset]);
455 455
           }
456 456
       );
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
     }
488 488
 
489 489
     if (\strpos($class, '\\') === 0) {
490
-      $class = '\\' . $class;
490
+      $class = '\\'.$class;
491 491
       if (\class_exists($class)) {
492 492
         $this->iteratorClass = $class;
493 493
 
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
       }
496 496
     }
497 497
 
498
-    throw new \InvalidArgumentException('The iterator class does not exist: ' . $class);
498
+    throw new \InvalidArgumentException('The iterator class does not exist: '.$class);
499 499
   }
500 500
 
501 501
   /**
@@ -595,11 +595,11 @@  discard block
 block discarded – undo
595 595
 
596 596
     foreach ($this->getGenerator() as $key => $item) {
597 597
       if ($item instanceof self) {
598
-        $result[$prefix . $key] = $item->appendToEachKey($prefix);
598
+        $result[$prefix.$key] = $item->appendToEachKey($prefix);
599 599
       } elseif (\is_array($item)) {
600
-        $result[$prefix . $key] = self::create($item)->appendToEachKey($prefix)->toArray();
600
+        $result[$prefix.$key] = self::create($item)->appendToEachKey($prefix)->toArray();
601 601
       } else {
602
-        $result[$prefix . $key] = $item;
602
+        $result[$prefix.$key] = $item;
603 603
       }
604 604
     }
605 605
 
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
       } elseif (\is_object($item)) {
627 627
         $result[$key] = $item;
628 628
       } else {
629
-        $result[$key] = $prefix . $item;
629
+        $result[$key] = $prefix.$item;
630 630
       }
631 631
     }
632 632
 
@@ -841,8 +841,8 @@  discard block
 block discarded – undo
841 841
   public function clean()
842 842
   {
843 843
     return $this->filter(
844
-        function ($value) {
845
-          return (bool)$value;
844
+        function($value) {
845
+          return (bool) $value;
846 846
         }
847 847
     );
848 848
   }
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
       return $this->in_array_recursive(
892 892
           UTF8::strtoupper($value),
893 893
           $this->walk(
894
-              function (&$val) {
894
+              function(&$val) {
895 895
                 $val = UTF8::strtoupper($val);
896 896
               },
897 897
               true
@@ -903,7 +903,7 @@  discard block
 block discarded – undo
903 903
     return \in_array(
904 904
         UTF8::strtoupper($value),
905 905
         $this->walk(
906
-            function (&$val) {
906
+            function(&$val) {
907 907
               $val = UTF8::strtoupper($val);
908 908
             },
909 909
             false
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
     // trim all string in the array
1152 1152
     \array_walk(
1153 1153
         $array,
1154
-        function (&$val) {
1154
+        function(&$val) {
1155 1155
           /** @noinspection ReferenceMismatchInspection */
1156 1156
           if (\is_string($val)) {
1157 1157
             $val = \trim($val);
@@ -1392,7 +1392,7 @@  discard block
 block discarded – undo
1392 1392
     }
1393 1393
 
1394 1394
     if ($isObject && \method_exists($array, '__toArray')) {
1395
-      return (array)$array->__toArray();
1395
+      return (array) $array->__toArray();
1396 1396
     }
1397 1397
 
1398 1398
     /** @noinspection ReferenceMismatchInspection */
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
         ||
1402 1402
         ($isObject && \method_exists($array, '__toString'))
1403 1403
     ) {
1404
-      return [(string)$array];
1404
+      return [(string) $array];
1405 1405
     }
1406 1406
 
1407 1407
     throw new \InvalidArgumentException(
@@ -1503,54 +1503,54 @@  discard block
 block discarded – undo
1503 1503
     }
1504 1504
 
1505 1505
     $ops = [
1506
-        'eq'          => function ($item, $prop, $value) {
1506
+        'eq'          => function($item, $prop, $value) {
1507 1507
           return $item[$prop] === $value;
1508 1508
         },
1509
-        'gt'          => function ($item, $prop, $value) {
1509
+        'gt'          => function($item, $prop, $value) {
1510 1510
           return $item[$prop] > $value;
1511 1511
         },
1512
-        'ge'          => function ($item, $prop, $value) {
1512
+        'ge'          => function($item, $prop, $value) {
1513 1513
           return $item[$prop] >= $value;
1514 1514
         },
1515
-        'gte'         => function ($item, $prop, $value) {
1515
+        'gte'         => function($item, $prop, $value) {
1516 1516
           return $item[$prop] >= $value;
1517 1517
         },
1518
-        'lt'          => function ($item, $prop, $value) {
1518
+        'lt'          => function($item, $prop, $value) {
1519 1519
           return $item[$prop] < $value;
1520 1520
         },
1521
-        'le'          => function ($item, $prop, $value) {
1521
+        'le'          => function($item, $prop, $value) {
1522 1522
           return $item[$prop] <= $value;
1523 1523
         },
1524
-        'lte'         => function ($item, $prop, $value) {
1524
+        'lte'         => function($item, $prop, $value) {
1525 1525
           return $item[$prop] <= $value;
1526 1526
         },
1527
-        'ne'          => function ($item, $prop, $value) {
1527
+        'ne'          => function($item, $prop, $value) {
1528 1528
           return $item[$prop] !== $value;
1529 1529
         },
1530
-        'contains'    => function ($item, $prop, $value) {
1531
-          return \in_array($item[$prop], (array)$value, true);
1530
+        'contains'    => function($item, $prop, $value) {
1531
+          return \in_array($item[$prop], (array) $value, true);
1532 1532
         },
1533
-        'notContains' => function ($item, $prop, $value) {
1534
-          return !\in_array($item[$prop], (array)$value, true);
1533
+        'notContains' => function($item, $prop, $value) {
1534
+          return !\in_array($item[$prop], (array) $value, true);
1535 1535
         },
1536
-        'newer'       => function ($item, $prop, $value) {
1536
+        'newer'       => function($item, $prop, $value) {
1537 1537
           return \strtotime($item[$prop]) > \strtotime($value);
1538 1538
         },
1539
-        'older'       => function ($item, $prop, $value) {
1539
+        'older'       => function($item, $prop, $value) {
1540 1540
           return \strtotime($item[$prop]) < \strtotime($value);
1541 1541
         },
1542 1542
     ];
1543 1543
 
1544 1544
     $result = \array_values(
1545 1545
         \array_filter(
1546
-            (array)$this->array,
1547
-            function ($item) use (
1546
+            (array) $this->array,
1547
+            function($item) use (
1548 1548
                 $property,
1549 1549
                 $value,
1550 1550
                 $ops,
1551 1551
                 $comparisonOp
1552 1552
             ) {
1553
-              $item = (array)$item;
1553
+              $item = (array) $item;
1554 1554
               $itemArrayy = new Arrayy($item);
1555 1555
               $item[$property] = $itemArrayy->get($property, []);
1556 1556
 
@@ -1619,9 +1619,9 @@  discard block
 block discarded – undo
1619 1619
   {
1620 1620
     if ($number === null) {
1621 1621
       $arrayTmp = $this->array;
1622
-      $array = (array)\array_shift($arrayTmp);
1622
+      $array = (array) \array_shift($arrayTmp);
1623 1623
     } else {
1624
-      $number = (int)$number;
1624
+      $number = (int) $number;
1625 1625
       $arrayTmp = $this->array;
1626 1626
       $array = \array_splice($arrayTmp, 0, $number, true);
1627 1627
     }
@@ -1639,9 +1639,9 @@  discard block
 block discarded – undo
1639 1639
   public function firstsMutable(int $number = null)
1640 1640
   {
1641 1641
     if ($number === null) {
1642
-      $this->array = (array)\array_shift($this->array);
1642
+      $this->array = (array) \array_shift($this->array);
1643 1643
     } else {
1644
-      $number = (int)$number;
1644
+      $number = (int) $number;
1645 1645
       $this->array = \array_splice($this->array, 0, $number, true);
1646 1646
     }
1647 1647
 
@@ -1683,8 +1683,8 @@  discard block
 block discarded – undo
1683 1683
     }
1684 1684
 
1685 1685
     // php cast "bool"-index into "int"-index
1686
-    if ((bool)$key === $key) {
1687
-      $key = (int)$key;
1686
+    if ((bool) $key === $key) {
1687
+      $key = (int) $key;
1688 1688
     }
1689 1689
 
1690 1690
     if (\array_key_exists($key, $usedArray) === true) {
@@ -1696,7 +1696,7 @@  discard block
 block discarded – undo
1696 1696
     }
1697 1697
 
1698 1698
     // Crawl through array, get key according to object or not
1699
-    foreach (\explode($this->pathSeparator, (string)$key) as $segment) {
1699
+    foreach (\explode($this->pathSeparator, (string) $key) as $segment) {
1700 1700
       if (!isset($usedArray[$segment])) {
1701 1701
         return $fallback instanceof \Closure ? $fallback() : $fallback;
1702 1702
       }
@@ -1808,7 +1808,7 @@  discard block
 block discarded – undo
1808 1808
   protected function getPublicProperties(): array
1809 1809
   {
1810 1810
     static $PROPERTY_CACHE = [];
1811
-    $cacheKey = 'Class::' . static::class;
1811
+    $cacheKey = 'Class::'.static::class;
1812 1812
 
1813 1813
     if (isset($PROPERTY_CACHE[$cacheKey])) {
1814 1814
       return $PROPERTY_CACHE[$cacheKey];
@@ -2005,7 +2005,7 @@  discard block
 block discarded – undo
2005 2005
       );
2006 2006
     }
2007 2007
 
2008
-    return (string)$pieces;
2008
+    return (string) $pieces;
2009 2009
   }
2010 2010
 
2011 2011
   /**
@@ -2135,7 +2135,7 @@  discard block
 block discarded – undo
2135 2135
    */
2136 2136
   protected function internalRemove($key): bool
2137 2137
   {
2138
-    $path = \explode($this->pathSeparator, (string)$key);
2138
+    $path = \explode($this->pathSeparator, (string) $key);
2139 2139
 
2140 2140
     // Crawl though the keys
2141 2141
     while (\count($path, COUNT_NORMAL) > 1) {
@@ -2167,7 +2167,7 @@  discard block
 block discarded – undo
2167 2167
   {
2168 2168
     if ($this->checkPropertyTypes === true) {
2169 2169
       if (isset($this->properties[$key]) === false) {
2170
-        throw new \InvalidArgumentException('The key ' . $key . ' does not exists as @property in the class (' . \get_class($this) . ').');
2170
+        throw new \InvalidArgumentException('The key '.$key.' does not exists as @property in the class ('.\get_class($this).').');
2171 2171
       }
2172 2172
 
2173 2173
       $this->properties[$key]->checkType($value);
@@ -2178,14 +2178,14 @@  discard block
 block discarded – undo
2178 2178
     }
2179 2179
 
2180 2180
     // init
2181
-    $array =& $this->array;
2182
-    $path = \explode($this->pathSeparator, (string)$key);
2181
+    $array = & $this->array;
2182
+    $path = \explode($this->pathSeparator, (string) $key);
2183 2183
 
2184 2184
     // Crawl through the keys
2185 2185
     while (\count($path, COUNT_NORMAL) > 1) {
2186 2186
       $key = \array_shift($path);
2187 2187
 
2188
-      $array =& $array[$key];
2188
+      $array = & $array[$key];
2189 2189
     }
2190 2190
 
2191 2191
     $array[\array_shift($path)] = $value;
@@ -2444,12 +2444,12 @@  discard block
 block discarded – undo
2444 2444
       if ($poppedValue === null) {
2445 2445
         $poppedValue = [$poppedValue];
2446 2446
       } else {
2447
-        $poppedValue = (array)$poppedValue;
2447
+        $poppedValue = (array) $poppedValue;
2448 2448
       }
2449 2449
 
2450 2450
       $arrayy = static::create($poppedValue);
2451 2451
     } else {
2452
-      $number = (int)$number;
2452
+      $number = (int) $number;
2453 2453
       $arrayy = $this->rest(-$number);
2454 2454
     }
2455 2455
 
@@ -2475,12 +2475,12 @@  discard block
 block discarded – undo
2475 2475
       if ($poppedValue === null) {
2476 2476
         $poppedValue = [$poppedValue];
2477 2477
       } else {
2478
-        $poppedValue = (array)$poppedValue;
2478
+        $poppedValue = (array) $poppedValue;
2479 2479
       }
2480 2480
 
2481 2481
       $this->array = static::create($poppedValue)->array;
2482 2482
     } else {
2483
-      $number = (int)$number;
2483
+      $number = (int) $number;
2484 2484
       $this->array = $this->rest(-$number)->array;
2485 2485
     }
2486 2486
 
@@ -2823,7 +2823,7 @@  discard block
 block discarded – undo
2823 2823
       } elseif (\is_array($item)) {
2824 2824
         $result[$key] = self::create($item)->prependToEachKey($suffix)->toArray();
2825 2825
       } else {
2826
-        $result[$key . $suffix] = $item;
2826
+        $result[$key.$suffix] = $item;
2827 2827
       }
2828 2828
 
2829 2829
     }
@@ -2851,7 +2851,7 @@  discard block
 block discarded – undo
2851 2851
       } elseif (\is_object($item)) {
2852 2852
         $result[$key] = $item;
2853 2853
       } else {
2854
-        $result[$key] = $item . $suffix;
2854
+        $result[$key] = $item.$suffix;
2855 2855
       }
2856 2856
     }
2857 2857
 
@@ -2941,7 +2941,7 @@  discard block
 block discarded – undo
2941 2941
       );
2942 2942
     }
2943 2943
 
2944
-    $result = (array)\array_rand($this->array, $number);
2944
+    $result = (array) \array_rand($this->array, $number);
2945 2945
 
2946 2946
     return static::create($result);
2947 2947
   }
@@ -3042,7 +3042,7 @@  discard block
 block discarded – undo
3042 3042
     if ($result === null) {
3043 3043
       $this->array = [];
3044 3044
     } else {
3045
-      $this->array = (array)$result;
3045
+      $this->array = (array) $result;
3046 3046
     }
3047 3047
 
3048 3048
     return static::create($this->array);
@@ -3168,7 +3168,7 @@  discard block
 block discarded – undo
3168 3168
       return new static();
3169 3169
     }
3170 3170
 
3171
-    return static::create(\array_fill(0, (int)$times, $this->array));
3171
+    return static::create(\array_fill(0, (int) $times, $this->array));
3172 3172
   }
3173 3173
 
3174 3174
   /**
@@ -3261,7 +3261,7 @@  discard block
 block discarded – undo
3261 3261
   public function replaceValues($search, $replacement = '')
3262 3262
   {
3263 3263
     $array = $this->each(
3264
-        function ($value) use ($search, $replacement) {
3264
+        function($value) use ($search, $replacement) {
3265 3265
           return UTF8::str_replace($search, $replacement, $value);
3266 3266
         }
3267 3267
     );
@@ -3342,8 +3342,8 @@  discard block
 block discarded – undo
3342 3342
     }
3343 3343
 
3344 3344
     // php cast "bool"-index into "int"-index
3345
-    if ((bool)$index === $index) {
3346
-      $index = (int)$index;
3345
+    if ((bool) $index === $index) {
3346
+      $index = (int) $index;
3347 3347
     }
3348 3348
 
3349 3349
     if (\array_key_exists($index, $this->array) === true) {
@@ -3584,7 +3584,7 @@  discard block
 block discarded – undo
3584 3584
    */
3585 3585
   public function sorter($sorter = null, $direction = SORT_ASC, int $strategy = SORT_REGULAR)
3586 3586
   {
3587
-    $array = (array)$this->array;
3587
+    $array = (array) $this->array;
3588 3588
     $direction = $this->getDirection($direction);
3589 3589
 
3590 3590
     // Transform all values into their results.
@@ -3593,7 +3593,7 @@  discard block
 block discarded – undo
3593 3593
 
3594 3594
       $that = $this;
3595 3595
       $results = $arrayy->each(
3596
-          function ($value) use ($sorter, $that) {
3596
+          function($value) use ($sorter, $that) {
3597 3597
             return \is_callable($sorter) ? $sorter($value) : $that->get($sorter, null, $value);
3598 3598
           }
3599 3599
       );
@@ -3691,7 +3691,7 @@  discard block
 block discarded – undo
3691 3691
     if ($arrayCount === 0) {
3692 3692
       $result = [];
3693 3693
     } else {
3694
-      $splitSize = (int)\ceil($arrayCount / $numberOfPieces);
3694
+      $splitSize = (int) \ceil($arrayCount / $numberOfPieces);
3695 3695
       $result = \array_chunk($this->array, $splitSize, $keepKeys);
3696 3696
     }
3697 3697
 
@@ -3706,12 +3706,12 @@  discard block
 block discarded – undo
3706 3706
   public function stripEmpty()
3707 3707
   {
3708 3708
     return $this->filter(
3709
-        function ($item) {
3709
+        function($item) {
3710 3710
           if ($item === null) {
3711 3711
             return false;
3712 3712
           }
3713 3713
 
3714
-          return (bool)\trim((string)$item);
3714
+          return (bool) \trim((string) $item);
3715 3715
         }
3716 3716
     );
3717 3717
   }
@@ -3779,7 +3779,7 @@  discard block
 block discarded – undo
3779 3779
 
3780 3780
     $this->array = \array_reduce(
3781 3781
         $this->array,
3782
-        function ($resultArray, $value) {
3782
+        function($resultArray, $value) {
3783 3783
           if (!\in_array($value, $resultArray, true)) {
3784 3784
             $resultArray[] = $value;
3785 3785
           }
@@ -3792,7 +3792,7 @@  discard block
 block discarded – undo
3792 3792
     if ($this->array === null) {
3793 3793
       $this->array = [];
3794 3794
     } else {
3795
-      $this->array = (array)$this->array;
3795
+      $this->array = (array) $this->array;
3796 3796
     }
3797 3797
 
3798 3798
     return $this;
@@ -3812,7 +3812,7 @@  discard block
 block discarded – undo
3812 3812
 
3813 3813
     $this->array = \array_reduce(
3814 3814
         \array_keys($array),
3815
-        function ($resultArray, $key) use ($array) {
3815
+        function($resultArray, $key) use ($array) {
3816 3816
           if (!\in_array($array[$key], $resultArray, true)) {
3817 3817
             $resultArray[$key] = $array[$key];
3818 3818
           }
@@ -3825,7 +3825,7 @@  discard block
 block discarded – undo
3825 3825
     if ($this->array === null) {
3826 3826
       $this->array = [];
3827 3827
     } else {
3828
-      $this->array = (array)$this->array;
3828
+      $this->array = (array) $this->array;
3829 3829
     }
3830 3830
 
3831 3831
     return $this;
@@ -3865,7 +3865,7 @@  discard block
 block discarded – undo
3865 3865
    */
3866 3866
   public function values()
3867 3867
   {
3868
-    return static::create(\array_values((array)$this->array));
3868
+    return static::create(\array_values((array) $this->array));
3869 3869
   }
3870 3870
 
3871 3871
   /**
Please login to merge, or discard this patch.