@@ -38,6 +38,5 @@ |
||
| 38 | 38 | * Class InvalidOperationException |
| 39 | 39 | * @package Platine\Collection\Exception |
| 40 | 40 | */ |
| 41 | -class InvalidOperationException extends Exception |
|
| 42 | -{ |
|
| 41 | +class InvalidOperationException extends Exception { |
|
| 43 | 42 | } |
@@ -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 | /** |
| 58 | 57 | * Merge with the given collection |
@@ -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 | /** |
| 57 | 56 | * Loop on each collection element with the given callback |
@@ -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 | } |
@@ -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); |
@@ -177,8 +177,7 @@ discard block |
||
| 177 | 177 | * @param int $offset |
| 178 | 178 | * @return T|null |
| 179 | 179 | */ |
| 180 | - public function get(int $offset) |
|
| 181 | - { |
|
| 180 | + public function get(int $offset) { |
|
| 182 | 181 | return $this->data->offsetGet($offset); |
| 183 | 182 | } |
| 184 | 183 | |
@@ -211,8 +210,7 @@ discard block |
||
| 211 | 210 | * @return T|null |
| 212 | 211 | * @throws InvalidOperationException |
| 213 | 212 | */ |
| 214 | - public function rand() |
|
| 215 | - { |
|
| 213 | + public function rand() { |
|
| 216 | 214 | if ($this->isEmpty()) { |
| 217 | 215 | throw new InvalidOperationException('The collection is empty'); |
| 218 | 216 | } |
@@ -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 | /** |
| 58 | 57 | * Sort the collection |
@@ -50,8 +50,7 @@ |
||
| 50 | 50 | * Class CollectionInterface |
| 51 | 51 | * @package Platine\Collection |
| 52 | 52 | */ |
| 53 | -interface CollectionInterface |
|
| 54 | -{ |
|
| 53 | +interface CollectionInterface { |
|
| 55 | 54 | |
| 56 | 55 | /** |
| 57 | 56 | * Add element to the collection |
@@ -52,8 +52,7 @@ |
||
| 52 | 52 | * Class TypeCheck |
| 53 | 53 | * @package Platine\Collection |
| 54 | 54 | */ |
| 55 | -class TypeCheck |
|
| 56 | -{ |
|
| 55 | +class TypeCheck { |
|
| 57 | 56 | |
| 58 | 57 | /** |
| 59 | 58 | * |
@@ -50,8 +50,7 @@ |
||
| 50 | 50 | * Class MapInterface |
| 51 | 51 | * @package Platine\Collection\Map |
| 52 | 52 | */ |
| 53 | -interface MapInterface |
|
| 54 | -{ |
|
| 53 | +interface MapInterface { |
|
| 55 | 54 | |
| 56 | 55 | /** |
| 57 | 56 | * Add element to the collection |
@@ -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); |
@@ -219,12 +219,12 @@ discard block |
||
| 219 | 219 | : null; |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - /** |
|
| 223 | - * |
|
| 224 | - * @param HashMap<T> $collection |
|
| 225 | - * @return bool |
|
| 226 | - * @throws InvalidOperationException |
|
| 227 | - */ |
|
| 222 | + /** |
|
| 223 | + * |
|
| 224 | + * @param HashMap<T> $collection |
|
| 225 | + * @return bool |
|
| 226 | + * @throws InvalidOperationException |
|
| 227 | + */ |
|
| 228 | 228 | public function equals(BaseCollection $collection): bool |
| 229 | 229 | { |
| 230 | 230 | if (!$collection instanceof self) { |
@@ -249,11 +249,11 @@ discard block |
||
| 249 | 249 | $this->initializePairs($data); |
| 250 | 250 | } |
| 251 | 251 | |
| 252 | - /** |
|
| 253 | - * Return the value for given key |
|
| 254 | - * @param mixed $key |
|
| 255 | - * @return T|null |
|
| 256 | - */ |
|
| 252 | + /** |
|
| 253 | + * Return the value for given key |
|
| 254 | + * @param mixed $key |
|
| 255 | + * @return T|null |
|
| 256 | + */ |
|
| 257 | 257 | public function get($key) |
| 258 | 258 | { |
| 259 | 259 | return $this->data->offsetExists($key) |
@@ -261,11 +261,11 @@ discard block |
||
| 261 | 261 | : null; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | - /** |
|
| 265 | - * {@inheritedoc} |
|
| 266 | - * @param HashMap<T> $collection |
|
| 267 | - * @return HashMap<T> |
|
| 268 | - */ |
|
| 264 | + /** |
|
| 265 | + * {@inheritedoc} |
|
| 266 | + * @param HashMap<T> $collection |
|
| 267 | + * @return HashMap<T> |
|
| 268 | + */ |
|
| 269 | 269 | public function merge(BaseCollection $collection): BaseCollection |
| 270 | 270 | { |
| 271 | 271 | TypeCheck::isEqual( |
@@ -309,9 +309,9 @@ discard block |
||
| 309 | 309 | throw new InvalidOperationException('Can not call this method in map'); |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - /** |
|
| 313 | - * {@inheritedoc} |
|
| 314 | - */ |
|
| 312 | + /** |
|
| 313 | + * {@inheritedoc} |
|
| 314 | + */ |
|
| 315 | 315 | public function remove($key): void |
| 316 | 316 | { |
| 317 | 317 | if ($this->isEmpty()) { |
@@ -328,12 +328,12 @@ discard block |
||
| 328 | 328 | $this->data->offsetUnset($key); |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - /** |
|
| 332 | - * |
|
| 333 | - * @param int $offset |
|
| 334 | - * @param int|null $length |
|
| 335 | - * @return HashMap<T>|null |
|
| 336 | - */ |
|
| 331 | + /** |
|
| 332 | + * |
|
| 333 | + * @param int $offset |
|
| 334 | + * @param int|null $length |
|
| 335 | + * @return HashMap<T>|null |
|
| 336 | + */ |
|
| 337 | 337 | public function slice(int $offset, ?int $length = null): ?BaseCollection |
| 338 | 338 | { |
| 339 | 339 | $newData = array_slice($this->all(), $offset, $length, true); |
@@ -347,11 +347,11 @@ discard block |
||
| 347 | 347 | : null; |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - /** |
|
| 351 | - * |
|
| 352 | - * @param callable $callback |
|
| 353 | - * @return HashMap<T>|null |
|
| 354 | - */ |
|
| 350 | + /** |
|
| 351 | + * |
|
| 352 | + * @param callable $callback |
|
| 353 | + * @return HashMap<T>|null |
|
| 354 | + */ |
|
| 355 | 355 | public function sort(callable $callback): ?BaseCollection |
| 356 | 356 | { |
| 357 | 357 | $data = $this->all(); |
@@ -85,8 +85,7 @@ discard block |
||
| 85 | 85 | * @param mixed $valueType |
| 86 | 86 | * @param array<mixed, T> $initials |
| 87 | 87 | */ |
| 88 | - public function __construct($keyType, $valueType, array $initials = []) |
|
| 89 | - { |
|
| 88 | + public function __construct($keyType, $valueType, array $initials = []) { |
|
| 90 | 89 | $this->keyType = $keyType; |
| 91 | 90 | $this->valueType = $valueType; |
| 92 | 91 | |
@@ -158,8 +157,7 @@ discard block |
||
| 158 | 157 | * Return the type of the key |
| 159 | 158 | * @return mixed |
| 160 | 159 | */ |
| 161 | - public function getKeyType() |
|
| 162 | - { |
|
| 160 | + public function getKeyType() { |
|
| 163 | 161 | return $this->keyType; |
| 164 | 162 | } |
| 165 | 163 | |
@@ -167,8 +165,7 @@ discard block |
||
| 167 | 165 | * Return the type of the value |
| 168 | 166 | * @return mixed |
| 169 | 167 | */ |
| 170 | - public function getValueType() |
|
| 171 | - { |
|
| 168 | + public function getValueType() { |
|
| 172 | 169 | return $this->valueType; |
| 173 | 170 | } |
| 174 | 171 | |
@@ -254,8 +251,7 @@ discard block |
||
| 254 | 251 | * @param mixed $key |
| 255 | 252 | * @return T|null |
| 256 | 253 | */ |
| 257 | - public function get($key) |
|
| 258 | - { |
|
| 254 | + public function get($key) { |
|
| 259 | 255 | return $this->data->offsetExists($key) |
| 260 | 256 | ? $this->data->offsetGet($key)->getValue() |
| 261 | 257 | : null; |
@@ -296,16 +292,14 @@ discard block |
||
| 296 | 292 | /** |
| 297 | 293 | * {@inheritedoc} |
| 298 | 294 | */ |
| 299 | - public function first() |
|
| 300 | - { |
|
| 295 | + public function first() { |
|
| 301 | 296 | throw new InvalidOperationException('Can not call this method in map'); |
| 302 | 297 | } |
| 303 | 298 | |
| 304 | 299 | /** |
| 305 | 300 | * {@inheritedoc} |
| 306 | 301 | */ |
| 307 | - public function last() |
|
| 308 | - { |
|
| 302 | + public function last() { |
|
| 309 | 303 | throw new InvalidOperationException('Can not call this method in map'); |
| 310 | 304 | } |
| 311 | 305 | |