@@ -2,20 +2,19 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace PragmaRX\Coollection\Package; |
| 4 | 4 | |
| 5 | +use ArrayAccess; |
|
| 5 | 6 | use Closure; |
| 6 | 7 | use Countable; |
| 7 | 8 | use Exception; |
| 8 | -use ArrayAccess; |
|
| 9 | -use JsonSerializable; |
|
| 10 | -use IteratorAggregate; |
|
| 11 | -use IlluminateAgnostic\Str\Support\Str; |
|
| 12 | 9 | use IlluminateAgnostic\Arr\Support\Arr; |
| 13 | -use IlluminateAgnostic\Collection\Support\Collection; |
|
| 14 | -use IlluminateAgnostic\Collection\Support\Traits\Macroable; |
|
| 15 | -use IlluminateAgnostic\Collection\Contracts\Support\Jsonable; |
|
| 16 | 10 | use IlluminateAgnostic\Collection\Contracts\Support\Arrayable; |
| 17 | -use IlluminateAgnostic\Collection\Support\HigherOrderCollectionProxy; |
|
| 11 | +use IlluminateAgnostic\Collection\Contracts\Support\Jsonable; |
|
| 18 | 12 | use IlluminateAgnostic\Collection\Support\Collection as TightencoCollect; |
| 13 | +use IlluminateAgnostic\Collection\Support\HigherOrderCollectionProxy; |
|
| 14 | +use IlluminateAgnostic\Collection\Support\Traits\Macroable; |
|
| 15 | +use IlluminateAgnostic\Str\Support\Str; |
|
| 16 | +use IteratorAggregate; |
|
| 17 | +use JsonSerializable; |
|
| 19 | 18 | |
| 20 | 19 | class Coollection implements ArrayAccess, Arrayable, Countable, IteratorAggregate, Jsonable, JsonSerializable |
| 21 | 20 | { |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | * Get an array as a key. |
| 252 | 252 | * |
| 253 | 253 | * @param $key |
| 254 | - * @return mixed|string |
|
| 254 | + * @return string |
|
| 255 | 255 | */ |
| 256 | 256 | private function getArrayKey($key) |
| 257 | 257 | { |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | /** |
| 328 | 328 | * Get a property by name. |
| 329 | 329 | * |
| 330 | - * @param $key |
|
| 330 | + * @param string $key |
|
| 331 | 331 | * @return string|static |
| 332 | 332 | */ |
| 333 | 333 | private function getByPropertyName($key) |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | /** |
| 347 | 347 | * Execute a closure via Laravel's Collection |
| 348 | 348 | * |
| 349 | - * @param $closure |
|
| 349 | + * @param Closure $closure |
|
| 350 | 350 | * @param null $method |
| 351 | 351 | * @return mixed |
| 352 | 352 | */ |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | |
| 496 | 496 | /** |
| 497 | 497 | * @param $originalCallback |
| 498 | - * @return callable |
|
| 498 | + * @return Closure |
|
| 499 | 499 | */ |
| 500 | 500 | public function coollectizeCallback(callable $originalCallback = null) |
| 501 | 501 | { |
@@ -508,7 +508,7 @@ discard block |
||
| 508 | 508 | |
| 509 | 509 | /** |
| 510 | 510 | * @param $originalCallback |
| 511 | - * @return callable |
|
| 511 | + * @return Closure |
|
| 512 | 512 | */ |
| 513 | 513 | public function coollectizeCallbackForReduce(callable $originalCallback) |
| 514 | 514 | { |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function call($name, $arguments = []) |
| 105 | 105 | { |
| 106 | - return $this->runViaLaravelCollection(function ($collection) use ($name, $arguments) { |
|
| 106 | + return $this->runViaLaravelCollection(function($collection) use ($name, $arguments) { |
|
| 107 | 107 | return call_user_func_array( |
| 108 | 108 | [$collection, $name], |
| 109 | 109 | $this->coollectizeCallbacks($this->__toArray($arguments), $name) |
@@ -121,11 +121,11 @@ discard block |
||
| 121 | 121 | { |
| 122 | 122 | $value = is_null($value) ? $this->items : $value; |
| 123 | 123 | |
| 124 | - if (! $this->isArrayable($value)) { |
|
| 124 | + if (!$this->isArrayable($value)) { |
|
| 125 | 125 | return $value; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $result = array_map(function ($value) { |
|
| 128 | + $result = array_map(function($value) { |
|
| 129 | 129 | if ($this->isArrayable($value)) { |
| 130 | 130 | return new static($value); |
| 131 | 131 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | public function toArray() |
| 145 | 145 | { |
| 146 | - return array_map(function ($value) { |
|
| 146 | + return array_map(function($value) { |
|
| 147 | 147 | return $value instanceof Arrayable ? $value->toArray() : $value; |
| 148 | 148 | }, $this->items); |
| 149 | 149 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | return null; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - return $this->runViaLaravelCollection(function ($collection) use ($key) { |
|
| 173 | + return $this->runViaLaravelCollection(function($collection) use ($key) { |
|
| 174 | 174 | return new HigherOrderCollectionProxy($collection, $key); |
| 175 | 175 | }); |
| 176 | 176 | } |
@@ -185,11 +185,11 @@ discard block |
||
| 185 | 185 | { |
| 186 | 186 | $value = is_null($value) ? $this->items : $value; |
| 187 | 187 | |
| 188 | - if (! $this->isArrayable($value)) { |
|
| 188 | + if (!$this->isArrayable($value)) { |
|
| 189 | 189 | return $value; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - $result = array_map(function ($value) { |
|
| 192 | + $result = array_map(function($value) { |
|
| 193 | 193 | if ($this->isArrayable($value)) { |
| 194 | 194 | return $this->__toArray($value); |
| 195 | 195 | } |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | lower($key), |
| 270 | 270 | ]; |
| 271 | 271 | |
| 272 | - $data = $this->filter(function ($value, $key) use ($cases) { |
|
| 272 | + $data = $this->filter(function($value, $key) use ($cases) { |
|
| 273 | 273 | return array_search($key, $cases) !== false || array_search(lower($key), $cases) !== false; |
| 274 | 274 | })->keys()->first(); |
| 275 | 275 | |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | |
| 357 | 357 | $result = $closure($collection); |
| 358 | 358 | |
| 359 | - if (! $this->methodMustReturnArray($method)) { |
|
| 359 | + if (!$this->methodMustReturnArray($method)) { |
|
| 360 | 360 | $result = $this->coollectizeItems($result); |
| 361 | 361 | } |
| 362 | 362 | |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | */ |
| 441 | 441 | public function offsetGet($key) |
| 442 | 442 | { |
| 443 | - if (! isset($this->items[$key])) { |
|
| 443 | + if (!isset($this->items[$key])) { |
|
| 444 | 444 | return null; |
| 445 | 445 | } |
| 446 | 446 | |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | */ |
| 500 | 500 | public function coollectizeCallback(callable $originalCallback = null) |
| 501 | 501 | { |
| 502 | - return function ($value = null, $key = null) use ($originalCallback) { |
|
| 502 | + return function($value = null, $key = null) use ($originalCallback) { |
|
| 503 | 503 | return $originalCallback( |
| 504 | 504 | $this->__wrap($value), $key |
| 505 | 505 | ); |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | */ |
| 513 | 513 | public function coollectizeCallbackForReduce(callable $originalCallback) |
| 514 | 514 | { |
| 515 | - return function ($carry, $item) use ($originalCallback) { |
|
| 515 | + return function($carry, $item) use ($originalCallback) { |
|
| 516 | 516 | return $originalCallback( |
| 517 | 517 | $carry, |
| 518 | 518 | $this->__wrap($item) |
@@ -70,7 +70,7 @@ |
||
| 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("Method {$method} does not exist."); |
| 75 | 75 | } |
| 76 | 76 | |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | use IlluminateAgnostic\Str\Support\Str; |
| 4 | 4 | use PragmaRX\Coollection\Package\Coollection; |
| 5 | 5 | |
| 6 | -if (! function_exists('coollect')) { |
|
| 6 | +if (!function_exists('coollect')) { |
|
| 7 | 7 | /** |
| 8 | 8 | * Create a collection from the given value. |
| 9 | 9 | * |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | -if (! function_exists('snake')) { |
|
| 23 | +if (!function_exists('snake')) { |
|
| 24 | 24 | /** |
| 25 | 25 | * Convert a string to snake case. |
| 26 | 26 | * |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | -if (! function_exists('lower')) { |
|
| 37 | +if (!function_exists('lower')) { |
|
| 38 | 38 | /** |
| 39 | 39 | * Convert the given string to lower-case. |
| 40 | 40 | * |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | -if (! function_exists('upper')) { |
|
| 50 | +if (!function_exists('upper')) { |
|
| 51 | 51 | /** |
| 52 | 52 | * Convert the given string to lower-case. |
| 53 | 53 | * |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | /** |
| 64 | 64 | * @codeCoverageIgnore |
| 65 | 65 | */ |
| 66 | -if (! function_exists('dump')) { |
|
| 66 | +if (!function_exists('dump')) { |
|
| 67 | 67 | function dump(...$args) |
| 68 | 68 | { |
| 69 | 69 | foreach ($args as $value) { |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | /** |
| 76 | 76 | * @codeCoverageIgnore |
| 77 | 77 | */ |
| 78 | -if (! function_exists('dd')) { |
|
| 78 | +if (!function_exists('dd')) { |
|
| 79 | 79 | function dd(...$args) |
| 80 | 80 | { |
| 81 | 81 | dump(...$args); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | -if (! function_exists('starts_with')) { |
|
| 87 | +if (!function_exists('starts_with')) { |
|
| 88 | 88 | /** |
| 89 | 89 | * Determine if a given string starts with a given substring. |
| 90 | 90 | * |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | -if (! function_exists('array_sort_by_keys_recursive')) { |
|
| 101 | +if (!function_exists('array_sort_by_keys_recursive')) { |
|
| 102 | 102 | /** |
| 103 | 103 | * Determine if a given string starts with a given substring. |
| 104 | 104 | * |