@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Arrayy; |
| 6 | 6 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | if (!isset(static::$methodArgs[$name])) { |
| 46 | - throw new \BadMethodCallException($name . ' is not a valid method'); |
|
| 46 | + throw new \BadMethodCallException($name.' is not a valid method'); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $numArgs = count($arguments); |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Arrayy; |
| 6 | 6 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Arrayy; |
| 6 | 6 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - return (array)$this->array; |
|
| 77 | + return (array) $this->array; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | ( |
| 190 | 190 | $tmpReturn === false |
| 191 | 191 | && |
| 192 | - strpos((string)$offset, $this->pathSeparator) === false |
|
| 192 | + strpos((string) $offset, $this->pathSeparator) === false |
|
| 193 | 193 | ) |
| 194 | 194 | ) { |
| 195 | 195 | |
@@ -199,16 +199,16 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | $offsetExists = false; |
| 201 | 201 | |
| 202 | - if (strpos((string)$offset, $this->pathSeparator) !== false) { |
|
| 202 | + if (strpos((string) $offset, $this->pathSeparator) !== false) { |
|
| 203 | 203 | |
| 204 | 204 | $offsetExists = false; |
| 205 | - $explodedPath = explode($this->pathSeparator, (string)$offset); |
|
| 205 | + $explodedPath = explode($this->pathSeparator, (string) $offset); |
|
| 206 | 206 | $lastOffset = array_pop($explodedPath); |
| 207 | 207 | $containerPath = implode($this->pathSeparator, $explodedPath); |
| 208 | 208 | |
| 209 | 209 | $this->callAtPath( |
| 210 | 210 | $containerPath, |
| 211 | - function ($container) use ($lastOffset, &$offsetExists) { |
|
| 211 | + function($container) use ($lastOffset, &$offsetExists) { |
|
| 212 | 212 | $offsetExists = isset($container[$lastOffset]); |
| 213 | 213 | } |
| 214 | 214 | ); |
@@ -258,14 +258,14 @@ discard block |
||
| 258 | 258 | return; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - if (strpos((string)$offset, $this->pathSeparator) !== false) { |
|
| 261 | + if (strpos((string) $offset, $this->pathSeparator) !== false) { |
|
| 262 | 262 | |
| 263 | - $path = explode($this->pathSeparator, (string)$offset); |
|
| 263 | + $path = explode($this->pathSeparator, (string) $offset); |
|
| 264 | 264 | $pathToUnset = array_pop($path); |
| 265 | 265 | |
| 266 | 266 | $this->callAtPath( |
| 267 | 267 | implode($this->pathSeparator, $path), |
| 268 | - function (&$offset) use (&$pathToUnset) { |
|
| 268 | + function(&$offset) use (&$pathToUnset) { |
|
| 269 | 269 | unset($offset[$pathToUnset]); |
| 270 | 270 | } |
| 271 | 271 | ); |
@@ -405,8 +405,8 @@ discard block |
||
| 405 | 405 | public function clean() |
| 406 | 406 | { |
| 407 | 407 | return $this->filter( |
| 408 | - function ($value) { |
|
| 409 | - return (bool)$value; |
|
| 408 | + function($value) { |
|
| 409 | + return (bool) $value; |
|
| 410 | 410 | } |
| 411 | 411 | ); |
| 412 | 412 | } |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | // trim all string in the array |
| 593 | 593 | array_walk( |
| 594 | 594 | $array, |
| 595 | - function (&$val) { |
|
| 595 | + function(&$val) { |
|
| 596 | 596 | /** @noinspection ReferenceMismatchInspection */ |
| 597 | 597 | if (is_string($val)) { |
| 598 | 598 | $val = trim($val); |
@@ -805,7 +805,7 @@ discard block |
||
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | if (is_object($array) && method_exists($array, '__toArray')) { |
| 808 | - return (array)$array->__toArray(); |
|
| 808 | + return (array) $array->__toArray(); |
|
| 809 | 809 | } |
| 810 | 810 | |
| 811 | 811 | /** @noinspection ReferenceMismatchInspection */ |
@@ -814,7 +814,7 @@ discard block |
||
| 814 | 814 | || |
| 815 | 815 | (is_object($array) && method_exists($array, '__toString')) |
| 816 | 816 | ) { |
| 817 | - return (array)$array; |
|
| 817 | + return (array) $array; |
|
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | throw new \InvalidArgumentException( |
@@ -867,54 +867,54 @@ discard block |
||
| 867 | 867 | } |
| 868 | 868 | |
| 869 | 869 | $ops = array( |
| 870 | - 'eq' => function ($item, $prop, $value) { |
|
| 870 | + 'eq' => function($item, $prop, $value) { |
|
| 871 | 871 | return $item[$prop] === $value; |
| 872 | 872 | }, |
| 873 | - 'gt' => function ($item, $prop, $value) { |
|
| 873 | + 'gt' => function($item, $prop, $value) { |
|
| 874 | 874 | return $item[$prop] > $value; |
| 875 | 875 | }, |
| 876 | - 'ge' => function ($item, $prop, $value) { |
|
| 876 | + 'ge' => function($item, $prop, $value) { |
|
| 877 | 877 | return $item[$prop] >= $value; |
| 878 | 878 | }, |
| 879 | - 'gte' => function ($item, $prop, $value) { |
|
| 879 | + 'gte' => function($item, $prop, $value) { |
|
| 880 | 880 | return $item[$prop] >= $value; |
| 881 | 881 | }, |
| 882 | - 'lt' => function ($item, $prop, $value) { |
|
| 882 | + 'lt' => function($item, $prop, $value) { |
|
| 883 | 883 | return $item[$prop] < $value; |
| 884 | 884 | }, |
| 885 | - 'le' => function ($item, $prop, $value) { |
|
| 885 | + 'le' => function($item, $prop, $value) { |
|
| 886 | 886 | return $item[$prop] <= $value; |
| 887 | 887 | }, |
| 888 | - 'lte' => function ($item, $prop, $value) { |
|
| 888 | + 'lte' => function($item, $prop, $value) { |
|
| 889 | 889 | return $item[$prop] <= $value; |
| 890 | 890 | }, |
| 891 | - 'ne' => function ($item, $prop, $value) { |
|
| 891 | + 'ne' => function($item, $prop, $value) { |
|
| 892 | 892 | return $item[$prop] !== $value; |
| 893 | 893 | }, |
| 894 | - 'contains' => function ($item, $prop, $value) { |
|
| 895 | - return in_array($item[$prop], (array)$value, true); |
|
| 894 | + 'contains' => function($item, $prop, $value) { |
|
| 895 | + return in_array($item[$prop], (array) $value, true); |
|
| 896 | 896 | }, |
| 897 | - 'notContains' => function ($item, $prop, $value) { |
|
| 898 | - return !in_array($item[$prop], (array)$value, true); |
|
| 897 | + 'notContains' => function($item, $prop, $value) { |
|
| 898 | + return !in_array($item[$prop], (array) $value, true); |
|
| 899 | 899 | }, |
| 900 | - 'newer' => function ($item, $prop, $value) { |
|
| 900 | + 'newer' => function($item, $prop, $value) { |
|
| 901 | 901 | return strtotime($item[$prop]) > strtotime($value); |
| 902 | 902 | }, |
| 903 | - 'older' => function ($item, $prop, $value) { |
|
| 903 | + 'older' => function($item, $prop, $value) { |
|
| 904 | 904 | return strtotime($item[$prop]) < strtotime($value); |
| 905 | 905 | }, |
| 906 | 906 | ); |
| 907 | 907 | |
| 908 | 908 | $result = array_values( |
| 909 | 909 | array_filter( |
| 910 | - (array)$this->array, |
|
| 911 | - function ($item) use ( |
|
| 910 | + (array) $this->array, |
|
| 911 | + function($item) use ( |
|
| 912 | 912 | $property, |
| 913 | 913 | $value, |
| 914 | 914 | $ops, |
| 915 | 915 | $comparisonOp |
| 916 | 916 | ) { |
| 917 | - $item = (array)$item; |
|
| 917 | + $item = (array) $item; |
|
| 918 | 918 | $itemArrayy = new Arrayy($item); |
| 919 | 919 | $item[$property] = $itemArrayy->get($property, array()); |
| 920 | 920 | |
@@ -987,9 +987,9 @@ discard block |
||
| 987 | 987 | { |
| 988 | 988 | if ($number === null) { |
| 989 | 989 | $arrayTmp = $this->array; |
| 990 | - $array = (array)array_shift($arrayTmp); |
|
| 990 | + $array = (array) array_shift($arrayTmp); |
|
| 991 | 991 | } else { |
| 992 | - $number = (int)$number; |
|
| 992 | + $number = (int) $number; |
|
| 993 | 993 | $arrayTmp = $this->array; |
| 994 | 994 | $array = array_splice($arrayTmp, 0, $number, true); |
| 995 | 995 | } |
@@ -1007,9 +1007,9 @@ discard block |
||
| 1007 | 1007 | public function firstsMutable($number = null) |
| 1008 | 1008 | { |
| 1009 | 1009 | if ($number === null) { |
| 1010 | - $this->array = (array)array_shift($this->array); |
|
| 1010 | + $this->array = (array) array_shift($this->array); |
|
| 1011 | 1011 | } else { |
| 1012 | - $number = (int)$number; |
|
| 1012 | + $number = (int) $number; |
|
| 1013 | 1013 | $this->array = array_splice($this->array, 0, $number, true); |
| 1014 | 1014 | } |
| 1015 | 1015 | |
@@ -1054,7 +1054,7 @@ discard block |
||
| 1054 | 1054 | } |
| 1055 | 1055 | |
| 1056 | 1056 | // Crawl through array, get key according to object or not |
| 1057 | - foreach (explode($this->pathSeparator, (string)$key) as $segment) { |
|
| 1057 | + foreach (explode($this->pathSeparator, (string) $key) as $segment) { |
|
| 1058 | 1058 | if (!isset($usedArray[$segment])) { |
| 1059 | 1059 | return $default instanceof \Closure ? $default() : $default; |
| 1060 | 1060 | } |
@@ -1210,7 +1210,7 @@ discard block |
||
| 1210 | 1210 | */ |
| 1211 | 1211 | public function group($grouper, $saveKeys = false) |
| 1212 | 1212 | { |
| 1213 | - $array = (array)$this->array; |
|
| 1213 | + $array = (array) $this->array; |
|
| 1214 | 1214 | $result = array(); |
| 1215 | 1215 | |
| 1216 | 1216 | // Iterate over values, group by property/results from closure |
@@ -1244,7 +1244,7 @@ discard block |
||
| 1244 | 1244 | public function has($key) |
| 1245 | 1245 | { |
| 1246 | 1246 | // Generate unique string to use as marker. |
| 1247 | - $unFound = (string)uniqid('arrayy', true); |
|
| 1247 | + $unFound = (string) uniqid('arrayy', true); |
|
| 1248 | 1248 | |
| 1249 | 1249 | return $this->get($key, $unFound) !== $unFound; |
| 1250 | 1250 | } |
@@ -1322,7 +1322,7 @@ discard block |
||
| 1322 | 1322 | */ |
| 1323 | 1323 | protected function internalRemove($key) |
| 1324 | 1324 | { |
| 1325 | - $path = explode($this->pathSeparator, (string)$key); |
|
| 1325 | + $path = explode($this->pathSeparator, (string) $key); |
|
| 1326 | 1326 | |
| 1327 | 1327 | // Crawl though the keys |
| 1328 | 1328 | while (count($path) > 1) { |
@@ -1358,7 +1358,7 @@ discard block |
||
| 1358 | 1358 | |
| 1359 | 1359 | // init |
| 1360 | 1360 | $array = &$this->array; |
| 1361 | - $path = explode($this->pathSeparator, (string)$key); |
|
| 1361 | + $path = explode($this->pathSeparator, (string) $key); |
|
| 1362 | 1362 | |
| 1363 | 1363 | // Crawl through the keys |
| 1364 | 1364 | while (count($path) > 1) { |
@@ -1544,10 +1544,10 @@ discard block |
||
| 1544 | 1544 | public function lastsImmutable($number = null) |
| 1545 | 1545 | { |
| 1546 | 1546 | if ($number === null) { |
| 1547 | - $poppedValue = (array)$this->pop(); |
|
| 1547 | + $poppedValue = (array) $this->pop(); |
|
| 1548 | 1548 | $arrayy = static::create($poppedValue); |
| 1549 | 1549 | } else { |
| 1550 | - $number = (int)$number; |
|
| 1550 | + $number = (int) $number; |
|
| 1551 | 1551 | $arrayy = $this->rest(-$number); |
| 1552 | 1552 | } |
| 1553 | 1553 | |
@@ -1564,10 +1564,10 @@ discard block |
||
| 1564 | 1564 | public function lastsMutable($number = null) |
| 1565 | 1565 | { |
| 1566 | 1566 | if ($number === null) { |
| 1567 | - $poppedValue = (array)$this->pop(); |
|
| 1567 | + $poppedValue = (array) $this->pop(); |
|
| 1568 | 1568 | $this->array = static::create($poppedValue)->array; |
| 1569 | 1569 | } else { |
| 1570 | - $number = (int)$number; |
|
| 1570 | + $number = (int) $number; |
|
| 1571 | 1571 | $this->array = $this->rest(-$number)->array; |
| 1572 | 1572 | } |
| 1573 | 1573 | |
@@ -1849,7 +1849,7 @@ discard block |
||
| 1849 | 1849 | } |
| 1850 | 1850 | |
| 1851 | 1851 | if ($number === null) { |
| 1852 | - $arrayRandValue = (array)$this->array[array_rand($this->array)]; |
|
| 1852 | + $arrayRandValue = (array) $this->array[array_rand($this->array)]; |
|
| 1853 | 1853 | |
| 1854 | 1854 | return static::create($arrayRandValue); |
| 1855 | 1855 | } |
@@ -1890,7 +1890,7 @@ discard block |
||
| 1890 | 1890 | */ |
| 1891 | 1891 | public function randomKeys($number) |
| 1892 | 1892 | { |
| 1893 | - $number = (int)$number; |
|
| 1893 | + $number = (int) $number; |
|
| 1894 | 1894 | $count = $this->count(); |
| 1895 | 1895 | |
| 1896 | 1896 | if ($number === 0 || $number > $count) { |
@@ -1903,7 +1903,7 @@ discard block |
||
| 1903 | 1903 | ); |
| 1904 | 1904 | } |
| 1905 | 1905 | |
| 1906 | - $result = (array)array_rand($this->array, $number); |
|
| 1906 | + $result = (array) array_rand($this->array, $number); |
|
| 1907 | 1907 | |
| 1908 | 1908 | return static::create($result); |
| 1909 | 1909 | } |
@@ -1922,7 +1922,7 @@ discard block |
||
| 1922 | 1922 | } |
| 1923 | 1923 | |
| 1924 | 1924 | if ($number === null) { |
| 1925 | - $arrayRandValue = (array)$this->array[array_rand($this->array)]; |
|
| 1925 | + $arrayRandValue = (array) $this->array[array_rand($this->array)]; |
|
| 1926 | 1926 | $this->array = $arrayRandValue; |
| 1927 | 1927 | |
| 1928 | 1928 | return $this; |
@@ -1958,7 +1958,7 @@ discard block |
||
| 1958 | 1958 | */ |
| 1959 | 1959 | public function randomValues($number) |
| 1960 | 1960 | { |
| 1961 | - $number = (int)$number; |
|
| 1961 | + $number = (int) $number; |
|
| 1962 | 1962 | |
| 1963 | 1963 | return $this->randomMutable($number); |
| 1964 | 1964 | } |
@@ -2002,7 +2002,7 @@ discard block |
||
| 2002 | 2002 | if ($result === null) { |
| 2003 | 2003 | $this->array = array(); |
| 2004 | 2004 | } else { |
| 2005 | - $this->array = (array)$result; |
|
| 2005 | + $this->array = (array) $result; |
|
| 2006 | 2006 | } |
| 2007 | 2007 | |
| 2008 | 2008 | return static::create($this->array); |
@@ -2205,7 +2205,7 @@ discard block |
||
| 2205 | 2205 | public function replaceValues($search, $replacement = '') |
| 2206 | 2206 | { |
| 2207 | 2207 | $array = $this->each( |
| 2208 | - function ($value) use ($search, $replacement) { |
|
| 2208 | + function($value) use ($search, $replacement) { |
|
| 2209 | 2209 | return UTF8::str_replace($search, $replacement, $value); |
| 2210 | 2210 | } |
| 2211 | 2211 | ); |
@@ -2251,7 +2251,7 @@ discard block |
||
| 2251 | 2251 | array_splice($array, $indexToMove, 1); |
| 2252 | 2252 | $i = 0; |
| 2253 | 2253 | $output = array(); |
| 2254 | - foreach($array as $key => $item) { |
|
| 2254 | + foreach ($array as $key => $item) { |
|
| 2255 | 2255 | if ($i == $to) { |
| 2256 | 2256 | $output[$from] = $itemToMove; |
| 2257 | 2257 | } |
@@ -2471,7 +2471,7 @@ discard block |
||
| 2471 | 2471 | */ |
| 2472 | 2472 | public function sorter($sorter = null, $direction = SORT_ASC, $strategy = SORT_REGULAR) |
| 2473 | 2473 | { |
| 2474 | - $array = (array)$this->array; |
|
| 2474 | + $array = (array) $this->array; |
|
| 2475 | 2475 | $direction = $this->getDirection($direction); |
| 2476 | 2476 | |
| 2477 | 2477 | // Transform all values into their results. |
@@ -2480,7 +2480,7 @@ discard block |
||
| 2480 | 2480 | |
| 2481 | 2481 | $that = $this; |
| 2482 | 2482 | $results = $arrayy->each( |
| 2483 | - function ($value) use ($sorter, $that) { |
|
| 2483 | + function($value) use ($sorter, $that) { |
|
| 2484 | 2484 | return is_callable($sorter) ? $sorter($value) : $that->get($sorter, null, $value); |
| 2485 | 2485 | } |
| 2486 | 2486 | ); |
@@ -2568,8 +2568,8 @@ discard block |
||
| 2568 | 2568 | if ($arrayCount === 0) { |
| 2569 | 2569 | $result = array(); |
| 2570 | 2570 | } else { |
| 2571 | - $numberOfPieces = (int)$numberOfPieces; |
|
| 2572 | - $splitSize = (int)ceil($arrayCount / $numberOfPieces); |
|
| 2571 | + $numberOfPieces = (int) $numberOfPieces; |
|
| 2572 | + $splitSize = (int) ceil($arrayCount / $numberOfPieces); |
|
| 2573 | 2573 | $result = array_chunk($this->array, $splitSize, $keepKeys); |
| 2574 | 2574 | } |
| 2575 | 2575 | |
@@ -2584,12 +2584,12 @@ discard block |
||
| 2584 | 2584 | public function stripEmpty() |
| 2585 | 2585 | { |
| 2586 | 2586 | return $this->filter( |
| 2587 | - function ($item) { |
|
| 2587 | + function($item) { |
|
| 2588 | 2588 | if (null === $item) { |
| 2589 | 2589 | return false; |
| 2590 | 2590 | } |
| 2591 | 2591 | |
| 2592 | - return (bool)trim((string)$item); |
|
| 2592 | + return (bool) trim((string) $item); |
|
| 2593 | 2593 | } |
| 2594 | 2594 | ); |
| 2595 | 2595 | } |
@@ -2654,7 +2654,7 @@ discard block |
||
| 2654 | 2654 | { |
| 2655 | 2655 | $this->array = array_reduce( |
| 2656 | 2656 | $this->array, |
| 2657 | - function ($resultArray, $value) { |
|
| 2657 | + function($resultArray, $value) { |
|
| 2658 | 2658 | if (in_array($value, $resultArray, true) === false) { |
| 2659 | 2659 | $resultArray[] = $value; |
| 2660 | 2660 | } |
@@ -2667,7 +2667,7 @@ discard block |
||
| 2667 | 2667 | if ($this->array === null) { |
| 2668 | 2668 | $this->array = array(); |
| 2669 | 2669 | } else { |
| 2670 | - $this->array = (array)$this->array; |
|
| 2670 | + $this->array = (array) $this->array; |
|
| 2671 | 2671 | } |
| 2672 | 2672 | |
| 2673 | 2673 | return $this; |
@@ -2695,7 +2695,7 @@ discard block |
||
| 2695 | 2695 | */ |
| 2696 | 2696 | public function values() |
| 2697 | 2697 | { |
| 2698 | - return static::create(array_values((array)$this->array)); |
|
| 2698 | + return static::create(array_values((array) $this->array)); |
|
| 2699 | 2699 | } |
| 2700 | 2700 | |
| 2701 | 2701 | /** |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare(strict_types=1); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace Arrayy; |
| 6 | 6 | |