Completed
Push — master ( abeb62...6c7a9b )
by Lars
01:38
created
src/Arrayy.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
       return false;
81 81
     }
82 82
 
83
-    return (array)$this->array;
83
+    return (array) $this->array;
84 84
   }
85 85
 
86 86
   /**
@@ -304,8 +304,8 @@  discard block
 block discarded – undo
304 304
     }
305 305
 
306 306
     // php cast "bool"-index into "int"-index
307
-    if ((bool)$offset === $offset) {
308
-      $offset = (int)$offset;
307
+    if ((bool) $offset === $offset) {
308
+      $offset = (int) $offset;
309 309
     }
310 310
 
311 311
     $tmpReturn = \array_key_exists($offset, $this->array);
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
         (
317 317
             $tmpReturn === false
318 318
             &&
319
-            strpos((string)$offset, $this->pathSeparator) === false
319
+            strpos((string) $offset, $this->pathSeparator) === false
320 320
         )
321 321
     ) {
322 322
       return $tmpReturn;
@@ -324,16 +324,16 @@  discard block
 block discarded – undo
324 324
 
325 325
     $offsetExists = false;
326 326
 
327
-    if (strpos((string)$offset, $this->pathSeparator) !== false) {
327
+    if (strpos((string) $offset, $this->pathSeparator) !== false) {
328 328
 
329 329
       $offsetExists = false;
330
-      $explodedPath = explode($this->pathSeparator, (string)$offset);
330
+      $explodedPath = explode($this->pathSeparator, (string) $offset);
331 331
       $lastOffset = \array_pop($explodedPath);
332 332
       $containerPath = implode($this->pathSeparator, $explodedPath);
333 333
 
334 334
       $this->callAtPath(
335 335
           $containerPath,
336
-          function ($container) use ($lastOffset, &$offsetExists) {
336
+          function($container) use ($lastOffset, &$offsetExists) {
337 337
             $offsetExists = \array_key_exists($lastOffset, $container);
338 338
           }
339 339
       );
@@ -386,14 +386,14 @@  discard block
 block discarded – undo
386 386
       return;
387 387
     }
388 388
 
389
-    if (strpos((string)$offset, $this->pathSeparator) !== false) {
389
+    if (strpos((string) $offset, $this->pathSeparator) !== false) {
390 390
 
391
-      $path = explode($this->pathSeparator, (string)$offset);
391
+      $path = explode($this->pathSeparator, (string) $offset);
392 392
       $pathToUnset = \array_pop($path);
393 393
 
394 394
       $this->callAtPath(
395 395
           implode($this->pathSeparator, $path),
396
-          function (&$offset) use ($pathToUnset) {
396
+          function(&$offset) use ($pathToUnset) {
397 397
             unset($offset[$pathToUnset]);
398 398
           }
399 399
       );
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
     }
430 430
 
431 431
     if (strpos($class, '\\') === 0) {
432
-      $class = '\\' . $class;
432
+      $class = '\\'.$class;
433 433
       if (class_exists($class)) {
434 434
         $this->iteratorClass = $class;
435 435
 
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
       }
438 438
     }
439 439
 
440
-    throw new \InvalidArgumentException('The iterator class does not exist: ' . $class);
440
+    throw new \InvalidArgumentException('The iterator class does not exist: '.$class);
441 441
   }
442 442
 
443 443
   /**
@@ -623,8 +623,8 @@  discard block
 block discarded – undo
623 623
   public function clean()
624 624
   {
625 625
     return $this->filter(
626
-        function ($value) {
627
-          return (bool)$value;
626
+        function($value) {
627
+          return (bool) $value;
628 628
         }
629 629
     );
630 630
   }
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
     // trim all string in the array
843 843
     \array_walk(
844 844
         $array,
845
-        function (&$val) {
845
+        function(&$val) {
846 846
           /** @noinspection ReferenceMismatchInspection */
847 847
           if (is_string($val)) {
848 848
             $val = trim($val);
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
     }
1082 1082
 
1083 1083
     if ($isObject && method_exists($array, '__toArray')) {
1084
-      return (array)$array->__toArray();
1084
+      return (array) $array->__toArray();
1085 1085
     }
