@@ -41,7 +41,7 @@ |
||
41 | 41 | } |
42 | 42 | |
43 | 43 | if (!isset(static::$methodArgs[$name])) { |
44 | - throw new \BadMethodCallException($name . ' is not a valid method'); |
|
44 | + throw new \BadMethodCallException($name.' is not a valid method'); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $numArgs = count($arguments); |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
324 | - * @param mixed $path |
|
324 | + * @param string $path |
|
325 | 325 | * @param callable $callable |
326 | 326 | * @param null|array $currentOffset |
327 | 327 | */ |
@@ -2504,7 +2504,7 @@ discard block |
||
2504 | 2504 | |
2505 | 2505 | /** |
2506 | 2506 | * @param array &$elements |
2507 | - * @param int|string $direction |
|
2507 | + * @param integer $direction |
|
2508 | 2508 | * @param int $strategy |
2509 | 2509 | * @param bool $keepKeys |
2510 | 2510 | */ |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | - return (array)$this->array; |
|
75 | + return (array) $this->array; |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | ( |
188 | 188 | $tmpReturn === false |
189 | 189 | && |
190 | - strpos((string)$offset, $this->pathSeparator) === false |
|
190 | + strpos((string) $offset, $this->pathSeparator) === false |
|
191 | 191 | ) |
192 | 192 | ) { |
193 | 193 | |
@@ -197,16 +197,16 @@ discard block |
||
197 | 197 | |
198 | 198 | $offsetExists = false; |
199 | 199 | |
200 | - if (strpos((string)$offset, $this->pathSeparator) !== false) { |
|
200 | + if (strpos((string) $offset, $this->pathSeparator) !== false) { |
|
201 | 201 | |
202 | 202 | $offsetExists = false; |
203 | - $explodedPath = explode($this->pathSeparator, (string)$offset); |
|
203 | + $explodedPath = explode($this->pathSeparator, (string) $offset); |
|
204 | 204 | $lastOffset = array_pop($explodedPath); |
205 | 205 | $containerPath = implode($this->pathSeparator, $explodedPath); |
206 | 206 | |
207 | 207 | $this->callAtPath( |
208 | 208 | $containerPath, |
209 | - function ($container) use ($lastOffset, &$offsetExists) { |
|
209 | + function($container) use ($lastOffset, &$offsetExists) { |
|
210 | 210 | $offsetExists = isset($container[$lastOffset]); |
211 | 211 | } |
212 | 212 | ); |
@@ -256,14 +256,14 @@ discard block |
||
256 | 256 | return; |
257 | 257 | } |
258 | 258 | |
259 | - if (strpos((string)$offset, $this->pathSeparator) !== false) { |
|
259 | + if (strpos((string) $offset, $this->pathSeparator) !== false) { |
|
260 | 260 | |
261 | - $path = explode($this->pathSeparator, (string)$offset); |
|
261 | + $path = explode($this->pathSeparator, (string) $offset); |
|
262 | 262 | $pathToUnset = array_pop($path); |
263 | 263 | |
264 | 264 | $this->callAtPath( |
265 | 265 | implode($this->pathSeparator, $path), |
266 | - function (&$offset) use (&$pathToUnset) { |
|
266 | + function(&$offset) use (&$pathToUnset) { |
|
267 | 267 | unset($offset[$pathToUnset]); |
268 | 268 | } |
269 | 269 | ); |
@@ -403,8 +403,8 @@ discard block |
||
403 | 403 | public function clean() |
404 | 404 | { |
405 | 405 | return $this->filter( |
406 | - function ($value) { |
|
407 | - return (bool)$value; |
|
406 | + function($value) { |
|
407 | + return (bool) $value; |
|
408 | 408 | } |
409 | 409 | ); |
410 | 410 | } |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | // trim all string in the array |
591 | 591 | array_walk( |
592 | 592 | $array, |
593 | - function (&$val) { |
|
593 | + function(&$val) { |
|
594 | 594 | /** @noinspection ReferenceMismatchInspection */ |
595 | 595 | if (is_string($val)) { |
596 | 596 | $val = trim($val); |
@@ -807,7 +807,7 @@ discard block |
||
807 | 807 | } |
808 | 808 | |
809 | 809 | if (is_object($array) && method_exists($array, '__toArray')) { |
810 | - return (array)$array->__toArray(); |
|
810 | + return (array) $array->__toArray(); |
|
811 | 811 | } |
812 | 812 | |
813 | 813 | /** @noinspection ReferenceMismatchInspection */ |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | || |
817 | 817 | (is_object($array) && method_exists($array, '__toString')) |
818 | 818 | ) { |
819 | - return (array)$array; |
|
819 | + return (array) $array; |
|
820 | 820 | } |
821 | 821 | |
822 | 822 | throw new \InvalidArgumentException( |
@@ -869,54 +869,54 @@ discard block |
||
869 | 869 | } |
870 | 870 | |
871 | 871 | $ops = array( |
872 | - 'eq' => function ($item, $prop, $value) { |
|
872 | + 'eq' => function($item, $prop, $value) { |
|
873 | 873 | return $item[$prop] === $value; |
874 | 874 | }, |
875 | - 'gt' => function ($item, $prop, $value) { |
|
875 | + 'gt' => function($item, $prop, $value) { |
|
876 | 876 | return $item[$prop] > $value; |
877 | 877 | }, |
878 | - 'ge' => function ($item, $prop, $value) { |
|
878 | + 'ge' => function($item, $prop, $value) { |
|
879 | 879 | return $item[$prop] >= $value; |
880 | 880 | }, |
881 | - 'gte' => function ($item, $prop, $value) { |
|
881 | + 'gte' => function($item, $prop, $value) { |
|
882 | 882 | return $item[$prop] >= $value; |
883 | 883 | }, |
884 | - 'lt' => function ($item, $prop, $value) { |
|
884 | + 'lt' => function($item, $prop, $value) { |
|
885 | 885 | return $item[$prop] < $value; |
886 | 886 | }, |
887 | - 'le' => function ($item, $prop, $value) { |
|
887 | + 'le' => function($item, $prop, $value) { |
|
888 | 888 | return $item[$prop] <= $value; |
889 | 889 | }, |
890 | - 'lte' => function ($item, $prop, $value) { |
|
890 | + 'lte' => function($item, $prop, $value) { |
|
891 | 891 | return $item[$prop] <= $value; |
892 | 892 | }, |
893 | - 'ne' => function ($item, $prop, $value) { |
|
893 | + 'ne' => function($item, $prop, $value) { |
|
894 | 894 | return $item[$prop] !== $value; |
895 | 895 | }, |
896 | - 'contains' => function ($item, $prop, $value) { |
|
897 | - return in_array($item[$prop], (array)$value, true); |
|
896 | + 'contains' => function($item, $prop, $value) { |
|
897 | + return in_array($item[$prop], (array) $value, true); |
|
898 | 898 | }, |
899 | - 'notContains' => function ($item, $prop, $value) { |
|
900 | - return !in_array($item[$prop], (array)$value, true); |
|
899 | + 'notContains' => function($item, $prop, $value) { |
|
900 | + return !in_array($item[$prop], (array) $value, true); |
|
901 | 901 | }, |
902 | - 'newer' => function ($item, $prop, $value) { |
|
902 | + 'newer' => function($item, $prop, $value) { |
|
903 | 903 | return strtotime($item[$prop]) > strtotime($value); |
904 | 904 | }, |
905 | - 'older' => function ($item, $prop, $value) { |
|
905 | + 'older' => function($item, $prop, $value) { |
|
906 | 906 | return strtotime($item[$prop]) < strtotime($value); |
907 | 907 | }, |
908 | 908 | ); |
909 | 909 | |
910 | 910 | $result = array_values( |
911 | 911 | array_filter( |
912 | - (array)$this->array, |
|
913 | - function ($item) use ( |
|
912 | + (array) $this->array, |
|
913 | + function($item) use ( |
|
914 | 914 | $property, |
915 | 915 | $value, |
916 | 916 | $ops, |
917 | 917 | $comparisonOp |
918 | 918 | ) { |
919 | - $item = (array)$item; |
|
919 | + $item = (array) $item; |
|
920 | 920 | $itemArrayy = new Arrayy($item); |
921 | 921 | $item[$property] = $itemArrayy->get($property, array()); |
922 | 922 | |
@@ -989,9 +989,9 @@ discard block |
||
989 | 989 | { |
990 | 990 | if ($number === null) { |
991 | 991 | $arrayTmp = $this->array; |
992 | - $array = (array)array_shift($arrayTmp); |
|
992 | + $array = (array) array_shift($arrayTmp); |
|
993 | 993 | } else { |
994 | - $number = (int)$number; |
|
994 | + $number = (int) $number; |
|
995 | 995 | $arrayTmp = $this->array; |
996 | 996 | $array = array_splice($arrayTmp, 0, $number, true); |
997 | 997 | } |
@@ -1009,9 +1009,9 @@ discard block |
||
1009 | 1009 | public function firstsMutable($number = null) |
1010 | 1010 | { |
1011 | 1011 | if ($number === null) { |
1012 | - $this->array = (array)array_shift($this->array); |
|
1012 | + $this->array = (array) array_shift($this->array); |
|
1013 | 1013 | } else { |
1014 | - $number = (int)$number; |
|
1014 | + $number = (int) $number; |
|
1015 | 1015 | $this->array = array_splice($this->array, 0, $number, true); |
1016 | 1016 | } |
1017 | 1017 | |
@@ -1064,7 +1064,7 @@ discard block |
||
1064 | 1064 | } |
1065 | 1065 | |
1066 | 1066 | // Crawl through array, get key according to object or not |
1067 | - foreach (explode($this->pathSeparator, (string)$key) as $segment) { |
|
1067 | + foreach (explode($this->pathSeparator, (string) $key) as $segment) { |
|
1068 | 1068 | if (!isset($usedArray[$segment])) { |
1069 | 1069 | return $default instanceof \Closure ? $default() : $default; |
1070 | 1070 | } |
@@ -1236,7 +1236,7 @@ discard block |
||
1236 | 1236 | */ |
1237 | 1237 | public function group($grouper, $saveKeys = false) |
1238 | 1238 | { |
1239 | - $array = (array)$this->array; |
|
1239 | + $array = (array) $this->array; |
|
1240 | 1240 | $result = array(); |
1241 | 1241 | |
1242 | 1242 | // Iterate over values, group by property/results from closure |
@@ -1279,7 +1279,7 @@ discard block |
||
1279 | 1279 | public function has($key) |
1280 | 1280 | { |
1281 | 1281 | // Generate unique string to use as marker. |
1282 | - $unFound = (string)uniqid('arrayy', true); |
|
1282 | + $unFound = (string) uniqid('arrayy', true); |
|
1283 | 1283 | |
1284 | 1284 | return $this->get($key, $unFound) !== $unFound; |
1285 | 1285 | } |
@@ -1357,7 +1357,7 @@ discard block |
||
1357 | 1357 | */ |
1358 | 1358 | protected function internalRemove($key) |
1359 | 1359 | { |
1360 | - $path = explode($this->pathSeparator, (string)$key); |
|
1360 | + $path = explode($this->pathSeparator, (string) $key); |
|
1361 | 1361 | |
1362 | 1362 | // Crawl though the keys |
1363 | 1363 | while (count($path) > 1) { |
@@ -1392,8 +1392,8 @@ discard block |
||
1392 | 1392 | } |
1393 | 1393 | |
1394 | 1394 | // init |
1395 | - $array =& $this->array; |
|
1396 | - $path = explode($this->pathSeparator, (string)$key); |
|
1395 | + $array = & $this->array; |
|
1396 | + $path = explode($this->pathSeparator, (string) $key); |
|
1397 | 1397 | |
1398 | 1398 | // Crawl through the keys |
1399 | 1399 | while (count($path) > 1) { |
@@ -1406,7 +1406,7 @@ discard block |
||
1406 | 1406 | $array[$key] = self::create(array()); |
1407 | 1407 | } |
1408 | 1408 | |
1409 | - $array =& $array[$key]; |
|
1409 | + $array = & $array[$key]; |
|
1410 | 1410 | } |
1411 | 1411 | |
1412 | 1412 | $array[array_shift($path)] = $value; |
@@ -1575,10 +1575,10 @@ discard block |
||
1575 | 1575 | public function lastsImmutable($number = null) |
1576 | 1576 | { |
1577 | 1577 | if ($number === null) { |
1578 | - $poppedValue = (array)$this->pop(); |
|
1578 | + $poppedValue = (array) $this->pop(); |
|
1579 | 1579 | $arrayy = static::create($poppedValue); |
1580 | 1580 | } else { |
1581 | - $number = (int)$number; |
|
1581 | + $number = (int) $number; |
|
1582 | 1582 | $arrayy = $this->rest(-$number); |
1583 | 1583 | } |
1584 | 1584 | |
@@ -1595,10 +1595,10 @@ discard block |
||
1595 | 1595 | public function lastsMutable($number = null) |
1596 | 1596 | { |
1597 | 1597 | if ($number === null) { |
1598 | - $poppedValue = (array)$this->pop(); |
|
1598 | + $poppedValue = (array) $this->pop(); |
|
1599 | 1599 | $this->array = static::create($poppedValue)->array; |
1600 | 1600 | } else { |
1601 | - $number = (int)$number; |
|
1601 | + $number = (int) $number; |
|
1602 | 1602 | $this->array = $this->rest(-$number)->array; |
1603 | 1603 | } |
1604 | 1604 | |
@@ -1880,7 +1880,7 @@ discard block |
||
1880 | 1880 | } |
1881 | 1881 | |
1882 | 1882 | if ($number === null) { |
1883 | - $arrayRandValue = (array)$this->array[array_rand($this->array)]; |
|
1883 | + $arrayRandValue = (array) $this->array[array_rand($this->array)]; |
|
1884 | 1884 | |
1885 | 1885 | return static::create($arrayRandValue); |
1886 | 1886 | } |
@@ -1921,7 +1921,7 @@ discard block |
||
1921 | 1921 | */ |
1922 | 1922 | public function randomKeys($number) |
1923 | 1923 | { |
1924 | - $number = (int)$number; |
|
1924 | + $number = (int) $number; |
|
1925 | 1925 | $count = $this->count(); |
1926 | 1926 | |
1927 | 1927 | if ($number === 0 || $number > $count) { |
@@ -1934,7 +1934,7 @@ discard block |
||
1934 | 1934 | ); |
1935 | 1935 | } |
1936 | 1936 | |
1937 | - $result = (array)array_rand($this->array, $number); |
|
1937 | + $result = (array) array_rand($this->array, $number); |
|
1938 | 1938 | |
1939 | 1939 | return static::create($result); |
1940 | 1940 | } |
@@ -1953,7 +1953,7 @@ discard block |
||
1953 | 1953 | } |
1954 | 1954 | |
1955 | 1955 | if ($number === null) { |
1956 | - $arrayRandValue = (array)$this->array[array_rand($this->array)]; |
|
1956 | + $arrayRandValue = (array) $this->array[array_rand($this->array)]; |
|
1957 | 1957 | $this->array = $arrayRandValue; |
1958 | 1958 | |
1959 | 1959 | return $this; |
@@ -1989,7 +1989,7 @@ discard block |
||
1989 | 1989 | */ |
1990 | 1990 | public function randomValues($number) |
1991 | 1991 | { |
1992 | - $number = (int)$number; |
|
1992 | + $number = (int) $number; |
|
1993 | 1993 | |
1994 | 1994 | return $this->randomMutable($number); |
1995 | 1995 | } |
@@ -2033,7 +2033,7 @@ discard block |
||
2033 | 2033 | if ($result === null) { |
2034 | 2034 | $this->array = array(); |
2035 | 2035 | } else { |
2036 | - $this->array = (array)$result; |
|
2036 | + $this->array = (array) $result; |
|
2037 | 2037 | } |
2038 | 2038 | |
2039 | 2039 | return static::create($this->array); |
@@ -2236,7 +2236,7 @@ discard block |
||
2236 | 2236 | public function replaceValues($search, $replacement = '') |
2237 | 2237 | { |
2238 | 2238 | $array = $this->each( |
2239 | - function ($value) use ($search, $replacement) { |
|
2239 | + function($value) use ($search, $replacement) { |
|
2240 | 2240 | return UTF8::str_replace($search, $replacement, $value); |
2241 | 2241 | } |
2242 | 2242 | ); |
@@ -2282,7 +2282,7 @@ discard block |
||
2282 | 2282 | array_splice($array, $indexToMove, 1); |
2283 | 2283 | $i = 0; |
2284 | 2284 | $output = array(); |
2285 | - foreach($array as $key => $item) { |
|
2285 | + foreach ($array as $key => $item) { |
|
2286 | 2286 | if ($i == $to) { |
2287 | 2287 | $output[$from] = $itemToMove; |
2288 | 2288 | } |
@@ -2502,7 +2502,7 @@ discard block |
||
2502 | 2502 | */ |
2503 | 2503 | public function sorter($sorter = null, $direction = SORT_ASC, $strategy = SORT_REGULAR) |
2504 | 2504 | { |
2505 | - $array = (array)$this->array; |
|
2505 | + $array = (array) $this->array; |
|
2506 | 2506 | $direction = $this->getDirection($direction); |
2507 | 2507 | |
2508 | 2508 | // Transform all values into their results. |
@@ -2511,7 +2511,7 @@ discard block |
||
2511 | 2511 | |
2512 | 2512 | $that = $this; |
2513 | 2513 | $results = $arrayy->each( |
2514 | - function ($value) use ($sorter, $that) { |
|
2514 | + function($value) use ($sorter, $that) { |
|
2515 | 2515 | return is_callable($sorter) ? $sorter($value) : $that->get($sorter, null, $value); |
2516 | 2516 | } |
2517 | 2517 | ); |
@@ -2599,8 +2599,8 @@ discard block |
||
2599 | 2599 | if ($arrayCount === 0) { |
2600 | 2600 | $result = array(); |
2601 | 2601 | } else { |
2602 | - $numberOfPieces = (int)$numberOfPieces; |
|
2603 | - $splitSize = (int)ceil($arrayCount / $numberOfPieces); |
|
2602 | + $numberOfPieces = (int) $numberOfPieces; |
|
2603 | + $splitSize = (int) ceil($arrayCount / $numberOfPieces); |
|
2604 | 2604 | $result = array_chunk($this->array, $splitSize, $keepKeys); |
2605 | 2605 | } |
2606 | 2606 | |
@@ -2615,12 +2615,12 @@ discard block |
||
2615 | 2615 | public function stripEmpty() |
2616 | 2616 | { |
2617 | 2617 | return $this->filter( |
2618 | - function ($item) { |
|
2618 | + function($item) { |
|
2619 | 2619 | if ($item === null) { |
2620 | 2620 | return false; |
2621 | 2621 | } |
2622 | 2622 | |
2623 | - return (bool)trim((string)$item); |
|
2623 | + return (bool) trim((string) $item); |
|
2624 | 2624 | } |
2625 | 2625 | ); |
2626 | 2626 | } |
@@ -2685,7 +2685,7 @@ discard block |
||
2685 | 2685 | { |
2686 | 2686 | $this->array = array_reduce( |
2687 | 2687 | $this->array, |
2688 | - function ($resultArray, $value) { |
|
2688 | + function($resultArray, $value) { |
|
2689 | 2689 | if (!in_array($value, $resultArray, true)) { |
2690 | 2690 | $resultArray[] = $value; |
2691 | 2691 | } |
@@ -2698,7 +2698,7 @@ discard block |
||
2698 | 2698 | if ($this->array === null) { |
2699 | 2699 | $this->array = array(); |
2700 | 2700 | } else { |
2701 | - $this->array = (array)$this->array; |
|
2701 | + $this->array = (array) $this->array; |
|
2702 | 2702 | } |
2703 | 2703 | |
2704 | 2704 | return $this; |
@@ -2726,7 +2726,7 @@ discard block |
||
2726 | 2726 | */ |
2727 | 2727 | public function values() |
2728 | 2728 | { |
2729 | - return static::create(array_values((array)$this->array)); |
|
2729 | + return static::create(array_values((array) $this->array)); |
|
2730 | 2730 | } |
2731 | 2731 | |
2732 | 2732 | /** |