Completed
Push — master ( 65eab4...bca288 )
by Lars
03:53
created
src/Arrayy.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
       }
61 61
     }
62 62
 
63
-    return (array)$this->array;
63
+    return (array) $this->array;
64 64
   }
65 65
 
66 66
   /**
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
   public function clean()
293 293
   {
294 294
     return $this->filter(
295
-        function ($value) {
296
-          return (bool)$value;
295
+        function($value) {
296
+          return (bool) $value;
297 297
         }
298 298
     );
299 299
   }
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
     // trim all string in the array
434 434
     array_walk(
435 435
         $array,
436
-        function (&$val) {
436
+        function(&$val) {
437 437
           if (is_string($val)) {
438 438
             $val = trim($val);
439 439
           }
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
     }
578 578
 
579 579
     if (is_object($array) && method_exists($array, '__toArray')) {
580
-      return (array)$array->__toArray();
580
+      return (array) $array->__toArray();
581 581
     }
582 582
 
583 583
     if (
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
         ||
586 586
         (is_object($array) && method_exists($array, '__toString'))
587 587
     ) {
588
-      return (array)$array;
588
+      return (array) $array;
589 589
     }
590 590
 
591 591
     throw new \InvalidArgumentException(
@@ -638,54 +638,54 @@  discard block
 block discarded – undo
638 638
     }
639 639
 
640 640
     $ops = array(
641
-        'eq'          => function ($item, $prop, $value) {
641
+        'eq'          => function($item, $prop, $value) {
642 642
           return $item[$prop] === $value;
643 643
         },
644
-        'gt'          => function ($item, $prop, $value) {
644
+        'gt'          => function($item, $prop, $value) {
645 645
           return $item[$prop] > $value;
646 646
         },
647
-        'ge'         => function ($item, $prop, $value) {
647
+        'ge'         => function($item, $prop, $value) {
648 648
           return $item[$prop] >= $value;
649 649
         },
650
-        'gte'         => function ($item, $prop, $value) {
650
+        'gte'         => function($item, $prop, $value) {
651 651
           return $item[$prop] >= $value;
652 652
         },
653
-        'lt'          => function ($item, $prop, $value) {
653
+        'lt'          => function($item, $prop, $value) {
654 654
           return $item[$prop] < $value;
655 655
         },
656
-        'le'         => function ($item, $prop, $value) {
656
+        'le'         => function($item, $prop, $value) {
657 657
           return $item[$prop] <= $value;
658 658
         },
659
-        'lte'         => function ($item, $prop, $value) {
659
+        'lte'         => function($item, $prop, $value) {
660 660
           return $item[$prop] <= $value;
661 661
         },
662
-        'ne'          => function ($item, $prop, $value) {
662
+        'ne'          => function($item, $prop, $value) {
663 663
           return $item[$prop] !== $value;
664 664
         },
665
-        'contains'    => function ($item, $prop, $value) {
666
-          return in_array($item[$prop], (array)$value, true);
665
+        'contains'    => function($item, $prop, $value) {
666
+          return in_array($item[$prop], (array) $value, true);
667 667
         },
668
-        'notContains' => function ($item, $prop, $value) {
669
-          return !in_array($item[$prop], (array)$value, true);
668
+        'notContains' => function($item, $prop, $value) {
669
+          return !in_array($item[$prop], (array) $value, true);
670 670
         },
671
-        'newer'       => function ($item, $prop, $value) {
671
+        'newer'       => function($item, $prop, $value) {
672 672
           return strtotime($item[$prop]) > strtotime($value);
673 673
         },
674
-        'older'       => function ($item, $prop, $value) {
674
+        'older'       => function($item, $prop, $value) {
675 675
           return strtotime($item[$prop]) < strtotime($value);
676 676
         },
677 677
     );
678 678
 
679 679
     $result = array_values(
680 680
         array_filter(
681
-            (array)$this->array,
682
-            function ($item) use (
681
+            (array) $this->array,
682
+            function($item) use (
683 683
                 $property,
684 684
                 $value,
685 685
                 $ops,
686 686
                 $comparisonOp
687 687
             ) {
688
-              $item = (array)$item;
688
+              $item = (array) $item;
689 689
               $itemArrayy = new Arrayy($item);
690 690
               $item[$property] = $itemArrayy->get($property, array());
691 691
 
@@ -758,9 +758,9 @@  discard block
 block discarded – undo
758 758
   public function firstsMutable($number = null)
759 759
   {
760 760
     if ($number === null) {
761
-      $this->array = (array)array_shift($this->array);
761
+      $this->array = (array) array_shift($this->array);
762 762
     } else {
763
-      $number = (int)$number;
763
+      $number = (int) $number;
764 764
       $this->array = array_splice($this->array, 0, $number, true);
765 765
     }
766 766
 
@@ -777,9 +777,9 @@  discard block
 block discarded – undo
777 777
   public function firstsImmutable($number = null)
778 778
   {
779 779
     if ($number === null) {
780
-      $array = (array)array_shift($this->array);
780
+      $array = (array) array_shift($this->array);
781 781
     } else {
782
-      $number = (int)$number;
782
+      $number = (int) $number;
783 783
       $array = array_splice($this->array, 0, $number, true);
784 784
     }
785 785
 
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
    */
