@@ -491,7 +491,6 @@ |
||
| 491 | 491 | * |
| 492 | 492 | * Reduces this collection to one value by passing value, key, and the return value from the previous iteration |
| 493 | 493 | * until only one value remains. Iteration begins from the last item in the collection and moves up. |
| 494 | - |
|
| 495 | 494 | * @param callable $callback The callback function |
| 496 | 495 | * @param $initial The initial "carry" value |
| 497 | 496 | * |
@@ -491,7 +491,6 @@ |
||
| 491 | 491 | * |
| 492 | 492 | * Reduces this collection to one value by passing value, key, and the return value from the previous iteration |
| 493 | 493 | * until only one value remains. Iteration begins from the last item in the collection and moves up. |
| 494 | - |
|
| 495 | 494 | * @param callable $callback The callback function |
| 496 | 495 | * @param $initial The initial "carry" value |
| 497 | 496 | * |
@@ -55,10 +55,8 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * Underscore function. |
| 58 | - |
|
| 59 | 58 | * This function is meant to work sort of like jQuery's "$()". It is a contextual catch-all type function. It works |
| 60 | 59 | * as a short-hand alias for invoke, collect, and with. |
| 61 | - |
|
| 62 | 60 | * @param callable|mixed $in |
| 63 | 61 | * @param mixed ... $_ |
| 64 | 62 | * |
@@ -136,10 +134,8 @@ discard block |
||
| 136 | 134 | * |
| 137 | 135 | * Accepts any kind of data and converts it to an array. If strict mode is on, only data that returns true from |
| 138 | 136 | * is_arrayable() will be converted to an array. Anything else will cause an InvalidArgumentException to be thrown. |
| 139 | - |
|
| 140 | 137 | * @param mixed $data Data to convert to array |
| 141 | 138 | * @param bool $strict Whether to use strict mode |
| 142 | - |
|
| 143 | 139 | * @return array |
| 144 | 140 | * |
| 145 | 141 | * @throws InvalidArgumentException |
@@ -245,12 +241,9 @@ discard block |
||
| 245 | 241 | * Provided with the requested offset, whether it be a string, an integer (positive or negative), or some type of |
| 246 | 242 | * object, this function will normalize it to a positive integer offset or, failing that, it will throw an exception. |
| 247 | 243 | * A negative offset will require either the traversable that is being indexed or its total count in order to normalize |
| 248 | - |
|
| 249 | 244 | * @param int|mixed $offset The offset to normalize |
| 250 | 245 | * @param int|array|traversable $count Either the traversable count, or the traversable itself. |
| 251 | - |
|
| 252 | 246 | * @return int |
| 253 | - |
|
| 254 | 247 | * @throws RuntimeException If offset cannot be normalized |
| 255 | 248 | * @throws InvalidArgumentException If offset is negative and count is not provided |
| 256 | 249 | */ |
@@ -9,24 +9,15 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | namespace Noz; |
| 11 | 11 | |
| 12 | -use Closure; |
|
| 13 | 12 | use Illuminate\Support\Str; |
| 14 | 13 | use InvalidArgumentException; |
| 15 | 14 | use Iterator; |
| 15 | +use Noz\Contracts\CollectionInterface; |
|
| 16 | 16 | use Noz\Immutable\Collection; |
| 17 | 17 | use Noz\Immutable\Sequence; |
| 18 | -use Noz\Contracts\CollectionInterface; |
|
| 19 | 18 | use RuntimeException; |
| 20 | -use Serializable; |
|
| 21 | 19 | use Traversable; |
| 22 | 20 | |
| 23 | -use Symfony\Component\Serializer\Serializer; |
|
| 24 | -use Symfony\Component\Serializer\Encoder\XmlEncoder; |
|
| 25 | -use Symfony\Component\Serializer\Encoder\JsonEncoder; |
|
| 26 | -use Symfony\Component\Serializer\Encoder\YamlEncoder; |
|
| 27 | -use Symfony\Component\Serializer\Encoder\CsvEncoder; |
|
| 28 | -use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; |
|
| 29 | - |
|
| 30 | 21 | /** |
| 31 | 22 | * Collection factory. |
| 32 | 23 | * |
@@ -9,21 +9,18 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | namespace Noz\Collection; |
| 11 | 11 | |
| 12 | -use InvalidArgumentException; |
|
| 13 | -use OutOfBoundsException; |
|
| 14 | - |
|
| 15 | 12 | use ArrayIterator; |
| 16 | 13 | use Countable; |
| 14 | +use InvalidArgumentException; |
|
| 17 | 15 | use Iterator; |
| 18 | -use Traversable; |
|
| 19 | - |
|
| 20 | 16 | use Noz\Contracts\Arrayable; |
| 21 | -use Noz\Contracts\Invokable; |
|
| 22 | 17 | use Noz\Contracts\CollectionInterface; |
| 23 | - |
|
| 18 | +use Noz\Contracts\Invokable; |
|
| 24 | 19 | use Noz\Traits\IsArrayable; |
| 25 | 20 | use Noz\Traits\IsContainer; |
| 26 | 21 | use Noz\Traits\IsSerializable; |
| 22 | +use OutOfBoundsException; |
|
| 23 | +use Traversable; |
|
| 27 | 24 | |
| 28 | 25 | use function |
| 29 | 26 | Noz\is_traversable, |
@@ -997,7 +997,7 @@ discard block |
||
| 997 | 997 | } |
| 998 | 998 | }); |
| 999 | 999 | $args = $args->prepend($this->getData()) |
| 1000 | - ->prepend(null); |
|
| 1000 | + ->prepend(null); |
|
| 1001 | 1001 | |
| 1002 | 1002 | return collect( |
| 1003 | 1003 | // array_map( |
@@ -1185,11 +1185,9 @@ discard block |
||
| 1185 | 1185 | |
| 1186 | 1186 | /** |
| 1187 | 1187 | * Get the number of times each item occurs in the collection. |
| 1188 | - |
|
| 1189 | 1188 | * This method will return a NumericCollection where keys are the |
| 1190 | 1189 | * values and values are the number of times that value occurs in |
| 1191 | 1190 | * the original collection. |
| 1192 | - |
|
| 1193 | 1191 | * @return CollectionInterface |
| 1194 | 1192 | */ |
| 1195 | 1193 | public function counts() |
@@ -9,18 +9,11 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | namespace Noz\Collection; |
| 11 | 11 | |
| 12 | -use BadMethodCallException; |
|
| 13 | - |
|
| 14 | 12 | use Countable; |
| 15 | -use Noz\Contracts\Structure\Dictable; |
|
| 16 | -use Traversable; |
|
| 17 | -use SplFixedArray; |
|
| 18 | - |
|
| 19 | -use Noz\Contracts\Structure\Sequenceable; |
|
| 20 | -use Noz\Contracts\Immutable; |
|
| 21 | 13 | use Noz\Contracts\Arrayable; |
| 14 | +use Noz\Contracts\Immutable; |
|
| 22 | 15 | use Noz\Contracts\Invokable; |
| 23 | - |
|
| 16 | +use Noz\Contracts\Structure\Dictable; |
|
| 24 | 17 | use Noz\Traits\IsImmutable; |
| 25 | 18 | |
| 26 | 19 | use function Noz\to_array; |
@@ -9,21 +9,18 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | namespace Noz\Immutable; |
| 11 | 11 | |
| 12 | -use InvalidArgumentException; |
|
| 13 | - |
|
| 14 | 12 | use Countable; |
| 15 | -use Traversable; |
|
| 16 | -use Serializable; |
|
| 17 | -use SplDoublyLinkedList; |
|
| 18 | - |
|
| 19 | -use Noz\Contracts\Structure\Listable; |
|
| 20 | -use Noz\Contracts\Immutable; |
|
| 13 | +use InvalidArgumentException; |
|
| 21 | 14 | use Noz\Contracts\Arrayable; |
| 15 | +use Noz\Contracts\Immutable; |
|
| 22 | 16 | use Noz\Contracts\Invokable; |
| 23 | - |
|
| 17 | +use Noz\Contracts\Structure\Listable; |
|
| 24 | 18 | use Noz\Traits\IsArrayable; |
| 25 | -use Noz\Traits\IsImmutable; |
|
| 26 | 19 | use Noz\Traits\IsContainer; |
| 20 | +use Noz\Traits\IsImmutable; |
|
| 21 | +use Serializable; |
|
| 22 | +use SplDoublyLinkedList; |
|
| 23 | +use Traversable; |
|
| 27 | 24 | |
| 28 | 25 | use function |
| 29 | 26 | Noz\is_traversable; |
@@ -9,18 +9,11 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | namespace Noz\Collection; |
| 11 | 11 | |
| 12 | -use BadMethodCallException; |
|
| 13 | - |
|
| 14 | 12 | use Countable; |
| 15 | -use Noz\Contracts\Structure\Listable; |
|
| 16 | -use Traversable; |
|
| 17 | -use SplFixedArray; |
|
| 18 | - |
|
| 19 | -use Noz\Contracts\Structure\Sequenceable; |
|
| 20 | -use Noz\Contracts\Immutable; |
|
| 21 | 13 | use Noz\Contracts\Arrayable; |
| 14 | +use Noz\Contracts\Immutable; |
|
| 22 | 15 | use Noz\Contracts\Invokable; |
| 23 | - |
|
| 16 | +use Noz\Contracts\Structure\Listable; |
|
| 24 | 17 | use Noz\Traits\IsImmutable; |
| 25 | 18 | |
| 26 | 19 | use function Noz\to_array; |
@@ -9,27 +9,22 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | namespace Noz\Immutable; |
| 11 | 11 | |
| 12 | -use BadMethodCallException; |
|
| 13 | -use RuntimeException; |
|
| 14 | - |
|
| 15 | -use Iterator; |
|
| 16 | 12 | use ArrayAccess; |
| 13 | +use BadMethodCallException; |
|
| 17 | 14 | use Countable; |
| 18 | -use Serializable; |
|
| 19 | -use SplFixedArray; |
|
| 20 | -use Traversable; |
|
| 21 | - |
|
| 22 | 15 | use Illuminate\Support\Str; |
| 23 | - |
|
| 16 | +use Iterator; |
|
| 24 | 17 | use Noz\Contracts\Arrayable; |
| 25 | 18 | use Noz\Contracts\Immutable; |
| 26 | 19 | use Noz\Contracts\Invokable; |
| 27 | 20 | use Noz\Contracts\Structure\Sequenceable; |
| 28 | - |
|
| 21 | +use Noz\Traits\IsArrayable; |
|
| 29 | 22 | use Noz\Traits\IsContainer; |
| 30 | 23 | use Noz\Traits\IsImmutable; |
| 31 | -use Noz\Traits\IsArrayable; |
|
| 32 | 24 | use Noz\Traits\IsSerializable; |
| 25 | +use RuntimeException; |
|
| 26 | +use SplFixedArray; |
|
| 27 | +use Traversable; |
|
| 33 | 28 | |
| 34 | 29 | use function |
| 35 | 30 | Noz\to_array, |
@@ -83,16 +83,12 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * Invoke sequence. |
| 86 | - |
|
| 87 | 86 | * A sequence is invokable as if it were a function. This allows some pretty useful functionality such as negative |
| 88 | 87 | * indexing, sub-sequence selection, etc. Basically, any way you invoke a sequence, you're going to get back either |
| 89 | 88 | * a single value from the sequence or a subset of it. |
| 90 | - |
|
| 91 | 89 | * @internal param mixed $funk Either a numerical offset (positive or negative), a range string (start:end), or a |
| 92 | 90 | * callback to be used as a filter. |
| 93 | - |
|
| 94 | 91 | * @return mixed |
| 95 | - |
|
| 96 | 92 | * @todo Put all the slice logic into a helper function or several |
| 97 | 93 | */ |
| 98 | 94 | public function __invoke() |
@@ -360,12 +356,12 @@ discard block |
||
| 360 | 356 | * |
| 361 | 357 | * @return Sequence |
| 362 | 358 | */ |
| 363 | - public function prepend($item) |
|
| 364 | - { |
|
| 365 | - $arr = $this->getData(); |
|
| 366 | - array_unshift($arr, $item); |
|
| 367 | - return new static($arr); |
|
| 368 | - } |
|
| 359 | + public function prepend($item) |
|
| 360 | + { |
|
| 361 | + $arr = $this->getData(); |
|
| 362 | + array_unshift($arr, $item); |
|
| 363 | + return new static($arr); |
|
| 364 | + } |
|
| 369 | 365 | |
| 370 | 366 | /** |
| 371 | 367 | * Append item to collection. |
@@ -9,17 +9,11 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | namespace Noz\Collection; |
| 11 | 11 | |
| 12 | -use BadMethodCallException; |
|
| 13 | - |
|
| 14 | 12 | use Countable; |
| 15 | -use Traversable; |
|
| 16 | -use SplFixedArray; |
|
| 17 | - |
|
| 18 | -use Noz\Contracts\Structure\Settable; |
|
| 19 | -use Noz\Contracts\Immutable; |
|
| 20 | 13 | use Noz\Contracts\Arrayable; |
| 14 | +use Noz\Contracts\Immutable; |
|
| 21 | 15 | use Noz\Contracts\Invokable; |
| 22 | - |
|
| 16 | +use Noz\Contracts\Structure\Settable; |
|
| 23 | 17 | use Noz\Traits\IsImmutable; |
| 24 | 18 | |
| 25 | 19 | use function Noz\to_array; |