Completed
Branch master (9bd847)
by Lars
03:32 queued 01:22
created
src/Arrayy.php 1 patch
Spacing   +48 added lines, -48 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
 
@@ -756,9 +756,9 @@  discard block
 block discarded – undo
756 756
   public function firstsMutable($number = null)
757 757
   {
758 758
     if ($number === null) {
759
-      $this->array = (array)array_shift($this->array);
759
+      $this->array = (array) array_shift($this->array);
760 760
     } else {
761
-      $number = (int)$number;
761
+      $number = (int) $number;
762 762
       $this->array = array_splice($this->array, 0, $number, true);
763 763
     }
764 764
 
@@ -775,9 +775,9 @@  discard block
 block discarded – undo
775 775
   public function firstsImmutable($number = null)
776 776
   {
777 777
     if ($number === null) {
778
-      $array = (array)array_shift($this->array);
778
+      $array = (array) array_shift($this->array);
779 779
     } else {
780
-      $number = (int)$number;
780
+      $number = (int) $number;
781 781
       $array = array_splice($this->array, 0, $number, true);
782 782
     }
783 783
 
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
    */
967 967
   public function group($grouper, $saveKeys = false)
968 968
   {
969
-    $array = (array)$this->array;
969
+    $array = (array) $this->array;
970 970
     $result = array();
971 971
 
972 972
     // Iterate over values, group by property/results from closure
@@ -1000,7 +1000,7 @@  discard block
 block discarded – undo
1000 1000
   public function has($key)
1001 1001
   {
1002 1002
     // Generate unique string to use as marker.
1003
-    $unFound = (string)uniqid('arrayy', true);
1003
+    $unFound = (string) uniqid('arrayy', true);
1004 1004
 
1005 1005
     return $this->get($key, $unFound) !== $unFound;
1006 1006
   }
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
       // If the key doesn't exist at this depth, we will just create an empty array
1124 1124
       // to hold the next value, allowing us to create the arrays to hold final
1125 1125
       // values at the correct depth. Then we'll keep digging into the array.
1126
-      if (! isset($array[$key]) || ! is_array($array[$key])) {
1126
+      if (!isset($array[$key]) || !is_array($array[$key])) {
1127 1127
         $array[$key] = array();
1128 1128
       }
1129 1129
       $array = &$array[$key];
@@ -1252,7 +1252,7 @@  discard block
 block discarded – undo
1252 1252
    */
1253 1253
   public function keys()
1254 1254
   {
1255
-    $array = array_keys((array)$this->array);
1255
+    $array = array_keys((array) $this->array);
1256 1256
 
1257 1257
     return static::create($array);
1258 1258
   }
@@ -1283,10 +1283,10 @@  discard block
 block discarded – undo
1283 1283
   public function lastsImmutable($number = null)
1284 1284
   {
1285 1285
     if ($number === null) {
1286
-      $poppedValue = (array)$this->pop();
1286
+      $poppedValue = (array) $this->pop();
1287 1287
       $arrayy = static::create($poppedValue);
1288 1288
     } else {
1289
-      $number = (int)$number;
1289
+      $number = (int) $number;
1290 1290
       $arrayy = $this->rest(-$number);
1291 1291
     }
1292 1292
 
@@ -1303,10 +1303,10 @@  discard block
 block discarded – undo
1303 1303
   public function lastsMutable($number = null)
1304 1304
   {
1305 1305
     if ($number === null) {
1306
-      $poppedValue = (array)$this->pop();
1306
+      $poppedValue = (array) $this->pop();
1307 1307
       $this->array = static::create($poppedValue)->array;
1308 1308
     } else {
1309
-      $number = (int)$number;
1309
+      $number = (int) $number;
1310 1310
       $this->array = $this->rest(-$number)->array;
1311 1311
     }
1312 1312
 
@@ -1566,7 +1566,7 @@  discard block
 block discarded – undo
1566 1566
     }
1567 1567
 
1568 1568
     if ($number === null) {
1569
-      $arrayRandValue = (array)$this->array[array_rand($this->array)];
1569
+      $arrayRandValue = (array) $this->array[array_rand($this->array)];
1570 1570
       $this->array = $arrayRandValue;
1571 1571
 
1572 1572
       return $this;
@@ -1591,7 +1591,7 @@  discard block
 block discarded – undo
1591 1591
     }
1592 1592
 
1593 1593
     if ($number === null) {
1594
-      $arrayRandValue = (array)$this->array[array_rand($this->array)];
1594
+      $arrayRandValue = (array) $this->array[array_rand($this->array)];
1595 1595
 
1596 1596
       return static::create($arrayRandValue);
1597 1597
     }
@@ -1632,7 +1632,7 @@  discard block
 block discarded – undo
1632 1632
    */
1633 1633
   public function randomKeys($number)
1634 1634
   {
1635
-    $number = (int)$number;
1635
+    $number = (int) $number;
1636 1636
     $count = $this->count();
1637 1637
 
1638 1638
     if ($number === 0 || $number > $count) {
@@ -1645,7 +1645,7 @@  discard block
 block discarded – undo
1645 1645
       );
1646 1646
     }
1647 1647
 
1648
-    $result = (array)array_rand($this->array, $number);
1648
+    $result = (array) array_rand($this->array, $number);
1649 1649
 
1650 1650
     return static::create($result);
1651 1651
   }
@@ -1675,7 +1675,7 @@  discard block
 block discarded – undo
1675 1675
    */
1676 1676
   public function randomValues($number)
1677 1677
   {
1678
-    $number = (int)$number;
1678
+    $number = (int) $number;
1679 1679
 
1680 1680
     return $this->randomMutable($number);
1681 1681
   }
@@ -1719,7 +1719,7 @@  discard block
 block discarded – undo
1719 1719
     if ($result === null) {
1720 1720
       $this->array = array();
1721 1721
     } else {
1722
-      $this->array = (array)$result;
1722
+      $this->array = (array) $result;
1723 1723
     }
1724 1724
 
1725 1725
     return static::create($this->array);
@@ -1920,7 +1920,7 @@  discard block
 block discarded – undo
1920 1920
   public function replaceValues($search, $replacement = '')
1921 1921
   {
1922 1922
     $array = $this->each(
1923
-        function ($value) use ($search, $replacement) {
1923
+        function($value) use ($search, $replacement) {
1924 1924
           return UTF8::str_replace($search, $replacement, $value);
1925 1925
         }
1926 1926
     );
@@ -2148,7 +2148,7 @@  discard block
 block discarded – undo
2148 2148
    */
2149 2149
   public function sorter($sorter = null, $direction = SORT_ASC, $strategy = SORT_REGULAR)
2150 2150
   {
2151
-    $array = (array)$this->array;
2151
+    $array = (array) $this->array;
2152 2152
     $direction = $this->getDirection($direction);
2153 2153
 
2154 2154
     // Transform all values into their results.
@@ -2157,7 +2157,7 @@  discard block
 block discarded – undo
2157 2157
 
2158 2158
       $that = $this;
2159 2159
       $results = $arrayy->each(
2160
-          function ($value) use ($sorter, $that) {
2160
+          function($value) use ($sorter, $that) {
2161 2161
             return is_callable($sorter) ? $sorter($value) : $that->get($sorter, null, $value);
2162 2162
           }
2163 2163
       );
@@ -2243,7 +2243,7 @@  discard block
 block discarded – undo
2243 2243
     if (count($this->array) === 0) {
2244 2244
       $result = array();
2245 2245
     } else {
2246
-      $numberOfPieces = (int)$numberOfPieces;
2246
+      $numberOfPieces = (int) $numberOfPieces;
2247 2247
       $splitSize = ceil(count($this->array) / $numberOfPieces);
2248 2248
       $result = array_chunk($this->array, $splitSize, $keepKeys);
2249 2249
     }
@@ -2292,7 +2292,7 @@  discard block
 block discarded – undo
2292 2292
   {
2293 2293
     $this->array = array_reduce(
2294 2294
         $this->array,
2295
-        function ($resultArray, $value) {
2295
+        function($resultArray, $value) {
2296 2296
           if (in_array($value, $resultArray, true) === false) {
2297 2297
             $resultArray[] = $value;
2298 2298
           }
@@ -2305,7 +2305,7 @@  discard block
 block discarded – undo
2305 2305
     if ($this->array === null) {
2306 2306
       $this->array = array();
2307 2307
     } else {
2308
-      $this->array = (array)$this->array;
2308
+      $this->array = (array) $this->array;
2309 2309
     }
2310 2310
 
2311 2311
     return $this;
@@ -2333,7 +2333,7 @@  discard block
 block discarded – undo
2333 2333
    */
2334 2334
   public function values()
2335 2335
   {
2336
-    $array = array_values((array)$this->array);
2336
+    $array = array_values((array) $this->array);
2337 2337
 
2338 2338
     return static::create($array);
2339 2339
   }
Please login to merge, or discard this patch.