@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | { |
| 172 | 172 | $type = gettype($data); |
| 173 | 173 | if ($meta) { |
| 174 | - switch($type) { |
|
| 174 | + switch ($type) { |
|
| 175 | 175 | case 'object': |
| 176 | 176 | $class = get_class($data); |
| 177 | 177 | return "{$type} <{$class}>"; |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | return "{$type} <{$restype}>"; |
| 181 | 181 | } |
| 182 | 182 | } else { |
| 183 | - switch($type) { |
|
| 183 | + switch ($type) { |
|
| 184 | 184 | case 'object': |
| 185 | 185 | return get_class($data); |
| 186 | 186 | case 'resource': |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | } else { |
| 271 | 271 | echo $label . "\n" . implode( |
| 272 | 272 | array_map( |
| 273 | - function () { |
|
| 273 | + function() { |
|
| 274 | 274 | return '-'; |
| 275 | 275 | }, |
| 276 | 276 | str_split($label) |
@@ -9,7 +9,6 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | namespace Noz; |
| 11 | 11 | |
| 12 | -use Closure; |
|
| 13 | 12 | use InvalidArgumentException; |
| 14 | 13 | use Iterator; |
| 15 | 14 | use Noz\Collection\Collection; |
@@ -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 | */ |
@@ -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 | * |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * @param string|int $index Set value at this index |
| 63 | 63 | * @param mixed $value Set this value at index |
| 64 | 64 | * |
| 65 | - * @return mixed |
|
| 65 | + * @return CollectionInterface |
|
| 66 | 66 | */ |
| 67 | 67 | public function set($index, $value); |
| 68 | 68 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @param string|int $index Delete item at this index |
| 75 | 75 | * |
| 76 | - * @return mixed |
|
| 76 | + * @return CollectionInterface |
|
| 77 | 77 | */ |
| 78 | 78 | public function delete($index); |
| 79 | 79 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * @param string|int $index Add value at this index |
| 109 | 109 | * @param mixed $value Add this value at index |
| 110 | 110 | * |
| 111 | - * @return mixed |
|
| 111 | + * @return CollectionInterface |
|
| 112 | 112 | */ |
| 113 | 113 | public function add($index, $value); |
| 114 | 114 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * @param int $nth The number of items between cycles |
| 165 | 165 | * @param null $offset An optional offset to begin from |
| 166 | 166 | * |
| 167 | - * @return mixed |
|
| 167 | + * @return CollectionInterface |
|
| 168 | 168 | */ |
| 169 | 169 | public function nth($nth, $offset = null); |
| 170 | 170 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | * |
| 229 | 229 | * @param int $num Number of items to return |
| 230 | 230 | * |
| 231 | - * @return mixed|CollectionInterface |
|
| 231 | + * @return CollectionInterface |
|
| 232 | 232 | */ |
| 233 | 233 | public function random($num); |
| 234 | 234 | |
@@ -14,13 +14,12 @@ |
||
| 14 | 14 | use InvalidArgumentException; |
| 15 | 15 | use Iterator; |
| 16 | 16 | use Noz\Contracts\Arrayable; |
| 17 | -use Noz\Contracts\Invokable; |
|
| 18 | 17 | use Noz\Contracts\CollectionInterface; |
| 18 | +use Noz\Contracts\Invokable; |
|
| 19 | +use Noz\Traits\IsArrayable; |
|
| 19 | 20 | use OutOfBoundsException; |
| 20 | 21 | use Traversable; |
| 21 | 22 | |
| 22 | -use Noz\Traits\IsArrayable; |
|
| 23 | - |
|
| 24 | 23 | use function |
| 25 | 24 | Noz\is_traversable, |
| 26 | 25 | Noz\typeof, |
@@ -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() |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | public function pairs() |
| 590 | 590 | { |
| 591 | 591 | return collect(array_map( |
| 592 | - function ($key, $val) { |
|
| 592 | + function($key, $val) { |
|
| 593 | 593 | return [$key, $val]; |
| 594 | 594 | }, |
| 595 | 595 | array_keys($this->getData()), |
@@ -608,11 +608,11 @@ discard block |
||
| 608 | 608 | public function duplicates() |
| 609 | 609 | { |
| 610 | 610 | $dups = []; |
| 611 | - $this->walk(function ($val, $key) use (&$dups) { |
|
| 611 | + $this->walk(function($val, $key) use (&$dups) { |
|
| 612 | 612 | $dups[$val][] = $key; |
| 613 | 613 | }); |
| 614 | 614 | |
| 615 | - return collect($dups)->filter(function ($val) { |
|
| 615 | + return collect($dups)->filter(function($val) { |
|
| 616 | 616 | return count($val) > 1; |
| 617 | 617 | }); |
| 618 | 618 | } |
@@ -899,7 +899,7 @@ discard block |
||
| 899 | 899 | public function split($num) |
| 900 | 900 | { |
| 901 | 901 | $count = $this->count(); |
| 902 | - $size = (int)($count / $num); |
|
| 902 | + $size = (int) ($count / $num); |
|
| 903 | 903 | $mod = $count % $num; |
| 904 | 904 | return collect($this->fold(function($chunks, $val, $key, $iter) use ($num, $size, $mod) { |
| 905 | 905 | $chunk_count = count($chunks); |
@@ -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,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,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; |
@@ -110,10 +110,8 @@ |
||
| 110 | 110 | * |
| 111 | 111 | * Accepts any kind of data and converts it to an array. If strict mode is on, only data that returns true from |
| 112 | 112 | * is_arrayable() will be converted to an array. Anything else will cause an InvalidArgumentException to be thrown. |
| 113 | - |
|
| 114 | 113 | * @param mixed $data Data to convert to array |
| 115 | 114 | * @param bool $strict Whether to use strict mode |
| 116 | - |
|
| 117 | 115 | * @return array |
| 118 | 116 | * |
| 119 | 117 | * @throws InvalidArgumentException |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | * |
| 41 | 41 | * @param mixed|callable $value The value to search for |
| 42 | 42 | * |
| 43 | - * @return mixed |
|
| 43 | + * @return boolean |
|
| 44 | 44 | */ |
| 45 | 45 | public function contains($value); |
| 46 | 46 | |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | public function contains($value, $index = null) |
| 32 | 32 | { |
| 33 | - return (bool) $this->fold(function ($carry, $val, $key) use ($value, $index) { |
|
| 33 | + return (bool) $this->fold(function($carry, $val, $key) use ($value, $index) { |
|
| 34 | 34 | if ($carry) { |
| 35 | 35 | return $carry; |
| 36 | 36 | } |