@@ -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); |
@@ -85,8 +85,7 @@ discard block |
||
85 | 85 | * @param mixed $valueType |
86 | 86 | * @param array<mixed, mixed> $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 | |
@@ -155,8 +154,7 @@ discard block |
||
155 | 154 | * Return the type of the key |
156 | 155 | * @return mixed |
157 | 156 | */ |
158 | - public function getKeyType() |
|
159 | - { |
|
157 | + public function getKeyType() { |
|
160 | 158 | return $this->keyType; |
161 | 159 | } |
162 | 160 | |
@@ -164,8 +162,7 @@ discard block |
||
164 | 162 | * Return the type of the value |
165 | 163 | * @return mixed |
166 | 164 | */ |
167 | - public function getValueType() |
|
168 | - { |
|
165 | + public function getValueType() { |
|
169 | 166 | return $this->valueType; |
170 | 167 | } |
171 | 168 | |
@@ -246,8 +243,7 @@ discard block |
||
246 | 243 | /** |
247 | 244 | * {@inheritedoc} |
248 | 245 | */ |
249 | - public function get($key) |
|
250 | - { |
|
246 | + public function get($key) { |
|
251 | 247 | return $this->data->offsetExists($key) |
252 | 248 | ? $this->data->offsetGet($key)->getValue() |
253 | 249 | : null; |
@@ -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); |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | : null; |
217 | 217 | } |
218 | 218 | |
219 | - /** |
|
220 | - * {@inheritedoc} |
|
221 | - */ |
|
219 | + /** |
|
220 | + * {@inheritedoc} |
|
221 | + */ |
|
222 | 222 | public function equals(BaseCollection $collection): bool |
223 | 223 | { |
224 | 224 | if (!$collection instanceof self) { |
@@ -243,9 +243,9 @@ discard block |
||
243 | 243 | $this->initializePairs($data); |
244 | 244 | } |
245 | 245 | |
246 | - /** |
|
247 | - * {@inheritedoc} |
|
248 | - */ |
|
246 | + /** |
|
247 | + * {@inheritedoc} |
|
248 | + */ |
|
249 | 249 | public function get($key) |
250 | 250 | { |
251 | 251 | return $this->data->offsetExists($key) |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | : null; |
254 | 254 | } |
255 | 255 | |
256 | - /** |
|
257 | - * {@inheritedoc} |
|
258 | - * @param HashMap<T> $collection |
|
259 | - */ |
|
256 | + /** |
|
257 | + * {@inheritedoc} |
|
258 | + * @param HashMap<T> $collection |
|
259 | + */ |
|
260 | 260 | public function merge(BaseCollection $collection): BaseCollection |
261 | 261 | { |
262 | 262 | TypeCheck::isEqual( |
@@ -284,9 +284,9 @@ discard block |
||
284 | 284 | ); |
285 | 285 | } |
286 | 286 | |
287 | - /** |
|
288 | - * {@inheritedoc} |
|
289 | - */ |
|
287 | + /** |
|
288 | + * {@inheritedoc} |
|
289 | + */ |
|
290 | 290 | public function remove($key): void |
291 | 291 | { |
292 | 292 | if ($this->isEmpty()) { |
@@ -303,9 +303,9 @@ discard block |
||
303 | 303 | $this->data->offsetUnset($key); |
304 | 304 | } |
305 | 305 | |
306 | - /** |
|
307 | - * {@inheritedoc} |
|
308 | - */ |
|
306 | + /** |
|
307 | + * {@inheritedoc} |
|
308 | + */ |
|
309 | 309 | public function slice(int $offset, ?int $length = null): ?BaseCollection |
310 | 310 | { |
311 | 311 | $newData = array_slice($this->all(), $offset, $length, true); |
@@ -319,9 +319,9 @@ discard block |
||
319 | 319 | : null; |
320 | 320 | } |
321 | 321 | |
322 | - /** |
|
323 | - * {@inheritedoc} |
|
324 | - */ |
|
322 | + /** |
|
323 | + * {@inheritedoc} |
|
324 | + */ |
|
325 | 325 | public function sort(callable $callback): ?BaseCollection |
326 | 326 | { |
327 | 327 | $data = $this->all(); |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | : null; |
336 | 336 | } |
337 | 337 | |
338 | - /** |
|
339 | - * {@inheritedoc} |
|
340 | - */ |
|
338 | + /** |
|
339 | + * {@inheritedoc} |
|
340 | + */ |
|
341 | 341 | public function update($key, $value): bool |
342 | 342 | { |
343 | 343 | $this->validateEntry($key, $value); |
@@ -50,8 +50,7 @@ discard block |
||
50 | 50 | * Class Pair |
51 | 51 | * @package Platine\Collection\Map |
52 | 52 | */ |
53 | -class Pair |
|
54 | -{ |
|
53 | +class Pair { |
|
55 | 54 | |
56 | 55 | /** |
57 | 56 | * |
@@ -70,8 +69,7 @@ discard block |
||
70 | 69 | * @param mixed $key |
71 | 70 | * @param mixed $value |
72 | 71 | */ |
73 | - public function __construct($key, $value) |
|
74 | - { |
|
72 | + public function __construct($key, $value) { |
|
75 | 73 | $this->key = $key; |
76 | 74 | $this->value = $value; |
77 | 75 | } |
@@ -80,8 +78,7 @@ discard block |
||
80 | 78 | * |
81 | 79 | * @return mixed |
82 | 80 | */ |
83 | - public function getKey() |
|
84 | - { |
|
81 | + public function getKey() { |
|
85 | 82 | return $this->key; |
86 | 83 | } |
87 | 84 | |
@@ -89,8 +86,7 @@ discard block |
||
89 | 86 | * |
90 | 87 | * @return mixed |
91 | 88 | */ |
92 | - public function getValue() |
|
93 | - { |
|
89 | + public function getValue() { |
|
94 | 90 | return $this->value; |
95 | 91 | } |
96 | 92 |
@@ -54,8 +54,7 @@ discard block |
||
54 | 54 | * Class Stack |
55 | 55 | * @package Platine\Collection\Stack |
56 | 56 | */ |
57 | -class Stack implements Countable |
|
58 | -{ |
|
57 | +class Stack implements Countable { |
|
59 | 58 | |
60 | 59 | /** |
61 | 60 | * |
@@ -73,8 +72,7 @@ discard block |
||
73 | 72 | * Create new instance |
74 | 73 | * @param string $type |
75 | 74 | */ |
76 | - public function __construct(string $type) |
|
77 | - { |
|
75 | + public function __construct(string $type) { |
|
78 | 76 | $this->data = []; |
79 | 77 | $this->type = $type; |
80 | 78 | } |
@@ -108,8 +106,7 @@ discard block |
||
108 | 106 | /** |
109 | 107 | * @return mixed |
110 | 108 | */ |
111 | - public function peek() |
|
112 | - { |
|
109 | + public function peek() { |
|
113 | 110 | if ($this->isEmpty()) { |
114 | 111 | throw new InvalidOperationException('The collection is empty'); |
115 | 112 | } |
@@ -121,8 +118,7 @@ discard block |
||
121 | 118 | * |
122 | 119 | * @return mixed |
123 | 120 | */ |
124 | - public function pop() |
|
125 | - { |
|
121 | + public function pop() { |
|
126 | 122 | return array_pop($this->data); |
127 | 123 | } |
128 | 124 | |
@@ -132,8 +128,7 @@ discard block |
||
132 | 128 | * @param mixed $value |
133 | 129 | * @return mixed |
134 | 130 | */ |
135 | - public function push($value) |
|
136 | - { |
|
131 | + public function push($value) { |
|
137 | 132 | TypeCheck::isValueOf( |
138 | 133 | $value, |
139 | 134 | $this->type, |
@@ -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); |
@@ -73,8 +73,7 @@ discard block |
||
73 | 73 | * Create new instance |
74 | 74 | * @param array<mixed, mixed> $data |
75 | 75 | */ |
76 | - public function __construct(array $data = []) |
|
77 | - { |
|
76 | + public function __construct(array $data = []) { |
|
78 | 77 | foreach ($data as $value) { |
79 | 78 | $this->validateEntry($value); |
80 | 79 | } |
@@ -180,8 +179,7 @@ discard block |
||
180 | 179 | * @return mixed |
181 | 180 | * @throws OutOfRangeException |
182 | 181 | */ |
183 | - public function get(int $offset) |
|
184 | - { |
|
182 | + public function get(int $offset) { |
|
185 | 183 | if ($this->isEmpty()) { |
186 | 184 | throw new OutOfRangeException('The collection is empty'); |
187 | 185 | } |
@@ -268,8 +266,7 @@ discard block |
||
268 | 266 | * Return a random element of the collection |
269 | 267 | * @return mixed |
270 | 268 | */ |
271 | - public function rand() |
|
272 | - { |
|
269 | + public function rand() { |
|
273 | 270 | if ($this->isEmpty()) { |
274 | 271 | throw new InvalidOperationException('The collection is empty'); |
275 | 272 | } |
@@ -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); |
@@ -52,15 +52,13 @@ |
||
52 | 52 | * @template Object |
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, mixed> $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 | } |
@@ -55,16 +55,14 @@ |
||
55 | 55 | * @template T |
56 | 56 | * @extends Collection<T> |
57 | 57 | */ |
58 | -class TypedCollection extends Collection |
|
59 | -{ |
|
58 | +class TypedCollection extends Collection { |
|
60 | 59 | |
61 | 60 | /** |
62 | 61 | * Create new instance |
63 | 62 | * @param string $type |
64 | 63 | * @param array<mixed, mixed> $data |
65 | 64 | */ |
66 | - public function __construct(string $type, array $data = []) |
|
67 | - { |
|
65 | + public function __construct(string $type, array $data = []) { |
|
68 | 66 | $this->type = $type; |
69 | 67 | parent::__construct($data); |
70 | 68 | } |