@@ -58,5 +58,5 @@ |
||
| 58 | 58 | * @param callable $callback |
| 59 | 59 | * @return void |
| 60 | 60 | */ |
| 61 | - public function forEach(callable $callback): void; |
|
| 61 | + public function forEach (callable $callback): void; |
|
| 62 | 62 | } |
@@ -58,5 +58,5 @@ |
||
| 58 | 58 | * @param callable $callback |
| 59 | 59 | * @return void |
| 60 | 60 | */ |
| 61 | - public function forEach(callable $callback): void; |
|
| 61 | + public function foreach(callable $callback): void; |
|
| 62 | 62 | } |
@@ -50,8 +50,7 @@ |
||
| 50 | 50 | * @class IterableInterface |
| 51 | 51 | * @package Platine\Collection |
| 52 | 52 | */ |
| 53 | -interface IterableInterface |
|
| 54 | -{ |
|
| 53 | +interface IterableInterface { |
|
| 55 | 54 | /** |
| 56 | 55 | * Loop on each collection element with the given callback |
| 57 | 56 | * @param callable $callback |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | $diffValues = array_udiff( |
| 107 | 107 | $this->all(), |
| 108 | 108 | $collection->all(), |
| 109 | - function ($a, $b) { |
|
| 109 | + function($a, $b) { |
|
| 110 | 110 | if (gettype($a) !== gettype($b)) { |
| 111 | 111 | return -1; |
| 112 | 112 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | /** |
| 157 | 157 | * {@inheritedoc} |
| 158 | 158 | */ |
| 159 | - public function forEach(callable $callback): void |
|
| 159 | + public function forEach (callable $callback): void |
|
| 160 | 160 | { |
| 161 | 161 | $data = $this->all(); |
| 162 | 162 | array_walk($data, $callback); |
@@ -156,7 +156,7 @@ |
||
| 156 | 156 | /** |
| 157 | 157 | * {@inheritedoc} |
| 158 | 158 | */ |
| 159 | - public function forEach(callable $callback): void |
|
| 159 | + public function foreach(callable $callback): void |
|
| 160 | 160 | { |
| 161 | 161 | $data = $this->all(); |
| 162 | 162 | array_walk($data, $callback); |
@@ -140,10 +140,10 @@ discard block |
||
| 140 | 140 | $diffValues = array_udiff_uassoc( |
| 141 | 141 | $this->all(), |
| 142 | 142 | $collection->all(), |
| 143 | - function ($a, $b) { |
|
| 143 | + function($a, $b) { |
|
| 144 | 144 | return $a <=> $b; |
| 145 | 145 | }, |
| 146 | - function ($c, $d) { |
|
| 146 | + function($c, $d) { |
|
| 147 | 147 | return $c <=> $d; |
| 148 | 148 | } |
| 149 | 149 | ); |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * @param callable $callback |
| 236 | 236 | * @return void |
| 237 | 237 | */ |
| 238 | - public function forEach(callable $callback): void |
|
| 238 | + public function forEach (callable $callback): void |
|
| 239 | 239 | { |
| 240 | 240 | $data = $this->all(); |
| 241 | 241 | array_walk($data, $callback); |
@@ -235,7 +235,7 @@ |
||
| 235 | 235 | * @param callable $callback |
| 236 | 236 | * @return void |
| 237 | 237 | */ |
| 238 | - public function forEach(callable $callback): void |
|
| 238 | + public function foreach(callable $callback): void |
|
| 239 | 239 | { |
| 240 | 240 | $data = $this->all(); |
| 241 | 241 | array_walk($data, $callback); |
@@ -206,12 +206,12 @@ discard block |
||
| 206 | 206 | : null; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - /** |
|
| 210 | - * |
|
| 211 | - * @param BaseCollection<T> $collection |
|
| 212 | - * @return bool |
|
| 213 | - * @throws InvalidOperationException |
|
| 214 | - */ |
|
| 209 | + /** |
|
| 210 | + * |
|
| 211 | + * @param BaseCollection<T> $collection |
|
| 212 | + * @return bool |
|
| 213 | + * @throws InvalidOperationException |
|
| 214 | + */ |
|
| 215 | 215 | public function equals(BaseCollection $collection): bool |
| 216 | 216 | { |
| 217 | 217 | if (!$collection instanceof self) { |
@@ -236,11 +236,11 @@ discard block |
||
| 236 | 236 | $this->initializePairs($data); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - /** |
|
| 240 | - * Return the value for given key |
|
| 241 | - * @param mixed $key |
|
| 242 | - * @return T|null |
|
| 243 | - */ |
|
| 239 | + /** |
|
| 240 | + * Return the value for given key |
|
| 241 | + * @param mixed $key |
|
| 242 | + * @return T|null |
|
| 243 | + */ |
|
| 244 | 244 | public function get(mixed $key): mixed |
| 245 | 245 | { |
| 246 | 246 | return $this->data->offsetExists($key) |
@@ -248,11 +248,11 @@ discard block |
||
| 248 | 248 | : null; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - /** |
|
| 252 | - * {@inheritedoc} |
|
| 253 | - * @param HashMap<T> $collection |
|
| 254 | - * @return HashMap<T> |
|
| 255 | - */ |
|
| 251 | + /** |
|
| 252 | + * {@inheritedoc} |
|
| 253 | + * @param HashMap<T> $collection |
|
| 254 | + * @return HashMap<T> |
|
| 255 | + */ |
|
| 256 | 256 | public function merge(BaseCollection $collection): BaseCollection |
| 257 | 257 | { |
| 258 | 258 | TypeCheck::isEqual( |
@@ -296,9 +296,9 @@ discard block |
||
| 296 | 296 | throw new InvalidOperationException('Can not call this method in map'); |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | - /** |
|
| 300 | - * {@inheritedoc} |
|
| 301 | - */ |
|
| 299 | + /** |
|
| 300 | + * {@inheritedoc} |
|
| 301 | + */ |
|
| 302 | 302 | public function remove(mixed $key): void |
| 303 | 303 | { |
| 304 | 304 | if ($this->isEmpty()) { |
@@ -315,12 +315,12 @@ discard block |
||
| 315 | 315 | $this->data->offsetUnset($key); |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - /** |
|
| 319 | - * |
|
| 320 | - * @param int $offset |
|
| 321 | - * @param int|null $length |
|
| 322 | - * @return HashMap<T>|null |
|
| 323 | - */ |
|
| 318 | + /** |
|
| 319 | + * |
|
| 320 | + * @param int $offset |
|
| 321 | + * @param int|null $length |
|
| 322 | + * @return HashMap<T>|null |
|
| 323 | + */ |
|
| 324 | 324 | public function slice(int $offset, ?int $length = null): ?BaseCollection |
| 325 | 325 | { |
| 326 | 326 | $newData = array_slice($this->all(), $offset, $length, true); |
@@ -334,11 +334,11 @@ discard block |
||
| 334 | 334 | : null; |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - /** |
|
| 338 | - * |
|
| 339 | - * @param callable $callback |
|
| 340 | - * @return HashMap<T>|null |
|
| 341 | - */ |
|
| 337 | + /** |
|
| 338 | + * |
|
| 339 | + * @param callable $callback |
|
| 340 | + * @return HashMap<T>|null |
|
| 341 | + */ |
|
| 342 | 342 | public function sort(callable $callback): ?BaseCollection |
| 343 | 343 | { |
| 344 | 344 | $data = $this->all(); |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | $diffValues = array_udiff( |
| 167 | 167 | $this->all(), |
| 168 | 168 | $collection->all(), |
| 169 | - function ($a, $b) { |
|
| 169 | + function($a, $b) { |
|
| 170 | 170 | return $a <=> $b; |
| 171 | 171 | } |
| 172 | 172 | ); |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | /** |
| 235 | 235 | * {@inheritedoc} |
| 236 | 236 | */ |
| 237 | - public function forEach(callable $callback): void |
|
| 237 | + public function forEach (callable $callback): void |
|
| 238 | 238 | { |
| 239 | 239 | $data = $this->all(); |
| 240 | 240 | array_walk($data, $callback); |
@@ -156,7 +156,7 @@ |
||
| 156 | 156 | /** |
| 157 | 157 | * {@inheritedoc} |
| 158 | 158 | */ |
| 159 | - public function forEach(callable $callback): void |
|
| 159 | + public function foreach(callable $callback): void |
|
| 160 | 160 | { |
| 161 | 161 | $data = $this->all(); |
| 162 | 162 | array_walk($data, $callback); |
@@ -67,8 +67,7 @@ |
||
| 67 | 67 | * @param array<mixed, mixed> $data |
| 68 | 68 | * @param string $type The type of this collection elements |
| 69 | 69 | */ |
| 70 | - public function __construct(array $data = [], protected string $type = '') |
|
| 71 | - { |
|
| 70 | + public function __construct(array $data = [], protected string $type = '') { |
|
| 72 | 71 | foreach ($data as $value) { |
| 73 | 72 | $this->validateEntry($value); |
| 74 | 73 | } |
@@ -52,15 +52,13 @@ |
||
| 52 | 52 | * |
| 53 | 53 | * @extends TypedCollection<object> |
| 54 | 54 | */ |
| 55 | -class ObjectCollection extends TypedCollection |
|
| 56 | -{ |
|
| 55 | +class ObjectCollection extends TypedCollection { |
|
| 57 | 56 | |
| 58 | 57 | /** |
| 59 | 58 | * Create new instance |
| 60 | 59 | * @param array<mixed, object> $data |
| 61 | 60 | */ |
| 62 | - public function __construct(array $data = []) |
|
| 63 | - { |
|
| 61 | + public function __construct(array $data = []) { |
|
| 64 | 62 | parent::__construct('object', $data); |
| 65 | 63 | } |
| 66 | 64 | } |
@@ -51,8 +51,7 @@ |
||
| 51 | 51 | * @package Platine\Collection |
| 52 | 52 | * @template T |
| 53 | 53 | */ |
| 54 | -interface MergeableInterface |
|
| 55 | -{ |
|
| 54 | +interface MergeableInterface { |
|
| 56 | 55 | /** |
| 57 | 56 | * Merge with the given collection |
| 58 | 57 | * @param BaseCollection<T> $collection |
@@ -51,8 +51,7 @@ |
||
| 51 | 51 | * @package Platine\Collection |
| 52 | 52 | * @template T |
| 53 | 53 | */ |
| 54 | -interface SortableInterface |
|
| 55 | -{ |
|
| 54 | +interface SortableInterface { |
|
| 56 | 55 | /** |
| 57 | 56 | * Sort the collection |
| 58 | 57 | * @param callable $callback |
@@ -68,8 +68,7 @@ |
||
| 68 | 68 | * Create new instance |
| 69 | 69 | * @param array<mixed, T> $initials |
| 70 | 70 | */ |
| 71 | - public function __construct(array $initials = []) |
|
| 72 | - { |
|
| 71 | + public function __construct(array $initials = []) { |
|
| 73 | 72 | $this->data = new DataContainer($initials); |
| 74 | 73 | } |
| 75 | 74 | |
@@ -50,15 +50,13 @@ |
||
| 50 | 50 | * @class Pair |
| 51 | 51 | * @package Platine\Collection\Map |
| 52 | 52 | */ |
| 53 | -class Pair |
|
| 54 | -{ |
|
| 53 | +class Pair { |
|
| 55 | 54 | /** |
| 56 | 55 | * Create new instance |
| 57 | 56 | * @param mixed $key |
| 58 | 57 | * @param mixed $value |
| 59 | 58 | */ |
| 60 | - public function __construct(protected mixed $key, protected mixed $value) |
|
| 61 | - { |
|
| 59 | + public function __construct(protected mixed $key, protected mixed $value) { |
|
| 62 | 60 | } |
| 63 | 61 | |
| 64 | 62 | /** |