@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | * Get the first item from the collection passing the given truth test. |
360 | 360 | * |
361 | 361 | * @param callable|null $callback |
362 | - * @param mixed $default |
|
362 | + * @param stdClass $default |
|
363 | 363 | * @return mixed |
364 | 364 | */ |
365 | 365 | public function first(callable $callback = null, $default = null) |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | /** |
407 | 407 | * Get an item from the collection by key. |
408 | 408 | * |
409 | - * @param mixed $key |
|
409 | + * @param integer $key |
|
410 | 410 | * @param mixed $default |
411 | 411 | * @return mixed |
412 | 412 | */ |
@@ -784,7 +784,7 @@ discard block |
||
784 | 784 | /** |
785 | 785 | * Get and remove the last item from the collection. |
786 | 786 | * |
787 | - * @return mixed |
|
787 | + * @return string |
|
788 | 788 | */ |
789 | 789 | public function pop() |
790 | 790 | { |
@@ -80,10 +80,10 @@ discard block |
||
80 | 80 | { |
81 | 81 | $callback = $this->valueRetriever($callback); |
82 | 82 | |
83 | - $items = $this->map(function ($value) use ($callback) { |
|
83 | + $items = $this->map(function($value) use ($callback) { |
|
84 | 84 | return $callback($value); |
85 | - })->filter(function ($value) { |
|
86 | - return ! is_null($value); |
|
85 | + })->filter(function($value) { |
|
86 | + return !is_null($value); |
|
87 | 87 | }); |
88 | 88 | |
89 | 89 | if ($count = $items->count()) { |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | public function median($key = null) |
101 | 101 | { |
102 | 102 | $values = (isset($key) ? $this->pluck($key) : $this) |
103 | - ->filter(function ($item) { |
|
104 | - return ! is_null($item); |
|
103 | + ->filter(function($item) { |
|
104 | + return !is_null($item); |
|
105 | 105 | })->sort()->values(); |
106 | 106 | |
107 | 107 | $count = $values->count(); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | |
138 | 138 | $counts = new self; |
139 | 139 | |
140 | - $collection->each(function ($value) use ($counts) { |
|
140 | + $collection->each(function($value) use ($counts) { |
|
141 | 141 | $counts[$value] = isset($counts[$value]) ? $counts[$value] + 1 : 1; |
142 | 142 | }); |
143 | 143 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | $highestValue = $sorted->last(); |
147 | 147 | |
148 | - return $sorted->filter(function ($value) use ($highestValue) { |
|
148 | + return $sorted->filter(function($value) use ($highestValue) { |
|
149 | 149 | return $value == $highestValue; |
150 | 150 | })->sort()->keys()->all(); |
151 | 151 | } |
@@ -313,12 +313,12 @@ discard block |
||
313 | 313 | protected function duplicateComparator($strict) |
314 | 314 | { |
315 | 315 | if ($strict) { |
316 | - return function ($a, $b) { |
|
316 | + return function($a, $b) { |
|
317 | 317 | return $a === $b; |
318 | 318 | }; |
319 | 319 | } |
320 | 320 | |
321 | - return function ($a, $b) { |
|
321 | + return function($a, $b) { |
|
322 | 322 | return $a == $b; |
323 | 323 | }; |
324 | 324 | } |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | { |
334 | 334 | if ($keys instanceof Enumerable) { |
335 | 335 | $keys = $keys->all(); |
336 | - } elseif (! is_array($keys)) { |
|
336 | + } elseif (!is_array($keys)) { |
|
337 | 337 | $keys = func_get_args(); |
338 | 338 | } |
339 | 339 | |
@@ -441,14 +441,14 @@ discard block |
||
441 | 441 | foreach ($this->items as $key => $value) { |
442 | 442 | $groupKeys = $groupBy($value, $key); |
443 | 443 | |
444 | - if (! is_array($groupKeys)) { |
|
444 | + if (!is_array($groupKeys)) { |
|
445 | 445 | $groupKeys = [$groupKeys]; |
446 | 446 | } |
447 | 447 | |
448 | 448 | foreach ($groupKeys as $groupKey) { |
449 | 449 | $groupKey = is_bool($groupKey) ? (int) $groupKey : $groupKey; |
450 | 450 | |
451 | - if (! array_key_exists($groupKey, $results)) { |
|
451 | + if (!array_key_exists($groupKey, $results)) { |
|
452 | 452 | $results[$groupKey] = new static; |
453 | 453 | } |
454 | 454 | |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | |
459 | 459 | $result = new static($results); |
460 | 460 | |
461 | - if (! empty($nextGroups)) { |
|
461 | + if (!empty($nextGroups)) { |
|
462 | 462 | return $result->map->groupBy($nextGroups, $preserveKeys); |
463 | 463 | } |
464 | 464 | |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | $keys = is_array($key) ? $key : func_get_args(); |
502 | 502 | |
503 | 503 | foreach ($keys as $value) { |
504 | - if (! $this->offsetExists($value)) { |
|
504 | + if (!$this->offsetExists($value)) { |
|
505 | 505 | return false; |
506 | 506 | } |
507 | 507 | } |
@@ -659,7 +659,7 @@ discard block |
||
659 | 659 | |
660 | 660 | $value = reset($pair); |
661 | 661 | |
662 | - if (! isset($dictionary[$key])) { |
|
662 | + if (!isset($dictionary[$key])) { |
|
663 | 663 | $dictionary[$key] = []; |
664 | 664 | } |
665 | 665 | |
@@ -931,7 +931,7 @@ discard block |
||
931 | 931 | */ |
932 | 932 | public function search($value, $strict = false) |
933 | 933 | { |
934 | - if (! $this->useAsCallable($value)) { |
|
934 | + if (!$this->useAsCallable($value)) { |
|
935 | 935 | return array_search($value, $this->items, $strict); |
936 | 936 | } |
937 | 937 | |
@@ -1202,11 +1202,11 @@ discard block |
||
1202 | 1202 | */ |
1203 | 1203 | public function zip($items) |
1204 | 1204 | { |
1205 | - $arrayableItems = array_map(function ($items) { |
|
1205 | + $arrayableItems = array_map(function($items) { |
|
1206 | 1206 | return $this->getArrayableItems($items); |
1207 | 1207 | }, func_get_args()); |
1208 | 1208 | |
1209 | - $params = array_merge([function () { |
|
1209 | + $params = array_merge([function() { |
|
1210 | 1210 | return new static(func_get_args()); |
1211 | 1211 | }, $this->items], $arrayableItems); |
1212 | 1212 |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * Get the first item from the enumerable passing the given truth test. |
323 | 323 | * |
324 | 324 | * @param callable|null $callback |
325 | - * @param mixed $default |
|
325 | + * @param stdClass $default |
|
326 | 326 | * @return mixed |
327 | 327 | */ |
328 | 328 | public function first(callable $callback = null, $default = null) |
@@ -1187,7 +1187,7 @@ discard block |
||
1187 | 1187 | * Explode the "value" and "key" arguments passed to "pluck". |
1188 | 1188 | * |
1189 | 1189 | * @param string|array $value |
1190 | - * @param string|array|null $key |
|
1190 | + * @param string|null $key |
|
1191 | 1191 | * @return array |
1192 | 1192 | */ |
1193 | 1193 | protected function explodePluckParameters($value, $key) |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | return new static; |
61 | 61 | } |
62 | 62 | |
63 | - $instance = new static(function () use ($number) { |
|
63 | + $instance = new static(function() use ($number) { |
|
64 | 64 | for ($current = 1; $current <= $number; $current++) { |
65 | 65 | yield $current; |
66 | 66 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public static function range($from, $to) |
80 | 80 | { |
81 | - return new static(function () use ($from, $to) { |
|
81 | + return new static(function() use ($from, $to) { |
|
82 | 82 | for (; $from <= $to; $from++) { |
83 | 83 | yield $from; |
84 | 84 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function collapse() |
141 | 141 | { |
142 | - return new static(function () { |
|
142 | + return new static(function() { |
|
143 | 143 | foreach ($this as $values) { |
144 | 144 | if (is_array($values) || $values instanceof Enumerable) { |
145 | 145 | foreach ($values as $value) { |
@@ -304,12 +304,12 @@ discard block |
||
304 | 304 | public function filter(callable $callback = null) |
305 | 305 | { |
306 | 306 | if (is_null($callback)) { |
307 | - $callback = function ($value) { |
|
307 | + $callback = function($value) { |
|
308 | 308 | return (bool) $value; |
309 | 309 | }; |
310 | 310 | } |
311 | 311 | |
312 | - return new static(function () use ($callback) { |
|
312 | + return new static(function() use ($callback) { |
|
313 | 313 | foreach ($this as $key => $value) { |
314 | 314 | if ($callback($value, $key)) { |
315 | 315 | yield $key => $value; |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | $iterator = $this->getIterator(); |
331 | 331 | |
332 | 332 | if (is_null($callback)) { |
333 | - if (! $iterator->valid()) { |
|
333 | + if (!$iterator->valid()) { |
|
334 | 334 | return value($default); |
335 | 335 | } |
336 | 336 | |
@@ -354,9 +354,9 @@ discard block |
||
354 | 354 | */ |
355 | 355 | public function flatten($depth = INF) |
356 | 356 | { |
357 | - $instance = new static(function () use ($depth) { |
|
357 | + $instance = new static(function() use ($depth) { |
|
358 | 358 | foreach ($this as $item) { |
359 | - if (! is_array($item) && ! $item instanceof Enumerable) { |
|
359 | + if (!is_array($item) && !$item instanceof Enumerable) { |
|
360 | 360 | yield $item; |
361 | 361 | } elseif ($depth === 1) { |
362 | 362 | yield from $item; |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | */ |
377 | 377 | public function flip() |
378 | 378 | { |
379 | - return new static(function () { |
|
379 | + return new static(function() { |
|
380 | 380 | foreach ($this as $key => $value) { |
381 | 381 | yield $value => $key; |
382 | 382 | } |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | */ |
426 | 426 | public function keyBy($keyBy) |
427 | 427 | { |
428 | - return new static(function () use ($keyBy) { |
|
428 | + return new static(function() use ($keyBy) { |
|
429 | 429 | $keyBy = $this->valueRetriever($keyBy); |
430 | 430 | |
431 | 431 | foreach ($this as $key => $item) { |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | */ |
502 | 502 | public function isEmpty() |
503 | 503 | { |
504 | - return ! $this->getIterator()->valid(); |
|
504 | + return !$this->getIterator()->valid(); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | /** |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | */ |
524 | 524 | public function keys() |
525 | 525 | { |
526 | - return new static(function () { |
|
526 | + return new static(function() { |
|
527 | 527 | foreach ($this as $key => $value) { |
528 | 528 | yield $key; |
529 | 529 | } |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | */ |
560 | 560 | public function pluck($value, $key = null) |
561 | 561 | { |
562 | - return new static(function () use ($value, $key) { |
|
562 | + return new static(function() use ($value, $key) { |
|
563 | 563 | [$value, $key] = $this->explodePluckParameters($value, $key); |
564 | 564 | |
565 | 565 | foreach ($this as $item) { |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | */ |
589 | 589 | public function map(callable $callback) |
590 | 590 | { |
591 | - return new static(function () use ($callback) { |
|
591 | + return new static(function() use ($callback) { |
|
592 | 592 | foreach ($this as $key => $value) { |
593 | 593 | yield $key => $callback($value, $key); |
594 | 594 | } |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | */ |
619 | 619 | public function mapWithKeys(callable $callback) |
620 | 620 | { |
621 | - return new static(function () use ($callback) { |
|
621 | + return new static(function() use ($callback) { |
|
622 | 622 | foreach ($this as $key => $value) { |
623 | 623 | yield from $callback($value, $key); |
624 | 624 | } |
@@ -655,13 +655,13 @@ discard block |
||
655 | 655 | */ |
656 | 656 | public function combine($values) |
657 | 657 | { |
658 | - return new static(function () use ($values) { |
|
658 | + return new static(function() use ($values) { |
|
659 | 659 | $values = $this->makeIterator($values); |
660 | 660 | |
661 | 661 | $errorMessage = 'Both parameters should have an equal number of elements'; |
662 | 662 | |
663 | 663 | foreach ($this as $key) { |
664 | - if (! $values->valid()) { |
|
664 | + if (!$values->valid()) { |
|
665 | 665 | trigger_error($errorMessage, E_USER_WARNING); |
666 | 666 | |
667 | 667 | break; |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | */ |
699 | 699 | public function nth($step, $offset = 0) |
700 | 700 | { |
701 | - return new static(function () use ($step, $offset) { |
|
701 | + return new static(function() use ($step, $offset) { |
|
702 | 702 | $position = 0; |
703 | 703 | |
704 | 704 | foreach ($this as $item) { |
@@ -721,11 +721,11 @@ discard block |
||
721 | 721 | { |
722 | 722 | if ($keys instanceof Enumerable) { |
723 | 723 | $keys = $keys->all(); |
724 | - } elseif (! is_null($keys)) { |
|
724 | + } elseif (!is_null($keys)) { |
|
725 | 725 | $keys = is_array($keys) ? $keys : func_get_args(); |
726 | 726 | } |
727 | 727 | |
728 | - return new static(function () use ($keys) { |
|
728 | + return new static(function() use ($keys) { |
|
729 | 729 | if (is_null($keys)) { |
730 | 730 | yield from $this; |
731 | 731 | } else { |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | */ |
755 | 755 | public function concat($source) |
756 | 756 | { |
757 | - return (new static(function () use ($source) { |
|
757 | + return (new static(function() use ($source) { |
|
758 | 758 | yield from $this; |
759 | 759 | yield from $source; |
760 | 760 | }))->values(); |
@@ -801,7 +801,7 @@ discard block |
||
801 | 801 | */ |
802 | 802 | public function replace($items) |
803 | 803 | { |
804 | - return new static(function () use ($items) { |
|
804 | + return new static(function() use ($items) { |
|
805 | 805 | $items = $this->getArrayableItems($items); |
806 | 806 | |
807 | 807 | foreach ($this as $key => $value) { |
@@ -852,7 +852,7 @@ discard block |
||
852 | 852 | { |
853 | 853 | $predicate = $this->useAsCallable($value) |
854 | 854 | ? $value |
855 | - : function ($item) use ($value, $strict) { |
|
855 | + : function($item) use ($value, $strict) { |
|
856 | 856 | return $strict ? $item === $value : $item == $value; |
857 | 857 | }; |
858 | 858 | |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | */ |
885 | 885 | public function skip($count) |
886 | 886 | { |
887 | - return new static(function () use ($count) { |
|
887 | + return new static(function() use ($count) { |
|
888 | 888 | $iterator = $this->getIterator(); |
889 | 889 | |
890 | 890 | while ($iterator->valid() && $count--) { |
@@ -940,7 +940,7 @@ discard block |
||
940 | 940 | return static::empty(); |
941 | 941 | } |
942 | 942 | |
943 | - return new static(function () use ($size) { |
|
943 | + return new static(function() use ($size) { |
|
944 | 944 | $iterator = $this->getIterator(); |
945 | 945 | |
946 | 946 | while ($iterator->valid()) { |
@@ -952,7 +952,7 @@ discard block |
||
952 | 952 | if (count($chunk) < $size) { |
953 | 953 | $iterator->next(); |
954 | 954 | |
955 | - if (! $iterator->valid()) { |
|
955 | + if (!$iterator->valid()) { |
|
956 | 956 | break; |
957 | 957 | } |
958 | 958 | } else { |
@@ -1038,11 +1038,11 @@ discard block |
||
1038 | 1038 | return $this->passthru('take', func_get_args()); |
1039 | 1039 | } |
1040 | 1040 | |
1041 | - return new static(function () use ($limit) { |
|
1041 | + return new static(function() use ($limit) { |
|
1042 | 1042 | $iterator = $this->getIterator(); |
1043 | 1043 | |
1044 | 1044 | while ($limit--) { |
1045 | - if (! $iterator->valid()) { |
|
1045 | + if (!$iterator->valid()) { |
|
1046 | 1046 | break; |
1047 | 1047 | } |
1048 | 1048 | |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | */ |
1064 | 1064 | public function tapEach(callable $callback) |
1065 | 1065 | { |
1066 | - return new static(function () use ($callback) { |
|
1066 | + return new static(function() use ($callback) { |
|
1067 | 1067 | foreach ($this as $key => $value) { |
1068 | 1068 | $callback($value, $key); |
1069 | 1069 | |
@@ -1079,7 +1079,7 @@ discard block |
||
1079 | 1079 | */ |
1080 | 1080 | public function values() |
1081 | 1081 | { |
1082 | - return new static(function () { |
|
1082 | + return new static(function() { |
|
1083 | 1083 | foreach ($this as $item) { |
1084 | 1084 | yield $item; |
1085 | 1085 | } |
@@ -1099,8 +1099,8 @@ discard block |
||
1099 | 1099 | { |
1100 | 1100 | $iterables = func_get_args(); |
1101 | 1101 | |
1102 | - return new static(function () use ($iterables) { |
|
1103 | - $iterators = Collection::make($iterables)->map(function ($iterable) { |
|
1102 | + return new static(function() use ($iterables) { |
|
1103 | + $iterators = Collection::make($iterables)->map(function($iterable) { |
|
1104 | 1104 | return $this->makeIterator($iterable); |
1105 | 1105 | })->prepend($this->getIterator()); |
1106 | 1106 | |
@@ -1125,7 +1125,7 @@ discard block |
||
1125 | 1125 | return $this->passthru('pad', func_get_args()); |
1126 | 1126 | } |
1127 | 1127 | |
1128 | - return new static(function () use ($size, $value) { |
|
1128 | + return new static(function() use ($size, $value) { |
|
1129 | 1129 | $yielded = 0; |
1130 | 1130 | |
1131 | 1131 | foreach ($this as $index => $item) { |
@@ -1208,7 +1208,7 @@ discard block |
||
1208 | 1208 | */ |
1209 | 1209 | protected function passthru($method, array $params) |
1210 | 1210 | { |
1211 | - return new static(function () use ($method, $params) { |
|
1211 | + return new static(function() use ($method, $params) { |
|
1212 | 1212 | yield from $this->collect()->$method(...$params); |
1213 | 1213 | }); |
1214 | 1214 | } |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | * Filter items by the given key value pair. |
484 | 484 | * |
485 | 485 | * @param string $key |
486 | - * @param mixed $operator |
|
486 | + * @param string $operator |
|
487 | 487 | * @param mixed $value |
488 | 488 | * @return static |
489 | 489 | */ |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | /** |
629 | 629 | * Create a collection of all elements that do not pass a given truth test. |
630 | 630 | * |
631 | - * @param callable|mixed $callback |
|
631 | + * @param \Closure $callback |
|
632 | 632 | * @return static |
633 | 633 | */ |
634 | 634 | public function reject($callback = true) |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | * Dynamically access collection proxies. |
784 | 784 | * |
785 | 785 | * @param string $key |
786 | - * @return mixed |
|
786 | + * @return HigherOrderCollectionProxy |
|
787 | 787 | * |
788 | 788 | * @throws \Exception |
789 | 789 | */ |
@@ -117,13 +117,13 @@ discard block |
||
117 | 117 | public function containsStrict($key, $value = null) |
118 | 118 | { |
119 | 119 | if (func_num_args() === 2) { |
120 | - return $this->contains(function ($item) use ($key, $value) { |
|
120 | + return $this->contains(function($item) use ($key, $value) { |
|
121 | 121 | return data_get($item, $key) === $value; |
122 | 122 | }); |
123 | 123 | } |
124 | 124 | |
125 | 125 | if ($this->useAsCallable($key)) { |
126 | - return ! is_null($this->first($key)); |
|
126 | + return !is_null($this->first($key)); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | foreach ($this as $item) { |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | { |
158 | 158 | (new static(func_get_args())) |
159 | 159 | ->push($this) |
160 | - ->each(function ($item) { |
|
160 | + ->each(function($item) { |
|
161 | 161 | VarDumper::dump($item); |
162 | 162 | }); |
163 | 163 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | */ |
190 | 190 | public function eachSpread(callable $callback) |
191 | 191 | { |
192 | - return $this->each(function ($chunk, $key) use ($callback) { |
|
192 | + return $this->each(function($chunk, $key) use ($callback) { |
|
193 | 193 | $chunk[] = $key; |
194 | 194 | |
195 | 195 | return $callback(...$chunk); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $callback = $this->valueRetriever($key); |
211 | 211 | |
212 | 212 | foreach ($this as $k => $v) { |
213 | - if (! $callback($v, $k)) { |
|
213 | + if (!$callback($v, $k)) { |
|
214 | 214 | return false; |
215 | 215 | } |
216 | 216 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function isNotEmpty() |
243 | 243 | { |
244 | - return ! $this->isEmpty(); |
|
244 | + return !$this->isEmpty(); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | */ |
253 | 253 | public function mapSpread(callable $callback) |
254 | 254 | { |
255 | - return $this->map(function ($chunk, $key) use ($callback) { |
|
255 | + return $this->map(function($chunk, $key) use ($callback) { |
|
256 | 256 | $chunk[] = $key; |
257 | 257 | |
258 | 258 | return $callback(...$chunk); |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | */ |
294 | 294 | public function mapInto($class) |
295 | 295 | { |
296 | - return $this->map(function ($value, $key) use ($class) { |
|
296 | + return $this->map(function($value, $key) use ($class) { |
|
297 | 297 | return new $class($value, $key); |
298 | 298 | }); |
299 | 299 | } |
@@ -308,11 +308,11 @@ discard block |
||
308 | 308 | { |
309 | 309 | $callback = $this->valueRetriever($callback); |
310 | 310 | |
311 | - return $this->map(function ($value) use ($callback) { |
|
311 | + return $this->map(function($value) use ($callback) { |
|
312 | 312 | return $callback($value); |
313 | - })->filter(function ($value) { |
|
314 | - return ! is_null($value); |
|
315 | - })->reduce(function ($result, $value) { |
|
313 | + })->filter(function($value) { |
|
314 | + return !is_null($value); |
|
315 | + })->reduce(function($result, $value) { |
|
316 | 316 | return is_null($result) || $value < $result ? $value : $result; |
317 | 317 | }); |
318 | 318 | } |
@@ -327,9 +327,9 @@ discard block |
||
327 | 327 | { |
328 | 328 | $callback = $this->valueRetriever($callback); |
329 | 329 | |
330 | - return $this->filter(function ($value) { |
|
331 | - return ! is_null($value); |
|
332 | - })->reduce(function ($result, $item) use ($callback) { |
|
330 | + return $this->filter(function($value) { |
|
331 | + return !is_null($value); |
|
332 | + })->reduce(function($result, $item) use ($callback) { |
|
333 | 333 | $value = $callback($item); |
334 | 334 | |
335 | 335 | return is_null($result) || $value > $result ? $value : $result; |
@@ -387,14 +387,14 @@ discard block |
||
387 | 387 | public function sum($callback = null) |
388 | 388 | { |
389 | 389 | if (is_null($callback)) { |
390 | - $callback = function ($value) { |
|
390 | + $callback = function($value) { |
|
391 | 391 | return $value; |
392 | 392 | }; |
393 | 393 | } else { |
394 | 394 | $callback = $this->valueRetriever($callback); |
395 | 395 | } |
396 | 396 | |
397 | - return $this->reduce(function ($result, $item) use ($callback) { |
|
397 | + return $this->reduce(function($result, $item) use ($callback) { |
|
398 | 398 | return $result + $callback($item); |
399 | 399 | }, 0); |
400 | 400 | } |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | */ |
453 | 453 | public function unless($value, callable $callback, callable $default = null) |
454 | 454 | { |
455 | - return $this->when(! $value, $callback, $default); |
|
455 | + return $this->when(!$value, $callback, $default); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | /** |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | { |
517 | 517 | $values = $this->getArrayableItems($values); |
518 | 518 | |
519 | - return $this->filter(function ($item) use ($key, $values, $strict) { |
|
519 | + return $this->filter(function($item) use ($key, $values, $strict) { |
|
520 | 520 | return in_array(data_get($item, $key), $values, $strict); |
521 | 521 | }); |
522 | 522 | } |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | */ |
555 | 555 | public function whereNotBetween($key, $values) |
556 | 556 | { |
557 | - return $this->filter(function ($item) use ($key, $values) { |
|
557 | + return $this->filter(function($item) use ($key, $values) { |
|
558 | 558 | return data_get($item, $key) < reset($values) || data_get($item, $key) > end($values); |
559 | 559 | }); |
560 | 560 | } |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | { |
572 | 572 | $values = $this->getArrayableItems($values); |
573 | 573 | |
574 | - return $this->reject(function ($item) use ($key, $values, $strict) { |
|
574 | + return $this->reject(function($item) use ($key, $values, $strict) { |
|
575 | 575 | return in_array(data_get($item, $key), $values, $strict); |
576 | 576 | }); |
577 | 577 | } |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | */ |
597 | 597 | public function whereInstanceOf($type) |
598 | 598 | { |
599 | - return $this->filter(function ($value) use ($type) { |
|
599 | + return $this->filter(function($value) use ($type) { |
|
600 | 600 | return $value instanceof $type; |
601 | 601 | }); |
602 | 602 | } |
@@ -635,9 +635,9 @@ discard block |
||
635 | 635 | { |
636 | 636 | $useAsCallable = $this->useAsCallable($callback); |
637 | 637 | |
638 | - return $this->filter(function ($value, $key) use ($callback, $useAsCallable) { |
|
638 | + return $this->filter(function($value, $key) use ($callback, $useAsCallable) { |
|
639 | 639 | return $useAsCallable |
640 | - ? ! $callback($value, $key) |
|
640 | + ? !$callback($value, $key) |
|
641 | 641 | : $value != $callback; |
642 | 642 | }); |
643 | 643 | } |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | |
656 | 656 | $exists = []; |
657 | 657 | |
658 | - return $this->reject(function ($item, $key) use ($callback, $strict, &$exists) { |
|
658 | + return $this->reject(function($item, $key) use ($callback, $strict, &$exists) { |
|
659 | 659 | if (in_array($id = $callback($item, $key), $exists, $strict)) { |
660 | 660 | return true; |
661 | 661 | } |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | */ |
693 | 693 | public function toArray() |
694 | 694 | { |
695 | - return $this->map(function ($value) { |
|
695 | + return $this->map(function($value) { |
|
696 | 696 | return $value instanceof Arrayable ? $value->toArray() : $value; |
697 | 697 | })->all(); |
698 | 698 | } |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | */ |
705 | 705 | public function jsonSerialize() |
706 | 706 | { |
707 | - return array_map(function ($value) { |
|
707 | + return array_map(function($value) { |
|
708 | 708 | if ($value instanceof JsonSerializable) { |
709 | 709 | return $value->jsonSerialize(); |
710 | 710 | } elseif ($value instanceof Jsonable) { |
@@ -748,12 +748,12 @@ discard block |
||
748 | 748 | public function countBy($callback = null) |
749 | 749 | { |
750 | 750 | if (is_null($callback)) { |
751 | - $callback = function ($value) { |
|
751 | + $callback = function($value) { |
|
752 | 752 | return $value; |
753 | 753 | }; |
754 | 754 | } |
755 | 755 | |
756 | - return new static($this->groupBy($callback)->map(function ($value) { |
|
756 | + return new static($this->groupBy($callback)->map(function($value) { |
|
757 | 757 | return $value->count(); |
758 | 758 | })); |
759 | 759 | } |
@@ -789,7 +789,7 @@ discard block |
||
789 | 789 | */ |
790 | 790 | public function __get($key) |
791 | 791 | { |
792 | - if (! in_array($key, static::$proxies)) { |
|
792 | + if (!in_array($key, static::$proxies)) { |
|
793 | 793 | throw new Exception("Property [{$key}] does not exist on this collection instance."); |
794 | 794 | } |
795 | 795 | |
@@ -843,10 +843,10 @@ discard block |
||
843 | 843 | $operator = '='; |
844 | 844 | } |
845 | 845 | |
846 | - return function ($item) use ($key, $operator, $value) { |
|
846 | + return function($item) use ($key, $operator, $value) { |
|
847 | 847 | $retrieved = data_get($item, $key); |
848 | 848 | |
849 | - $strings = array_filter([$retrieved, $value], function ($value) { |
|
849 | + $strings = array_filter([$retrieved, $value], function($value) { |
|
850 | 850 | return is_string($value) || (is_object($value) && method_exists($value, '__toString')); |
851 | 851 | }); |
852 | 852 | |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | */ |
879 | 879 | protected function useAsCallable($value) |
880 | 880 | { |
881 | - return ! is_string($value) && is_callable($value); |
|
881 | + return !is_string($value) && is_callable($value); |
|
882 | 882 | } |
883 | 883 | |
884 | 884 | /** |
@@ -893,7 +893,7 @@ discard block |
||
893 | 893 | return $value; |
894 | 894 | } |
895 | 895 | |
896 | - return function ($item) use ($value) { |
|
896 | + return function($item) use ($value) { |
|
897 | 897 | return data_get($item, $value); |
898 | 898 | }; |
899 | 899 | } |