@@ -94,7 +94,7 @@ |
||
| 94 | 94 | * Determine if a given string contains a given substring. |
| 95 | 95 | * |
| 96 | 96 | * @param string $haystack |
| 97 | - * @param string|array $needles |
|
| 97 | + * @param string $needles |
|
| 98 | 98 | * @return bool |
| 99 | 99 | */ |
| 100 | 100 | public static function contains($haystack, $needles) |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | $languageSpecific = static::languageSpecificCharsArray($language); |
| 54 | 54 | |
| 55 | - if (! is_null($languageSpecific)) { |
|
| 55 | + if (!is_null($languageSpecific)) { |
|
| 56 | 56 | $value = str_replace($languageSpecific[0], $languageSpecific[1], $value); |
| 57 | 57 | } |
| 58 | 58 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | { |
| 246 | 246 | preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $value, $matches); |
| 247 | 247 | |
| 248 | - if (! isset($matches[0]) || static::length($value) === static::length($matches[0])) { |
|
| 248 | + if (!isset($matches[0]) || static::length($value) === static::length($matches[0])) { |
|
| 249 | 249 | return $value; |
| 250 | 250 | } |
| 251 | 251 | |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | return static::$snakeCache[$key][$delimiter]; |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - if (! ctype_lower($value)) { |
|
| 450 | + if (!ctype_lower($value)) { |
|
| 451 | 451 | $value = preg_replace('/\s+/u', '', ucwords($value)); |
| 452 | 452 | |
| 453 | 453 | $value = static::lower(preg_replace('/(.)(?=[A-Z])/u', '$1'.$delimiter, $value)); |
@@ -665,14 +665,14 @@ discard block |
||
| 665 | 665 | { |
| 666 | 666 | static $languageSpecific; |
| 667 | 667 | |
| 668 | - if (! isset($languageSpecific)) { |
|
| 668 | + if (!isset($languageSpecific)) { |
|
| 669 | 669 | $languageSpecific = [ |
| 670 | 670 | 'bg' => [ |
| 671 | 671 | ['х', 'Х', 'щ', 'Щ', 'ъ', 'Ъ', 'ь', 'Ь'], |
| 672 | 672 | ['h', 'H', 'sht', 'SHT', 'a', 'А', 'y', 'Y'], |
| 673 | 673 | ], |
| 674 | 674 | 'de' => [ |
| 675 | - ['ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü'], |
|
| 675 | + ['ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü'], |
|
| 676 | 676 | ['ae', 'oe', 'ue', 'AE', 'OE', 'UE'], |
| 677 | 677 | ], |
| 678 | 678 | ]; |
@@ -2,11 +2,11 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace IlluminateAgnostic\Collection\Support; |
| 4 | 4 | |
| 5 | -use Ramsey\Uuid\Uuid; |
|
| 6 | -use Ramsey\Uuid\UuidFactory; |
|
| 7 | 5 | use IlluminateAgnostic\Collection\Support\Traits\Macroable; |
| 8 | -use Ramsey\Uuid\Generator\CombGenerator; |
|
| 9 | 6 | use Ramsey\Uuid\Codec\TimestampFirstCombCodec; |
| 7 | +use Ramsey\Uuid\Generator\CombGenerator; |
|
| 8 | +use Ramsey\Uuid\Uuid; |
|
| 9 | +use Ramsey\Uuid\UuidFactory; |
|
| 10 | 10 | |
| 11 | 11 | class Str |
| 12 | 12 | { |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public function __get($key) |
| 44 | 44 | { |
| 45 | - return $this->collection->{$this->method}(function ($value) use ($key) { |
|
| 45 | + return $this->collection->{$this->method}(function($value) use ($key) { |
|
| 46 | 46 | return is_array($value) ? $value[$key] : $value->{$key}; |
| 47 | 47 | }); |
| 48 | 48 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public function __call($method, $parameters) |
| 58 | 58 | { |
| 59 | - return $this->collection->{$this->method}(function ($value) use ($method, $parameters) { |
|
| 59 | + return $this->collection->{$this->method}(function($value) use ($method, $parameters) { |
|
| 60 | 60 | return $value->{$method}(...$parameters); |
| 61 | 61 | }); |
| 62 | 62 | } |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | ]; |
| 15 | 15 | |
| 16 | 16 | foreach ($aliases as $illuminate => $tighten) { |
| 17 | - if (class_exists($illuminate) && ! interface_exists($illuminate) && ! trait_exists($illuminate)) { |
|
| 17 | + if (class_exists($illuminate) && !interface_exists($illuminate) && !trait_exists($illuminate)) { |
|
| 18 | 18 | class_alias($illuminate, $tighten); |
| 19 | 19 | } |
| 20 | 20 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | use IlluminateAgnostic\Collection\Support\Debug\Dumper; |
| 7 | 7 | use Illuminate\Support\Collection as IlluminateCollection; |
| 8 | 8 | |
| 9 | -if (! function_exists('collect')) { |
|
| 9 | +if (!function_exists('collect')) { |
|
| 10 | 10 | /** |
| 11 | 11 | * Create a collection from the given value. |
| 12 | 12 | * |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | } |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | -if (! function_exists('value')) { |
|
| 22 | +if (!function_exists('value')) { |
|
| 23 | 23 | /** |
| 24 | 24 | * Return the default value of the given value. |
| 25 | 25 | * |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | -if (! function_exists('data_get')) { |
|
| 35 | +if (!function_exists('data_get')) { |
|
| 36 | 36 | /** |
| 37 | 37 | * Get an item from an array or object using "dot" notation. |
| 38 | 38 | * |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | $key = is_array($key) ? $key : explode('.', $key); |
| 51 | 51 | |
| 52 | - while (! is_null($segment = array_shift($key))) { |
|
| 52 | + while (!is_null($segment = array_shift($key))) { |
|
| 53 | 53 | if ($segment === '*') { |
| 54 | 54 | if ($target instanceof Collection) { |
| 55 | 55 | $target = $target->all(); |
| 56 | - } elseif (! is_array($target)) { |
|
| 56 | + } elseif (!is_array($target)) { |
|
| 57 | 57 | return value($default); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | |
| 79 | -if (! function_exists('with')) { |
|
| 79 | +if (!function_exists('with')) { |
|
| 80 | 80 | /** |
| 81 | 81 | * Return the given object. Useful for chaining. |
| 82 | 82 | * |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | -if (! function_exists('dd')) { |
|
| 92 | +if (!function_exists('dd')) { |
|
| 93 | 93 | /** |
| 94 | 94 | * Dump the passed variables and end the script. |
| 95 | 95 | * |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | -if (! function_exists('studly_case')) { |
|
| 108 | +if (!function_exists('studly_case')) { |
|
| 109 | 109 | /** |
| 110 | 110 | * Convert a value to studly caps case. |
| 111 | 111 | * |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | /** |
| 210 | 210 | * Determine if an item exists in the collection. |
| 211 | 211 | * |
| 212 | - * @param mixed $key |
|
| 212 | + * @param \Closure $key |
|
| 213 | 213 | * @param mixed $operator |
| 214 | 214 | * @param mixed $value |
| 215 | 215 | * @return bool |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | * Filter items by the given key value pair. |
| 453 | 453 | * |
| 454 | 454 | * @param string $key |
| 455 | - * @param mixed $operator |
|
| 455 | + * @param string $operator |
|
| 456 | 456 | * @param mixed $value |
| 457 | 457 | * @return static |
| 458 | 458 | */ |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | * Get the first item from the collection. |
| 579 | 579 | * |
| 580 | 580 | * @param callable|null $callback |
| 581 | - * @param mixed $default |
|
| 581 | + * @param stdClass $default |
|
| 582 | 582 | * @return mixed |
| 583 | 583 | */ |
| 584 | 584 | public function first(callable $callback = null, $default = null) |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | /** |
| 639 | 639 | * Get an item from the collection by key. |
| 640 | 640 | * |
| 641 | - * @param mixed $key |
|
| 641 | + * @param integer $key |
|
| 642 | 642 | * @param mixed $default |
| 643 | 643 | * @return mixed |
| 644 | 644 | */ |
@@ -1234,7 +1234,7 @@ discard block |
||
| 1234 | 1234 | * Reduce the collection to a single value. |
| 1235 | 1235 | * |
| 1236 | 1236 | * @param callable $callback |
| 1237 | - * @param mixed $initial |
|
| 1237 | + * @param integer $initial |
|
| 1238 | 1238 | * @return mixed |
| 1239 | 1239 | */ |
| 1240 | 1240 | public function reduce(callable $callback, $initial = null) |
@@ -1245,7 +1245,7 @@ discard block |
||
| 1245 | 1245 | /** |
| 1246 | 1246 | * Create a collection of all elements that do not pass a given truth test. |
| 1247 | 1247 | * |
| 1248 | - * @param callable|mixed $callback |
|
| 1248 | + * @param \Closure $callback |
|
| 1249 | 1249 | * @return static |
| 1250 | 1250 | */ |
| 1251 | 1251 | public function reject($callback) |
@@ -1793,7 +1793,7 @@ discard block |
||
| 1793 | 1793 | * Dynamically access collection proxies. |
| 1794 | 1794 | * |
| 1795 | 1795 | * @param string $key |
| 1796 | - * @return mixed |
|
| 1796 | + * @return HigherOrderCollectionProxy |
|
| 1797 | 1797 | * |
| 1798 | 1798 | * @throws \Exception |
| 1799 | 1799 | */ |
@@ -2,19 +2,19 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace IlluminateAgnostic\Collection\Support; |
| 4 | 4 | |
| 5 | -use stdClass; |
|
| 6 | -use Countable; |
|
| 7 | -use Exception; |
|
| 8 | 5 | use ArrayAccess; |
| 9 | -use Traversable; |
|
| 10 | 6 | use ArrayIterator; |
| 11 | 7 | use CachingIterator; |
| 12 | -use JsonSerializable; |
|
| 13 | -use IteratorAggregate; |
|
| 14 | -use IlluminateAgnostic\Collection\Support\Traits\Macroable; |
|
| 8 | +use Countable; |
|
| 9 | +use Exception; |
|
| 10 | +use IlluminateAgnostic\Collection\Contracts\Support\Arrayable; |
|
| 15 | 11 | use IlluminateAgnostic\Collection\Contracts\Support\Jsonable; |
| 12 | +use IlluminateAgnostic\Collection\Support\Traits\Macroable; |
|
| 13 | +use IteratorAggregate; |
|
| 14 | +use JsonSerializable; |
|
| 16 | 15 | use Symfony\Component\VarDumper\VarDumper; |
| 17 | -use IlluminateAgnostic\Collection\Contracts\Support\Arrayable; |
|
| 16 | +use Traversable; |
|
| 17 | +use stdClass; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * @property-read HigherOrderCollectionProxy $average |
@@ -147,10 +147,10 @@ discard block |
||
| 147 | 147 | { |
| 148 | 148 | $callback = $this->valueRetriever($callback); |
| 149 | 149 | |
| 150 | - $items = $this->map(function ($value) use ($callback) { |
|
| 150 | + $items = $this->map(function($value) use ($callback) { |
|
| 151 | 151 | return $callback($value); |
| 152 | - })->filter(function ($value) { |
|
| 153 | - return ! is_null($value); |
|
| 152 | + })->filter(function($value) { |
|
| 153 | + return !is_null($value); |
|
| 154 | 154 | }); |
| 155 | 155 | |
| 156 | 156 | if ($count = $items->count()) { |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | public function median($key = null) |
| 179 | 179 | { |
| 180 | 180 | $values = (isset($key) ? $this->pluck($key) : $this) |
| 181 | - ->filter(function ($item) { |
|
| 182 | - return ! is_null($item); |
|
| 181 | + ->filter(function($item) { |
|
| 182 | + return !is_null($item); |
|
| 183 | 183 | })->sort()->values(); |
| 184 | 184 | |
| 185 | 185 | $count = $values->count(); |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | |
| 218 | 218 | $counts = new self; |
| 219 | 219 | |
| 220 | - $collection->each(function ($value) use ($counts) { |
|
| 220 | + $collection->each(function($value) use ($counts) { |
|
| 221 | 221 | $counts[$value] = isset($counts[$value]) ? $counts[$value] + 1 : 1; |
| 222 | 222 | }); |
| 223 | 223 | |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | |
| 226 | 226 | $highestValue = $sorted->last(); |
| 227 | 227 | |
| 228 | - return $sorted->filter(function ($value) use ($highestValue) { |
|
| 228 | + return $sorted->filter(function($value) use ($highestValue) { |
|
| 229 | 229 | return $value == $highestValue; |
| 230 | 230 | })->sort()->keys()->all(); |
| 231 | 231 | } |
@@ -273,13 +273,13 @@ discard block |
||
| 273 | 273 | public function containsStrict($key, $value = null) |
| 274 | 274 | { |
| 275 | 275 | if (func_num_args() === 2) { |
| 276 | - return $this->contains(function ($item) use ($key, $value) { |
|
| 276 | + return $this->contains(function($item) use ($key, $value) { |
|
| 277 | 277 | return data_get($item, $key) === $value; |
| 278 | 278 | }); |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | if ($this->useAsCallable($key)) { |
| 282 | - return ! is_null($this->first($key)); |
|
| 282 | + return !is_null($this->first($key)); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | return in_array($key, $this->items, true); |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | { |
| 320 | 320 | (new static(func_get_args())) |
| 321 | 321 | ->push($this) |
| 322 | - ->each(function ($item) { |
|
| 322 | + ->each(function($item) { |
|
| 323 | 323 | VarDumper::dump($item); |
| 324 | 324 | }); |
| 325 | 325 | |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | */ |
| 421 | 421 | public function eachSpread(callable $callback) |
| 422 | 422 | { |
| 423 | - return $this->each(function ($chunk, $key) use ($callback) { |
|
| 423 | + return $this->each(function($chunk, $key) use ($callback) { |
|
| 424 | 424 | $chunk[] = $key; |
| 425 | 425 | |
| 426 | 426 | return $callback(...$chunk); |
@@ -441,7 +441,7 @@ discard block |
||
| 441 | 441 | $callback = $this->valueRetriever($key); |
| 442 | 442 | |
| 443 | 443 | foreach ($this->items as $k => $v) { |
| 444 | - if (! $callback($v, $k)) { |
|
| 444 | + if (!$callback($v, $k)) { |
|
| 445 | 445 | return false; |
| 446 | 446 | } |
| 447 | 447 | } |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | { |
| 463 | 463 | if ($keys instanceof self) { |
| 464 | 464 | $keys = $keys->all(); |
| 465 | - } elseif (! is_array($keys)) { |
|
| 465 | + } elseif (!is_array($keys)) { |
|
| 466 | 466 | $keys = func_get_args(); |
| 467 | 467 | } |
| 468 | 468 | |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | */ |
| 514 | 514 | public function unless($value, callable $callback, callable $default = null) |
| 515 | 515 | { |
| 516 | - return $this->when(! $value, $callback, $default); |
|
| 516 | + return $this->when(!$value, $callback, $default); |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | /** |
@@ -551,10 +551,10 @@ discard block |
||
| 551 | 551 | $operator = '='; |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | - return function ($item) use ($key, $operator, $value) { |
|
| 554 | + return function($item) use ($key, $operator, $value) { |
|
| 555 | 555 | $retrieved = data_get($item, $key); |
| 556 | 556 | |
| 557 | - $strings = array_filter([$retrieved, $value], function ($value) { |
|
| 557 | + $strings = array_filter([$retrieved, $value], function($value) { |
|
| 558 | 558 | return is_string($value) || (is_object($value) && method_exists($value, '__toString')); |
| 559 | 559 | }); |
| 560 | 560 | |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | { |
| 603 | 603 | $values = $this->getArrayableItems($values); |
| 604 | 604 | |
| 605 | - return $this->filter(function ($item) use ($key, $values, $strict) { |
|
| 605 | + return $this->filter(function($item) use ($key, $values, $strict) { |
|
| 606 | 606 | return in_array(data_get($item, $key), $values, $strict); |
| 607 | 607 | }); |
| 608 | 608 | } |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | { |
| 632 | 632 | $values = $this->getArrayableItems($values); |
| 633 | 633 | |
| 634 | - return $this->reject(function ($item) use ($key, $values, $strict) { |
|
| 634 | + return $this->reject(function($item) use ($key, $values, $strict) { |
|
| 635 | 635 | return in_array(data_get($item, $key), $values, $strict); |
| 636 | 636 | }); |
| 637 | 637 | } |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | */ |
| 657 | 657 | public function whereInstanceOf($type) |
| 658 | 658 | { |
| 659 | - return $this->filter(function ($value) use ($type) { |
|
| 659 | + return $this->filter(function($value) use ($type) { |
|
| 660 | 660 | return $value instanceof $type; |
| 661 | 661 | }); |
| 662 | 662 | } |
@@ -760,14 +760,14 @@ discard block |
||
| 760 | 760 | foreach ($this->items as $key => $value) { |
| 761 | 761 | $groupKeys = $groupBy($value, $key); |
| 762 | 762 | |
| 763 | - if (! is_array($groupKeys)) { |
|
| 763 | + if (!is_array($groupKeys)) { |
|
| 764 | 764 | $groupKeys = [$groupKeys]; |
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | foreach ($groupKeys as $groupKey) { |
| 768 | 768 | $groupKey = is_bool($groupKey) ? (int) $groupKey : $groupKey; |
| 769 | 769 | |
| 770 | - if (! array_key_exists($groupKey, $results)) { |
|
| 770 | + if (!array_key_exists($groupKey, $results)) { |
|
| 771 | 771 | $results[$groupKey] = new static; |
| 772 | 772 | } |
| 773 | 773 | |
@@ -777,7 +777,7 @@ discard block |
||
| 777 | 777 | |
| 778 | 778 | $result = new static($results); |
| 779 | 779 | |
| 780 | - if (! empty($nextGroups)) { |
|
| 780 | + if (!empty($nextGroups)) { |
|
| 781 | 781 | return $result->map->groupBy($nextGroups, $preserveKeys); |
| 782 | 782 | } |
| 783 | 783 | |
@@ -820,7 +820,7 @@ discard block |
||
| 820 | 820 | $keys = is_array($key) ? $key : func_get_args(); |
| 821 | 821 | |
| 822 | 822 | foreach ($keys as $value) { |
| 823 | - if (! $this->offsetExists($value)) { |
|
| 823 | + if (!$this->offsetExists($value)) { |
|
| 824 | 824 | return false; |
| 825 | 825 | } |
| 826 | 826 | } |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | */ |
| 888 | 888 | public function isNotEmpty() |
| 889 | 889 | { |
| 890 | - return ! $this->isEmpty(); |
|
| 890 | + return !$this->isEmpty(); |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | /** |
@@ -898,7 +898,7 @@ discard block |
||
| 898 | 898 | */ |
| 899 | 899 | protected function useAsCallable($value) |
| 900 | 900 | { |
| 901 | - return ! is_string($value) && is_callable($value); |
|
| 901 | + return !is_string($value) && is_callable($value); |
|
| 902 | 902 | } |
| 903 | 903 | |
| 904 | 904 | /** |
@@ -958,7 +958,7 @@ discard block |
||
| 958 | 958 | */ |
| 959 | 959 | public function mapSpread(callable $callback) |
| 960 | 960 | { |
| 961 | - return $this->map(function ($chunk, $key) use ($callback) { |
|
| 961 | + return $this->map(function($chunk, $key) use ($callback) { |
|
| 962 | 962 | $chunk[] = $key; |
| 963 | 963 | |
| 964 | 964 | return $callback(...$chunk); |
@@ -984,7 +984,7 @@ discard block |
||
| 984 | 984 | |
| 985 | 985 | $value = reset($pair); |
| 986 | 986 | |
| 987 | - if (! isset($dictionary[$key])) { |
|
| 987 | + if (!isset($dictionary[$key])) { |
|
| 988 | 988 | $dictionary[$key] = []; |
| 989 | 989 | } |
| 990 | 990 | |
@@ -1051,7 +1051,7 @@ discard block |
||
| 1051 | 1051 | */ |
| 1052 | 1052 | public function mapInto($class) |
| 1053 | 1053 | { |
| 1054 | - return $this->map(function ($value, $key) use ($class) { |
|
| 1054 | + return $this->map(function($value, $key) use ($class) { |
|
| 1055 | 1055 | return new $class($value, $key); |
| 1056 | 1056 | }); |
| 1057 | 1057 | } |
@@ -1066,9 +1066,9 @@ discard block |
||
| 1066 | 1066 | { |
| 1067 | 1067 | $callback = $this->valueRetriever($callback); |
| 1068 | 1068 | |
| 1069 | - return $this->filter(function ($value) { |
|
| 1070 | - return ! is_null($value); |
|
| 1071 | - })->reduce(function ($result, $item) use ($callback) { |
|
| 1069 | + return $this->filter(function($value) { |
|
| 1070 | + return !is_null($value); |
|
| 1071 | + })->reduce(function($result, $item) use ($callback) { |
|
| 1072 | 1072 | $value = $callback($item); |
| 1073 | 1073 | |
| 1074 | 1074 | return is_null($result) || $value > $result ? $value : $result; |
@@ -1118,11 +1118,11 @@ discard block |
||
| 1118 | 1118 | { |
| 1119 | 1119 | $callback = $this->valueRetriever($callback); |
| 1120 | 1120 | |
| 1121 | - return $this->map(function ($value) use ($callback) { |
|
| 1121 | + return $this->map(function($value) use ($callback) { |
|
| 1122 | 1122 | return $callback($value); |
| 1123 | - })->filter(function ($value) { |
|
| 1124 | - return ! is_null($value); |
|
| 1125 | - })->reduce(function ($result, $value) { |
|
| 1123 | + })->filter(function($value) { |
|
| 1124 | + return !is_null($value); |
|
| 1125 | + })->reduce(function($result, $value) { |
|
| 1126 | 1126 | return is_null($result) || $value < $result ? $value : $result; |
| 1127 | 1127 | }); |
| 1128 | 1128 | } |
@@ -1203,7 +1203,7 @@ discard block |
||
| 1203 | 1203 | : $this->operatorForWhere(...func_get_args()); |
| 1204 | 1204 | |
| 1205 | 1205 | foreach ($this->items as $key => $item) { |
| 1206 | - $partitions[(int) ! $callback($item, $key)][$key] = $item; |
|
| 1206 | + $partitions[(int) !$callback($item, $key)][$key] = $item; |
|
| 1207 | 1207 | } |
| 1208 | 1208 | |
| 1209 | 1209 | return new static($partitions); |
@@ -1338,12 +1338,12 @@ discard block |
||
| 1338 | 1338 | public function reject($callback) |
| 1339 | 1339 | { |
| 1340 | 1340 | if ($this->useAsCallable($callback)) { |
| 1341 | - return $this->filter(function ($value, $key) use ($callback) { |
|
| 1342 | - return ! $callback($value, $key); |
|
| 1341 | + return $this->filter(function($value, $key) use ($callback) { |
|
| 1342 | + return !$callback($value, $key); |
|
| 1343 | 1343 | }); |
| 1344 | 1344 | } |
| 1345 | 1345 | |
| 1346 | - return $this->filter(function ($item) use ($callback) { |
|
| 1346 | + return $this->filter(function($item) use ($callback) { |
|
| 1347 | 1347 | return $item != $callback; |
| 1348 | 1348 | }); |
| 1349 | 1349 | } |
@@ -1367,7 +1367,7 @@ discard block |
||
| 1367 | 1367 | */ |
| 1368 | 1368 | public function search($value, $strict = false) |
| 1369 | 1369 | { |
| 1370 | - if (! $this->useAsCallable($value)) { |
|
| 1370 | + if (!$this->useAsCallable($value)) { |
|
| 1371 | 1371 | return array_search($value, $this->items, $strict); |
| 1372 | 1372 | } |
| 1373 | 1373 | |
@@ -1592,7 +1592,7 @@ discard block |
||
| 1592 | 1592 | |
| 1593 | 1593 | $callback = $this->valueRetriever($callback); |
| 1594 | 1594 | |
| 1595 | - return $this->reduce(function ($result, $item) use ($callback) { |
|
| 1595 | + return $this->reduce(function($result, $item) use ($callback) { |
|
| 1596 | 1596 | return $result + $callback($item); |
| 1597 | 1597 | }, 0); |
| 1598 | 1598 | } |
@@ -1651,7 +1651,7 @@ discard block |
||
| 1651 | 1651 | |
| 1652 | 1652 | $exists = []; |
| 1653 | 1653 | |
| 1654 | - return $this->reject(function ($item, $key) use ($callback, $strict, &$exists) { |
|
| 1654 | + return $this->reject(function($item, $key) use ($callback, $strict, &$exists) { |
|
| 1655 | 1655 | if (in_array($id = $callback($item, $key), $exists, $strict)) { |
| 1656 | 1656 | return true; |
| 1657 | 1657 | } |
@@ -1693,7 +1693,7 @@ discard block |
||
| 1693 | 1693 | return $value; |
| 1694 | 1694 | } |
| 1695 | 1695 | |
| 1696 | - return function ($item) use ($value) { |
|
| 1696 | + return function($item) use ($value) { |
|
| 1697 | 1697 | return data_get($item, $value); |
| 1698 | 1698 | }; |
| 1699 | 1699 | } |
@@ -1709,11 +1709,11 @@ discard block |
||
| 1709 | 1709 | */ |
| 1710 | 1710 | public function zip($items) |
| 1711 | 1711 | { |
| 1712 | - $arrayableItems = array_map(function ($items) { |
|
| 1712 | + $arrayableItems = array_map(function($items) { |
|
| 1713 | 1713 | return $this->getArrayableItems($items); |
| 1714 | 1714 | }, func_get_args()); |
| 1715 | 1715 | |
| 1716 | - $params = array_merge([function () { |
|
| 1716 | + $params = array_merge([function() { |
|
| 1717 | 1717 | return new static(func_get_args()); |
| 1718 | 1718 | }, $this->items], $arrayableItems); |
| 1719 | 1719 | |
@@ -1739,7 +1739,7 @@ discard block |
||
| 1739 | 1739 | */ |
| 1740 | 1740 | public function toArray() |
| 1741 | 1741 | { |
| 1742 | - return array_map(function ($value) { |
|
| 1742 | + return array_map(function($value) { |
|
| 1743 | 1743 | return $value instanceof Arrayable ? $value->toArray() : $value; |
| 1744 | 1744 | }, $this->items); |
| 1745 | 1745 | } |
@@ -1751,7 +1751,7 @@ discard block |
||
| 1751 | 1751 | */ |
| 1752 | 1752 | public function jsonSerialize() |
| 1753 | 1753 | { |
| 1754 | - return array_map(function ($value) { |
|
| 1754 | + return array_map(function($value) { |
|
| 1755 | 1755 | if ($value instanceof JsonSerializable) { |
| 1756 | 1756 | return $value->jsonSerialize(); |
| 1757 | 1757 | } elseif ($value instanceof Jsonable) { |
@@ -1921,7 +1921,7 @@ discard block |
||
| 1921 | 1921 | */ |
| 1922 | 1922 | public function __get($key) |
| 1923 | 1923 | { |
| 1924 | - if (! in_array($key, static::$proxies)) { |
|
| 1924 | + if (!in_array($key, static::$proxies)) { |
|
| 1925 | 1925 | throw new Exception("Property [{$key}] does not exist on this collection instance."); |
| 1926 | 1926 | } |
| 1927 | 1927 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public static function __callStatic($method, $parameters) |
| 72 | 72 | { |
| 73 | - if (! static::hasMacro($method)) { |
|
| 73 | + if (!static::hasMacro($method)) { |
|
| 74 | 74 | throw new BadMethodCallException(sprintf( |
| 75 | 75 | 'Method %s::%s does not exist.', static::class, $method |
| 76 | 76 | )); |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function __call($method, $parameters) |
| 96 | 96 | { |
| 97 | - if (! static::hasMacro($method)) { |
|
| 97 | + if (!static::hasMacro($method)) { |
|
| 98 | 98 | throw new BadMethodCallException(sprintf( |
| 99 | 99 | 'Method %s::%s does not exist.', static::class, $method |
| 100 | 100 | )); |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | foreach ($array as $values) { |
| 52 | 52 | if ($values instanceof Collection) { |
| 53 | 53 | $values = $values->all(); |
| 54 | - } elseif (! is_array($values)) { |
|
| 54 | + } elseif (!is_array($values)) { |
|
| 55 | 55 | continue; |
| 56 | 56 | } |
| 57 | 57 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $results = []; |
| 112 | 112 | |
| 113 | 113 | foreach ($array as $key => $value) { |
| 114 | - if (is_array($value) && ! empty($value)) { |
|
| 114 | + if (is_array($value) && !empty($value)) { |
|
| 115 | 115 | $results = array_merge($results, static::dot($value, $prepend.$key.'.')); |
| 116 | 116 | } else { |
| 117 | 117 | $results[$prepend.$key] = $value; |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | foreach ($array as $item) { |
| 212 | 212 | $item = $item instanceof Collection ? $item->all() : $item; |
| 213 | 213 | |
| 214 | - if (! is_array($item)) { |
|
| 214 | + if (!is_array($item)) { |
|
| 215 | 215 | $result[] = $item; |
| 216 | 216 | } elseif ($depth === 1) { |
| 217 | 217 | $result = array_merge($result, array_values($item)); |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | */ |
| 278 | 278 | public static function get($array, $key, $default = null) |
| 279 | 279 | { |
| 280 | - if (! static::accessible($array)) { |
|
| 280 | + if (!static::accessible($array)) { |
|
| 281 | 281 | return value($default); |
| 282 | 282 | } |
| 283 | 283 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | |
| 320 | 320 | $keys = (array) $keys; |
| 321 | 321 | |
| 322 | - if (! $array) { |
|
| 322 | + if (!$array) { |
|
| 323 | 323 | return false; |
| 324 | 324 | } |
| 325 | 325 | |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | // If the key doesn't exist at this depth, we will just create an empty array |
| 526 | 526 | // to hold the next value, allowing us to create the arrays to hold final |
| 527 | 527 | // values at the correct depth. Then we'll keep digging into the array. |
| 528 | - if (! isset($array[$key]) || ! is_array($array[$key])) { |
|
| 528 | + if (!isset($array[$key]) || !is_array($array[$key])) { |
|
| 529 | 529 | $array[$key] = []; |
| 530 | 530 | } |
| 531 | 531 | |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | } else { |
| 552 | 552 | srand($seed); |
| 553 | 553 | |
| 554 | - usort($array, function () { |
|
| 554 | + usort($array, function() { |
|
| 555 | 555 | return rand(-1, 1); |
| 556 | 556 | }); |
| 557 | 557 | } |
@@ -618,6 +618,6 @@ discard block |
||
| 618 | 618 | return []; |
| 619 | 619 | } |
| 620 | 620 | |
| 621 | - return ! is_array($value) ? [$value] : $value; |
|
| 621 | + return !is_array($value) ? [$value] : $value; |
|
| 622 | 622 | } |
| 623 | 623 | } |
@@ -378,7 +378,7 @@ |
||
| 378 | 378 | * |
| 379 | 379 | * @param array $array |
| 380 | 380 | * @param string|array $value |
| 381 | - * @param string|array|null $key |
|
| 381 | + * @param string|null $key |
|
| 382 | 382 | * @return array |
| 383 | 383 | */ |
| 384 | 384 | public static function pluck($array, $value, $key = null) |
@@ -3,8 +3,8 @@ |
||
| 3 | 3 | namespace IlluminateAgnostic\Collection\Support; |
| 4 | 4 | |
| 5 | 5 | use ArrayAccess; |
| 6 | -use InvalidArgumentException; |
|
| 7 | 6 | use IlluminateAgnostic\Collection\Support\Traits\Macroable; |
| 7 | +use InvalidArgumentException; |
|
| 8 | 8 | |
| 9 | 9 | class Arr |
| 10 | 10 | { |