@@ -62,11 +62,11 @@ discard block |
||
| 62 | 62 | || |
| 63 | 63 | (is_object($array) && method_exists($array, '__toString')) |
| 64 | 64 | ) { |
| 65 | - return (array)$array; |
|
| 65 | + return (array) $array; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | if (is_object($array) && method_exists($array, '__toArray')) { |
| 69 | - return (array)$array->__toArray(); |
|
| 69 | + return (array) $array->__toArray(); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | throw new \InvalidArgumentException( |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | // trim all string in the array |
| 110 | 110 | array_walk( |
| 111 | 111 | $array, |
| 112 | - function (&$val) { |
|
| 112 | + function(&$val) { |
|
| 113 | 113 | if (is_string($val)) { |
| 114 | 114 | $val = trim($val); |
| 115 | 115 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | if ($number === null) { |
| 204 | - $arrayRandValue = (array)$this->array[array_rand($this->array)]; |
|
| 204 | + $arrayRandValue = (array) $this->array[array_rand($this->array)]; |
|
| 205 | 205 | |
| 206 | 206 | return static::create($arrayRandValue); |
| 207 | 207 | } |
@@ -243,9 +243,9 @@ discard block |
||
| 243 | 243 | public function first($number = null) |
| 244 | 244 | { |
| 245 | 245 | if ($number === null) { |
| 246 | - $array = (array)array_shift($this->array); |
|
| 246 | + $array = (array) array_shift($this->array); |
|
| 247 | 247 | } else { |
| 248 | - $number = (int)$number; |
|
| 248 | + $number = (int) $number; |
|
| 249 | 249 | $array = array_splice($this->array, 0, $number, true); |
| 250 | 250 | } |
| 251 | 251 | |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | */ |
| 339 | 339 | public function randomValues($number) |
| 340 | 340 | { |
| 341 | - $number = (int)$number; |
|
| 341 | + $number = (int) $number; |
|
| 342 | 342 | |
| 343 | 343 | return $this->random($number); |
| 344 | 344 | } |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | */ |
| 377 | 377 | public function randomKeys($number) |
| 378 | 378 | { |
| 379 | - $number = (int)$number; |
|
| 379 | + $number = (int) $number; |
|
| 380 | 380 | $count = $this->count(); |
| 381 | 381 | |
| 382 | 382 | if ($number === 0 || $number > $count) { |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | ); |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - $result = (array)array_rand($this->array, $number); |
|
| 392 | + $result = (array) array_rand($this->array, $number); |
|
| 393 | 393 | |
| 394 | 394 | return static::create($result); |
| 395 | 395 | } |
@@ -439,48 +439,48 @@ discard block |
||
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | $ops = array( |
| 442 | - 'eq' => function ($item, $prop, $value) { |
|
| 442 | + 'eq' => function($item, $prop, $value) { |
|
| 443 | 443 | return $item[$prop] === $value; |
| 444 | 444 | }, |
| 445 | - 'gt' => function ($item, $prop, $value) { |
|
| 445 | + 'gt' => function($item, $prop, $value) { |
|
| 446 | 446 | return $item[$prop] > $value; |
| 447 | 447 | }, |
| 448 | - 'gte' => function ($item, $prop, $value) { |
|
| 448 | + 'gte' => function($item, $prop, $value) { |
|
| 449 | 449 | return $item[$prop] >= $value; |
| 450 | 450 | }, |
| 451 | - 'lt' => function ($item, $prop, $value) { |
|
| 451 | + 'lt' => function($item, $prop, $value) { |
|
| 452 | 452 | return $item[$prop] < $value; |
| 453 | 453 | }, |
| 454 | - 'lte' => function ($item, $prop, $value) { |
|
| 454 | + 'lte' => function($item, $prop, $value) { |
|
| 455 | 455 | return $item[$prop] <= $value; |
| 456 | 456 | }, |
| 457 | - 'ne' => function ($item, $prop, $value) { |
|
| 457 | + 'ne' => function($item, $prop, $value) { |
|
| 458 | 458 | return $item[$prop] !== $value; |
| 459 | 459 | }, |
| 460 | - 'contains' => function ($item, $prop, $value) { |
|
| 461 | - return in_array($item[$prop], (array)$value, true); |
|
| 460 | + 'contains' => function($item, $prop, $value) { |
|
| 461 | + return in_array($item[$prop], (array) $value, true); |
|
| 462 | 462 | }, |
| 463 | - 'notContains' => function ($item, $prop, $value) { |
|
| 464 | - return !in_array($item[$prop], (array)$value, true); |
|
| 463 | + 'notContains' => function($item, $prop, $value) { |
|
| 464 | + return !in_array($item[$prop], (array) $value, true); |
|
| 465 | 465 | }, |
| 466 | - 'newer' => function ($item, $prop, $value) { |
|
| 466 | + 'newer' => function($item, $prop, $value) { |
|
| 467 | 467 | return strtotime($item[$prop]) > strtotime($value); |
| 468 | 468 | }, |
| 469 | - 'older' => function ($item, $prop, $value) { |
|
| 469 | + 'older' => function($item, $prop, $value) { |
|
| 470 | 470 | return strtotime($item[$prop]) < strtotime($value); |
| 471 | 471 | }, |
| 472 | 472 | ); |
| 473 | 473 | |
| 474 | 474 | $result = array_values( |
| 475 | 475 | array_filter( |
| 476 | - (array)$this->array, |
|
| 477 | - function ($item) use ( |
|
| 476 | + (array) $this->array, |
|
| 477 | + function($item) use ( |
|
| 478 | 478 | $property, |
| 479 | 479 | $value, |
| 480 | 480 | $ops, |
| 481 | 481 | $comparisonOp |
| 482 | 482 | ) { |
| 483 | - $item = (array)$item; |
|
| 483 | + $item = (array) $item; |
|
| 484 | 484 | $itemArrayy = new Arrayy($item); |
| 485 | 485 | $item[$property] = $itemArrayy->get($property, array()); |
| 486 | 486 | |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | */ |
| 554 | 554 | public function values() |
| 555 | 555 | { |
| 556 | - $array = array_values((array)$this->array); |
|
| 556 | + $array = array_values((array) $this->array); |
|
| 557 | 557 | |
| 558 | 558 | return static::create($array); |
| 559 | 559 | } |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | */ |
| 569 | 569 | public function group($grouper, $saveKeys = false) |
| 570 | 570 | { |
| 571 | - $array = (array)$this->array; |
|
| 571 | + $array = (array) $this->array; |
|
| 572 | 572 | $result = array(); |
| 573 | 573 | |
| 574 | 574 | // Iterate over values, group by property/results from closure |
@@ -764,7 +764,7 @@ discard block |
||
| 764 | 764 | } |
| 765 | 765 | } |
| 766 | 766 | |
| 767 | - return (array)$this->array; |
|
| 767 | + return (array) $this->array; |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | /** |
@@ -883,7 +883,7 @@ discard block |
||
| 883 | 883 | return false; |
| 884 | 884 | } |
| 885 | 885 | |
| 886 | - return (bool)count(array_filter(array_keys($this->array), 'is_string')); |
|
| 886 | + return (bool) count(array_filter(array_keys($this->array), 'is_string')); |
|
| 887 | 887 | } |
| 888 | 888 | |
| 889 | 889 | /** |
@@ -948,7 +948,7 @@ discard block |
||
| 948 | 948 | */ |
| 949 | 949 | public function keys() |
| 950 | 950 | { |
| 951 | - $array = array_keys((array)$this->array); |
|
| 951 | + $array = array_keys((array) $this->array); |
|
| 952 | 952 | |
| 953 | 953 | return static::create($array); |
| 954 | 954 | } |
@@ -1098,8 +1098,8 @@ discard block |
||
| 1098 | 1098 | public function clean() |
| 1099 | 1099 | { |
| 1100 | 1100 | return $this->filter( |
| 1101 | - function ($value) { |
|
| 1102 | - return (bool)$value; |
|
| 1101 | + function($value) { |
|
| 1102 | + return (bool) $value; |
|
| 1103 | 1103 | } |
| 1104 | 1104 | ); |
| 1105 | 1105 | } |
@@ -1235,10 +1235,10 @@ discard block |
||
| 1235 | 1235 | public function last($number = null) |
| 1236 | 1236 | { |
| 1237 | 1237 | if ($number === null) { |
| 1238 | - $poppedValue = (array)$this->pop(); |
|
| 1238 | + $poppedValue = (array) $this->pop(); |
|
| 1239 | 1239 | $arrayy = static::create($poppedValue); |
| 1240 | 1240 | } else { |
| 1241 | - $number = (int)$number; |
|
| 1241 | + $number = (int) $number; |
|
| 1242 | 1242 | $arrayy = $this->rest(-$number); |
| 1243 | 1243 | } |
| 1244 | 1244 | |
@@ -1441,7 +1441,7 @@ discard block |
||
| 1441 | 1441 | public function replaceValues($search, $replacement = '') |
| 1442 | 1442 | { |
| 1443 | 1443 | $array = $this->each( |
| 1444 | - function ($value) use ($search, $replacement) { |
|
| 1444 | + function($value) use ($search, $replacement) { |
|
| 1445 | 1445 | return UTF8::str_replace($search, $replacement, $value); |
| 1446 | 1446 | } |
| 1447 | 1447 | ); |
@@ -1519,7 +1519,7 @@ discard block |
||
| 1519 | 1519 | if (count($this->array) === 0) { |
| 1520 | 1520 | $result = array(); |
| 1521 | 1521 | } else { |
| 1522 | - $numberOfPieces = (int)$numberOfPieces; |
|
| 1522 | + $numberOfPieces = (int) $numberOfPieces; |
|
| 1523 | 1523 | $splitSize = ceil(count($this->array) / $numberOfPieces); |
| 1524 | 1524 | $result = array_chunk($this->array, $splitSize, $keepKeys); |
| 1525 | 1525 | } |
@@ -1720,7 +1720,7 @@ discard block |
||
| 1720 | 1720 | public function has($key) |
| 1721 | 1721 | { |
| 1722 | 1722 | // Generate unique string to use as marker. |
| 1723 | - $unFound = (string)uniqid('arrayy', true); |
|
| 1723 | + $unFound = (string) uniqid('arrayy', true); |
|
| 1724 | 1724 | |
| 1725 | 1725 | return $this->get($key, $unFound) !== $unFound; |
| 1726 | 1726 | } |
@@ -2103,7 +2103,7 @@ discard block |
||
| 2103 | 2103 | */ |
| 2104 | 2104 | public function sorter($sorter = null, $direction = SORT_ASC, $strategy = SORT_REGULAR) |
| 2105 | 2105 | { |
| 2106 | - $array = (array)$this->array; |
|
| 2106 | + $array = (array) $this->array; |
|
| 2107 | 2107 | $direction = $this->getDirection($direction); |
| 2108 | 2108 | |
| 2109 | 2109 | // Transform all values into their results. |
@@ -2112,7 +2112,7 @@ discard block |
||
| 2112 | 2112 | |
| 2113 | 2113 | $that = $this; |
| 2114 | 2114 | $results = $arrayy->each( |
| 2115 | - function ($value) use ($sorter, $that) { |
|
| 2115 | + function($value) use ($sorter, $that) { |
|
| 2116 | 2116 | return is_callable($sorter) ? $sorter($value) : $that->get($sorter, null, $value); |
| 2117 | 2117 | } |
| 2118 | 2118 | ); |
@@ -2184,7 +2184,7 @@ discard block |
||
| 2184 | 2184 | { |
| 2185 | 2185 | $this->array = array_reduce( |
| 2186 | 2186 | $this->array, |
| 2187 | - function ($resultArray, $value) { |
|
| 2187 | + function($resultArray, $value) { |
|
| 2188 | 2188 | if (in_array($value, $resultArray, true) === false) { |
| 2189 | 2189 | $resultArray[] = $value; |
| 2190 | 2190 | } |