1086 1086
 
1087 1087
     /** @noinspection ReferenceMismatchInspection */
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
         ||
1091 1091
         ($isObject && method_exists($array, '__toString'))
1092 1092
     ) {
1093
-      return array((string)$array);
1093
+      return array((string) $array);
1094 1094
     }
1095 1095
 
1096 1096
     throw new \InvalidArgumentException(
@@ -1197,54 +1197,54 @@  discard block
 block discarded – undo
1197 1197
     }
1198 1198
 
1199 1199
     $ops = array(
1200
-        'eq'          => function ($item, $prop, $value) {
1200
+        'eq'          => function($item, $prop, $value) {
1201 1201
           return $item[$prop] === $value;
1202 1202
         },
1203
-        'gt'          => function ($item, $prop, $value) {
1203
+        'gt'          => function($item, $prop, $value) {
1204 1204
           return $item[$prop] > $value;
1205 1205
         },
1206
-        'ge'          => function ($item, $prop, $value) {
1206
+        'ge'          => function($item, $prop, $value) {
1207 1207
           return $item[$prop] >= $value;
1208 1208
         },
1209
-        'gte'         => function ($item, $prop, $value) {
1209
+        'gte'         => function($item, $prop, $value) {
1210 1210
           return $item[$prop] >= $value;
1211 1211
         },
1212
-        'lt'          => function ($item, $prop, $value) {
1212
+        'lt'          => function($item, $prop, $value) {
1213 1213
           return $item[$prop] < $value;
1214 1214
         },
1215
-        'le'          => function ($item, $prop, $value) {
1215
+        'le'          => function($item, $prop, $value) {
1216 1216
           return $item[$prop] <= $value;
1217 1217
         },
1218
-        'lte'         => function ($item, $prop, $value) {
1218
+        'lte'         => function($item, $prop, $value) {
1219 1219
           return $item[$prop] <= $value;
1220 1220
         },
1221
-        'ne'          => function ($item, $prop, $value) {
1221
+        'ne'          => function($item, $prop, $value) {
1222 1222
           return $item[$prop] !== $value;
1223 1223
         },
1224
-        'contains'    => function ($item, $prop, $value) {
1225
-          return in_array($item[$prop], (array)$value, true);
1224
+        'contains'    => function($item, $prop, $value) {
1225
+          return in_array($item[$prop], (array) $value, true);
1226 1226
         },
1227
-        'notContains' => function ($item, $prop, $value) {
1228
-          return !in_array($item[$prop], (array)$value, true);
1227
+        'notContains' => function($item, $prop, $value) {
1228
+          return !in_array($item[$prop], (array) $value, true);
1229 1229
         },
1230
-        'newer'       => function ($item, $prop, $value) {
1230
+        'newer'       => function($item, $prop, $value) {
1231 1231
           return strtotime($item[$prop]) > strtotime($value);
1232 1232
         },
1233
-        'older'       => function ($item, $prop, $value) {
1233
+        'older'       => function($item, $prop, $value) {
1234 1234
           return strtotime($item[$prop]) < strtotime($value);
1235 1235
         },
1236 1236
     );
1237 1237
 
1238 1238
     $result = \array_values(
1239 1239
         \array_filter(
1240
-            (array)$this->array,
1241
-            function ($item) use (
1240
+            (array) $this->array,
1241
+            function($item) use (
1242 1242
                 $property,
1243 1243
                 $value,
1244 1244
                 $ops,
1245 1245
                 $comparisonOp
1246 1246
             ) {
1247
-              $item = (array)$item;
1247
+              $item = (array) $item;
1248 1248
               $itemArrayy = new Arrayy($item);
1249 1249
               $item[$property] = $itemArrayy->get($property, array());
1250 1250
 
@@ -1317,9 +1317,9 @@  discard block
 block discarded – undo
1317 1317
   {
1318 1318
     if ($number === null) {
1319 1319
       $arrayTmp = $this->array;
1320
-      $array = (array)\array_shift($arrayTmp);
1320
+      $array = (array) \array_shift($arrayTmp);
1321 1321
     } else {
1322
-      $number = (int)$number;
1322
+      $number = (int) $number;
1323 1323
       $arrayTmp = $this->array;
1324 1324
       $array = \array_splice($arrayTmp, 0, $number, true);
1325 1325
     }
@@ -1337,9 +1337,9 @@  discard block
 block discarded – undo
1337 1337
   public function firstsMutable($number = null)
1338 1338
   {
1339 1339
     if ($number === null) {
1340
-      $this->array = (array)\array_shift($this->array);
1340
+      $this->array = (array) \array_shift($this->array);
1341 1341
     } else {
1342
-      $number = (int)$number;
1342
+      $number = (int) $number;
1343 1343
       $this->array = \array_splice($this->array, 0, $number, true);
1344 1344
     }
1345 1345
 
@@ -1385,8 +1385,8 @@  discard block
 block discarded – undo
1385 1385
     }
1386 1386
 
1387 1387
     // php cast "bool"-index into "int"-index
1388
-    if ((bool)$key === $key) {
1389
-      $key = (int)$key;
1388
+    if ((bool) $key === $key) {
1389
+      $key = (int) $key;
1390 1390
     }
1391 1391
 
1392 1392
     if (\array_key_exists($key, $usedArray) === true) {
@@ -1398,7 +1398,7 @@  discard block
 block discarded – undo
1398 1398
     }
1399 1399
 
1400 1400
     // Crawl through array, get key according to object or not
1401
-    foreach (explode($this->pathSeparator, (string)$key) as $segment) {
1401
+    foreach (explode($this->pathSeparator, (string) $key) as $segment) {
1402 1402
       if (!isset($usedArray[$segment])) {
1403 1403
         return $fallback instanceof \Closure ? $fallback() : $fallback;
1404 1404
       }
@@ -1596,7 +1596,7 @@  discard block
 block discarded – undo
1596 1596
    */
1597 1597
   public function group($grouper, $saveKeys = false)
1598 1598
   {
1599
-    $array = (array)$this->array;
1599
+    $array = (array) $this->array;
1600 1600
     $result = array();
1601 1601
 
1602 1602
     // Iterate over values, group by property/results from closure
@@ -1639,7 +1639,7 @@  discard block
 block discarded – undo
1639 1639
   public function has($key)
1640 1640
   {
1641 1641
     // Generate unique string to use as marker.
1642
-    $unFound = (string)uniqid('arrayy', true);
1642
+    $unFound = (string) uniqid('arrayy', true);
1643 1643
 
1644 1644
     return $this->get($key, $unFound) !== $unFound;
1645 1645
   }
@@ -1670,7 +1670,7 @@  discard block
 block discarded – undo
1670 1670
           $glue,
1671 1671
           array_map(
1672 1672
               array('self', 'implode_recursive'),
1673
-              array_fill(0,  ($pieces_count > 0 ? $pieces_count : 1), $glue),
1673
+              array_fill(0, ($pieces_count > 0 ? $pieces_count : 1), $glue),
1674 1674
               $pieces
1675 1675
           )
1676 1676
       );
@@ -1759,7 +1759,7 @@  discard block
 block discarded – undo
1759 1759
    */
1760 1760
   protected function internalRemove($key)
1761 1761
   {
1762
-    $path = explode($this->pathSeparator, (string)$key);
1762
+    $path = explode($this->pathSeparator, (string) $key);
1763 1763
 
1764 1764
     // Crawl though the keys
1765 1765
     while (count($path) > 1) {
@@ -1794,8 +1794,8 @@  discard block
 block discarded – undo
1794 1794
     }
1795 1795
 
1796 1796
     // init
1797
-    $array =& $this->array;
1798
-    $path = explode($this->pathSeparator, (string)$key);
1797
+    $array = & $this->array;
1798
+    $path = explode($this->pathSeparator, (string) $key);
1799 1799
 
1800 1800
     // Crawl through the keys
1801 1801
     while (count($path) > 1) {
@@ -1808,7 +1808,7 @@  discard block
 block discarded – undo
1808 1808
         $array[$key] = static::create(array());
1809 1809
       }
1810 1810
 
1811
-      $array =& $array[$key];
1811
+      $array = & $array[$key];
1812 1812
     }
1813 1813
 
1814 1814
     $array[\array_shift($path)] = $value;
@@ -2012,12 +2012,12 @@  discard block
 block discarded – undo
2012 2012
       if ($poppedValue === null) {
2013 2013
         $poppedValue = array($poppedValue);
2014 2014
       } else {
2015
-        $poppedValue = (array)$poppedValue;
2015
+        $poppedValue = (array) $poppedValue;
2016 2016
       }
2017 2017
 
2018 2018
       $arrayy = static::create($poppedValue);
2019 2019
     } else {
2020
-      $number = (int)$number;
2020
+      $number = (int) $number;
2021 2021
       $arrayy = $this->rest(-$number);
2022 2022
     }
2023 2023
 
@@ -2043,12 +2043,12 @@  discard block
 block discarded – undo
2043 2043
       if ($poppedValue === null) {
2044 2044
         $poppedValue = array($poppedValue);
2045 2045
       } else {
2046
-        $poppedValue = (array)$poppedValue;
2046
+        $poppedValue = (array) $poppedValue;
2047 2047
       }
2048 2048
 
2049 2049
       $this->array = static::create($poppedValue)->array;
2050 2050
     } else {
2051
-      $number = (int)$number;
2051
+      $number = (int) $number;
2052 2052
       $this->array = $this->rest(-$number)->array;
2053 2053
     }
2054 2054
 
@@ -2418,7 +2418,7 @@  discard block
 block discarded – undo
2418 2418
    */
2419 2419
   public function randomKeys($number)
2420 2420
   {
2421
-    $number = (int)$number;
2421
+    $number = (int) $number;
2422 2422
     $count = $this->count();
2423 2423
 
2424 2424
     if ($number === 0 || $number > $count) {
@@ -2431,7 +2431,7 @@  discard block
 block discarded – undo
2431 2431
       );
2432 2432
     }
2433 2433
 
2434
-    $result = (array)\array_rand($this->array, $number);
2434
+    $result = (array) \array_rand($this->array, $number);
2435 2435
 
2436 2436
     return static::create($result);
2437 2437
   }
@@ -2486,7 +2486,7 @@  discard block
 block discarded – undo
2486 2486
    */
2487 2487
   public function randomValues($number)
2488 2488
   {
2489
-    $number = (int)$number;
2489
+    $number = (int) $number;
2490 2490
 
2491 2491
     return $this->randomMutable($number);
2492 2492
   }
@@ -2530,7 +2530,7 @@  discard block
 block discarded – undo
2530 2530
     if ($result === null) {
2531 2531
       $this->array = array();
2532 2532
     } else {
2533
-      $this->array = (array)$result;
2533
+      $this->array = (array) $result;
2534 2534
     }
2535 2535
 
2536 2536
     return static::create($this->array);
@@ -2656,7 +2656,7 @@  discard block
 block discarded – undo
2656 2656
       return new static();
2657 2657
     }
2658 2658
 
2659
-    return static::create(\array_fill(0, (int)$times, $this->array));
2659
+    return static::create(\array_fill(0, (int) $times, $this->array));
2660 2660
   }
2661 2661
 
2662 2662
   /**
@@ -2749,7 +2749,7 @@  discard block
 block discarded – undo
2749 2749
   public function replaceValues($search, $replacement = '')
2750 2750
   {
2751 2751
     $array = $this->each(
2752
-        function ($value) use ($search, $replacement) {
2752
+        function($value) use ($search, $replacement) {
2753 2753
           return UTF8::str_replace($search, $replacement, $value);
2754 2754
         }
2755 2755
     );
@@ -2830,8 +2830,8 @@  discard block
 block discarded – undo
2830 2830
     }
2831 2831
 
2832 2832
     // php cast "bool"-index into "int"-index
2833
-    if ((bool)$index === $index) {
2834
-      $index = (int)$index;
2833
+    if ((bool) $index === $index) {
2834
+      $index = (int) $index;
2835 2835
     }
2836 2836
 
2837 2837
     if (\array_key_exists($index, $this->array) === true) {
@@ -3004,7 +3004,7 @@  discard block
 block discarded – undo
3004 3004
    */
3005 3005
   public function sorter($sorter = null, $direction = SORT_ASC, $strategy = SORT_REGULAR)
3006 3006
   {
3007
-    $array = (array)$this->array;
3007
+    $array = (array) $this->array;
3008 3008
     $direction = $this->getDirection($direction);
3009 3009
 
3010 3010
     // Transform all values into their results.
@@ -3013,7 +3013,7 @@  discard block
 block discarded – undo
3013 3013
 
3014 3014
       $that = $this;
3015 3015
       $results = $arrayy->each(
3016
-          function ($value) use ($sorter, $that) {
3016
+          function($value) use ($sorter, $that) {
3017 3017
             return is_callable($sorter) ? $sorter($value) : $that->get($sorter, null, $value);
3018 3018
           }
3019 3019
       );
@@ -3110,8 +3110,8 @@  discard block
 block discarded – undo
3110 3110
     if ($arrayCount === 0) {
3111 3111
       $result = array();
3112 3112
     } else {
3113
-      $numberOfPieces = (int)$numberOfPieces;
3114
-      $splitSize = (int)ceil($arrayCount / $numberOfPieces);
3113
+      $numberOfPieces = (int) $numberOfPieces;
3114
+      $splitSize = (int) ceil($arrayCount / $numberOfPieces);
3115 3115
       $result = \array_chunk($this->array, $splitSize, $keepKeys);
3116 3116
     }
3117 3117
 
@@ -3126,12 +3126,12 @@  discard block
 block discarded – undo
3126 3126
   public function stripEmpty()
3127 3127
   {
3128 3128
     return $this->filter(
3129
-        function ($item) {
3129
+        function($item) {
3130 3130
           if ($item === null) {
3131 3131
             return false;
3132 3132
           }
3133 3133
 
3134
-          return (bool)trim((string)$item);
3134
+          return (bool) trim((string) $item);
3135 3135
         }
3136 3136
     );
3137 3137
   }
@@ -3199,7 +3199,7 @@  discard block
 block discarded – undo
3199 3199
 
3200 3200
     $this->array = \array_reduce(
3201 3201
         $this->array,
3202
-        function ($resultArray, $value) {
3202
+        function($resultArray, $value) {
3203 3203
           if (!in_array($value, $resultArray, true)) {
3204 3204
             $resultArray[] = $value;
3205 3205
           }
@@ -3212,7 +3212,7 @@  discard block
 block discarded – undo
3212 3212
     if ($this->array === null) {
3213 3213
       $this->array = array();
3214 3214
     } else {
3215
-      $this->array = (array)$this->array;
3215
+      $this->array = (array) $this->array;
3216 3216
     }
3217 3217
 
3218 3218
     return $this;
@@ -3232,7 +3232,7 @@  discard block
 block discarded – undo
3232 3232
 
3233 3233
     $this->array = \array_reduce(
3234 3234
         \array_keys($array),
3235
-        function ($resultArray, $key) use ($array) {
3235
+        function($resultArray, $key) use ($array) {
3236 3236
           if (!in_array($array[$key], $resultArray, true)) {
3237 3237
             $resultArray[$key] = $array[$key];
3238 3238
           }
@@ -3245,7 +3245,7 @@  discard block
 block discarded – undo
3245 3245
     if ($this->array === null) {
3246 3246
       $this->array = array();
3247 3247
     } else {
3248
-      $this->array = (array)$this->array;
3248
+      $this->array = (array) $this->array;
3249 3249
     }
3250 3250
 
3251 3251
     return $this;
@@ -3285,7 +3285,7 @@  discard block
 block discarded – undo
3285 3285
    */
3286 3286
   public function values()
3287 3287
   {
3288
-    return static::create(\array_values((array)$this->array));
3288
+    return static::create(\array_values((array) $this->array));
3289 3289
   }
3290 3290
 
3291 3291
   /**
Please login to merge, or discard this patch.