969 969
   public function group($grouper, $saveKeys = false)
970 970
   {
971
-    $array = (array)$this->array;
971
+    $array = (array) $this->array;
972 972
     $result = array();
973 973
 
974 974
     // Iterate over values, group by property/results from closure
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
   public function has($key)
1003 1003
   {
1004 1004
     // Generate unique string to use as marker.
1005
-    $unFound = (string)uniqid('arrayy', true);
1005
+    $unFound = (string) uniqid('arrayy', true);
1006 1006
 
1007 1007
     return $this->get($key, $unFound) !== $unFound;
1008 1008
   }
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
       // If the key doesn't exist at this depth, we will just create an empty array
1126 1126
       // to hold the next value, allowing us to create the arrays to hold final
1127 1127
       // values at the correct depth. Then we'll keep digging into the array.
1128
-      if (! isset($array[$key]) || ! is_array($array[$key])) {
1128
+      if (!isset($array[$key]) || !is_array($array[$key])) {
1129 1129
         $array[$key] = array();
1130 1130
       }
1131 1131
       $array = &$array[$key];
@@ -1254,7 +1254,7 @@  discard block
 block discarded – undo
1254 1254
    */
1255 1255
   public function keys()
1256 1256
   {
1257
-    $array = array_keys((array)$this->array);
1257
+    $array = array_keys((array) $this->array);
1258 1258
 
1259 1259
     return static::create($array);
1260 1260
   }
@@ -1285,10 +1285,10 @@  discard block
 block discarded – undo
1285 1285
   public function lastsImmutable($number = null)
1286 1286
   {
1287 1287
     if ($number === null) {
1288
-      $poppedValue = (array)$this->pop();
1288
+      $poppedValue = (array) $this->pop();
1289 1289
       $arrayy = static::create($poppedValue);
1290 1290
     } else {
1291
-      $number = (int)$number;
1291
+      $number = (int) $number;
1292 1292
       $arrayy = $this->rest(-$number);
1293 1293
     }
1294 1294
 
@@ -1305,10 +1305,10 @@  discard block
 block discarded – undo
1305 1305
   public function lastsMutable($number = null)
1306 1306
   {
1307 1307
     if ($number === null) {
1308
-      $poppedValue = (array)$this->pop();
1308
+      $poppedValue = (array) $this->pop();
1309 1309
       $this->array = static::create($poppedValue)->array;
1310 1310
     } else {
1311
-      $number = (int)$number;
1311
+      $number = (int) $number;
1312 1312
       $this->array = $this->rest(-$number)->array;
1313 1313
     }
1314 1314
 
@@ -1568,7 +1568,7 @@  discard block
 block discarded – undo
1568 1568
     }
1569 1569
 
1570 1570
     if ($number === null) {
1571
-      $arrayRandValue = (array)$this->array[array_rand($this->array)];
1571
+      $arrayRandValue = (array) $this->array[array_rand($this->array)];
1572 1572
       $this->array = $arrayRandValue;
1573 1573
 
1574 1574
       return $this;
@@ -1593,7 +1593,7 @@  discard block
 block discarded – undo
1593 1593
     }
1594 1594
 
1595 1595
     if ($number === null) {
1596
-      $arrayRandValue = (array)$this->array[array_rand($this->array)];
1596
+      $arrayRandValue = (array) $this->array[array_rand($this->array)];
1597 1597
 
1598 1598
       return static::create($arrayRandValue);
1599 1599
     }
@@ -1634,7 +1634,7 @@  discard block
 block discarded – undo
1634 1634
    */
1635 1635
   public function randomKeys($number)
1636 1636
   {
1637
-    $number = (int)$number;
1637
+    $number = (int) $number;
1638 1638
     $count = $this->count();
1639 1639
 
1640 1640
     if ($number === 0 || $number > $count) {
@@ -1647,7 +1647,7 @@  discard block
 block discarded – undo
1647 1647
       );
1648 1648
     }
1649 1649
 
1650
-    $result = (array)array_rand($this->array, $number);
1650
+    $result = (array) array_rand($this->array, $number);
1651 1651
 
1652 1652
     return static::create($result);
1653 1653
   }
@@ -1677,7 +1677,7 @@  discard block
 block discarded – undo
1677 1677
    */
1678 1678
   public function randomValues($number)
1679 1679
   {
1680
-    $number = (int)$number;
1680
+    $number = (int) $number;
1681 1681
 
1682 1682
     return $this->randomMutable($number);
1683 1683
   }
@@ -1724,7 +1724,7 @@  discard block
 block discarded – undo
1724 1724
       $this->array = $result;
1725 1725
     }
1726 1726
 
1727
-    return static::create((array)$this->array);
1727
+    return static::create((array) $this->array);
1728 1728
   }
1729 1729
 
1730 1730
   /**
@@ -1922,7 +1922,7 @@  discard block
 block discarded – undo
1922 1922
   public function replaceValues($search, $replacement = '')
1923 1923
   {
1924 1924
     $array = $this->each(
1925
-        function ($value) use ($search, $replacement) {
1925
+        function($value) use ($search, $replacement) {
1926 1926
           return UTF8::str_replace($search, $replacement, $value);
1927 1927
         }
1928 1928
     );
@@ -2150,7 +2150,7 @@  discard block
 block discarded – undo
2150 2150
    */
2151 2151
   public function sorter($sorter = null, $direction = SORT_ASC, $strategy = SORT_REGULAR)
2152 2152
   {
2153
-    $array = (array)$this->array;
2153
+    $array = (array) $this->array;
2154 2154
     $direction = $this->getDirection($direction);
2155 2155
 
2156 2156
     // Transform all values into their results.
@@ -2159,7 +2159,7 @@  discard block
 block discarded – undo
2159 2159
 
2160 2160
       $that = $this;
2161 2161
       $results = $arrayy->each(
2162
-          function ($value) use ($sorter, $that) {
2162
+          function($value) use ($sorter, $that) {
2163 2163
             return is_callable($sorter) ? $sorter($value) : $that->get($sorter, null, $value);
2164 2164
           }
2165 2165
       );
@@ -2245,7 +2245,7 @@  discard block
 block discarded – undo
2245 2245
     if (count($this->array) === 0) {
2246 2246
       $result = array();
2247 2247
     } else {
2248
-      $numberOfPieces = (int)$numberOfPieces;
2248
+      $numberOfPieces = (int) $numberOfPieces;
2249 2249
       $splitSize = ceil(count($this->array) / $numberOfPieces);
2250 2250
       $result = array_chunk($this->array, $splitSize, $keepKeys);
2251 2251
     }
@@ -2294,7 +2294,7 @@  discard block
 block discarded – undo
2294 2294
   {
2295 2295
     $this->array = array_reduce(
2296 2296
         $this->array,
2297
-        function ($resultArray, $value) {
2297
+        function($resultArray, $value) {
2298 2298
           if (in_array($value, $resultArray, true) === false) {
2299 2299
             $resultArray[] = $value;
2300 2300
           }
@@ -2329,7 +2329,7 @@  discard block
 block discarded – undo
2329 2329
    */
2330 2330
   public function values()
2331 2331
   {
2332
-    $array = array_values((array)$this->array);
2332
+    $array = array_values((array) $this->array);
2333 2333
 
2334 2334
     return static::create($array);
2335 2335
   }
Please login to merge, or discard this patch.