GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( 4aa098...31b0d3 )
by Baptiste
02:27
created

Collection.php (15 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\Immutable;
5
6
use Innmind\Immutable\Exception\SortException;
7
use Innmind\Immutable\Exception\OutOfBoundException;
8
use Innmind\Immutable\Exception\RuntimeException;
9
use Innmind\Immutable\Exception\InvalidArgumentException;
10
use Innmind\Immutable\Exception\LogicException;
11
12
class Collection implements CollectionInterface
13
{
14
    private $values;
15
16 139
    public function __construct(array $values)
17
    {
18 139
        $this->values = $values;
19 139
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 97
    public function toPrimitive()
25
    {
26 97
        return $this->values;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32 2
    public function filter(callable $filter = null): CollectionInterface
33
    {
34 2
        if ($filter === null) {
35 2
            $values = array_filter($this->values);
36
        } else {
37 2
            $values = array_filter(
38 2
                $this->values,
39
                $filter,
40 2
                ARRAY_FILTER_USE_BOTH
41
            );
42
        }
43
44 2
        return new self($values);
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50 2
    public function intersect(CollectionInterface $collection): CollectionInterface
51
    {
52 2
        return new self(array_intersect(
53 2
            $this->values,
54 2
            $collection->toPrimitive()
55
        ));
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61 2 View Code Duplication
    public function chunk(int $size): CollectionInterface
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
62
    {
63 2
        $chunks = array_chunk($this->values, $size);
64 2
        $subs = [];
65
66 2
        foreach ($chunks as $chunk) {
67 2
            $subs[] = new self($chunk);
68
        }
69
70 2
        return new self($subs);
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76 2
    public function shift(): CollectionInterface
77
    {
78 2
        $values = $this->values;
79 2
        array_shift($values);
80
81 2
        return new self($values);
82
    }
83
84
    /**
85
     * {@inheritdoc}
86
     */
87 1
    public function reduce(callable $reducer, $initial = null)
88
    {
89 1
        return array_reduce($this->values, $reducer, $initial);
90
    }
91
92
    /**
93
     * {@inheritdoc}
94
     */
95 1
    public function search($needle, bool $strict = true)
96
    {
97 1
        return array_search($needle, $this->values, (bool) $strict);
98
    }
99
100
    /**
101
     * {@inheritdoc}
102
     */
103 2
    public function uintersect(CollectionInterface $collection, callable $intersecter): CollectionInterface
104
    {
105 2
        return new self(array_uintersect(
106 2
            $this->values,
107 2
            $collection->toPrimitive(),
108
            $intersecter
109
        ));
110
    }
111
112
    /**
113
     * {@inheritdoc}
114
     */
115 2
    public function keyIntersect(CollectionInterface $collection): CollectionInterface
116
    {
117 2
        return new self(array_intersect_key(
118 2
            $this->values,
119 2
            $collection->toPrimitive()
120
        ));
121
    }
122
123
    /**
124
     * {@inheritdoc}
125
     */
126 3
    public function map(callable $mapper): CollectionInterface
127
    {
128 3
        return new self(array_map($mapper, $this->values));
129
    }
130
131
    /**
132
     * {@inheritdoc}
133
     */
134 2
    public function pad(int $size, $value): CollectionInterface
135
    {
136 2
        return new self(array_pad($this->values, $size, $value));
137
    }
138
139
    /**
140
     * {@inheritdoc}
141
     */
142 2
    public function pop(): CollectionInterface
143
    {
144 2
        $values = $this->values;
145 2
        array_pop($values);
146
147 2
        return new self($values);
148
    }
149
150
    /**
151
     * {@inheritdoc}
152
     */
153 1
    public function sum()
154
    {
155 1
        return array_sum($this->values);
156
    }
157
158
    /**
159
     * {@inheritdoc}
160
     */
161 2
    public function diff(CollectionInterface $collection): CollectionInterface
162
    {
163 2
        return new self(array_diff($this->values, $collection->toPrimitive()));
164
    }
165
166
    /**
167
     * {@inheritdoc}
168
     */
169 1
    public function flip(): CollectionInterface
170
    {
171 1
        return new self(array_flip($this->values));
172
    }
173
174
    /**
175
     * {@inheritdoc}
176
     */
177 1
    public function keys($search = null, bool $strict = true): CollectionInterface
178
    {
179 1
        $args = func_get_args();
180
181 1
        if (count($args) > 0) {
182 1
            $keys = array_keys($this->values, $search, (bool) $strict);
183
        } else {
184 1
            $keys = array_keys($this->values);
185
        }
186
187 1
        return new self($keys);
188
    }
189
190
    /**
191
     * {@inheritdoc}
192
     */
193 2
    public function push($value): CollectionInterface
194
    {
195 2
        $values = $this->values;
196 2
        array_push($values, $value);
197
198 2
        return new self($values);
199
    }
200
201
    /**
202
     * {@inheritdoc}
203
     */
204 4
    public function rand(int $num = 1): CollectionInterface
205
    {
206 4
        if ($num > $this->count()) {
207 2
            throw new OutOfBoundException(
208 2
                'Trying to return a wider collection than the current one'
209
            );
210
        }
211
212 2
        $keys = (array) array_rand($this->values, $num);
213 2
        $values = [];
214
215 2
        foreach ($keys as $key) {
216 2
            $values[$key] = $this->values[$key];
217
        }
218
219 2
        return new self($values);
220
    }
221
222
    /**
223
     * {@inheritdoc}
224
     */
225 2
    public function merge(CollectionInterface $collection): CollectionInterface
226
    {
227 2
        return new self(array_merge(
228 2
            $this->values,
229 2
            $collection->toPrimitive()
230
        ));
231
    }
232
233
    /**
234
     * {@inheritdoc}
235
     */
236 2
    public function slice(int $offset, int $length = null, bool $preserveKeys = false): CollectionInterface
237
    {
238 2
        return new self(array_slice(
239 2
            $this->values,
240
            $offset,
241 2
            $length === null ? null : $length,
242
            $preserveKeys
243
        ));
244
    }
245
246
    /**
247
     * {@inheritdoc}
248
     */
249 2
    public function udiff(CollectionInterface $collection, callable $differ): CollectionInterface
250
    {
251 2
        return new self(array_udiff(
252 2
            $this->values,
253 2
            $collection->toPrimitive(),
254
            $differ
255
        ));
256
    }
257
258
    /**
259
     * {@inheritdoc}
260
     */
261 1
    public function column($key, $indexKey = null): CollectionInterface
262
    {
263 1
        return new self(array_column(
264 1
            $this->values,
265
            $key,
266
            $indexKey
267
        ));
268
    }
269
270
    /**
271
     * {@inheritdoc}
272
     */
273 2
    public function splice(int $offset, int $length = 0, $replacement = []): CollectionInterface
274
    {
275 2
        $values = $this->values;
276 2
        array_splice($values, $offset, $length, $replacement);
277
278 2
        return new self($values);
279
    }
280
281
    /**
282
     * {@inheritdoc}
283
     */
284 2
    public function unique(int $flags = self::SORT_REGULAR): CollectionInterface
285
    {
286 2
        return new self(array_unique($this->values, $flags));
287
    }
288
289
    /**
290
     * {@inheritdoc}
291
     */
292 2
    public function values(): CollectionInterface
293
    {
294 2
        return new self(array_values($this->values));
295
    }
296
297
    /**
298
     * {@inheritdoc}
299
     */
300 1
    public function product()
301
    {
302 1
        return array_product($this->values);
303
    }
304
305
    /**
306
     * {@inheritdoc}
307
     */
308 2
    public function replace(CollectionInterface $collection): CollectionInterface
309
    {
310 2
        return new self(array_replace(
311 2
            $this->values,
312 2
            $collection->toPrimitive()
313
        ));
314
    }
315
316
    /**
317
     * {@inheritdoc}
318
     */
319 2
    public function reverse(bool $preserveKeys = false): CollectionInterface
320
    {
321 2
        return new self(array_reverse($this->values, $preserveKeys));
322
    }
323
324
    /**
325
     * {@inheritdoc}
326
     */
327 2
    public function unshift($value): CollectionInterface
328
    {
329 2
        $values = $this->values;
330 2
        array_unshift($values, $value);
331
332 2
        return new self($values);
333
    }
334
335
    /**
336
     * {@inheritdoc}
337
     */
338 2
    public function keyDiff(CollectionInterface $collection): CollectionInterface
339
    {
340 2
        return new self(array_diff_key(
341 2
            $this->values,
342 2
            $collection->toPrimitive()
343
        ));
344
    }
345
346
    /**
347
     * {@inheritdoc}
348
     */
349 2
    public function ukeyDiff(CollectionInterface $collection, callable $differ): CollectionInterface
350
    {
351 2
        return new self(array_diff_ukey(
352 2
            $this->values,
353 2
            $collection->toPrimitive(),
354
            $differ
355
        ));
356
    }
357
358
    /**
359
     * {@inheritdoc}
360
     */
361 2
    public function associativeDiff(CollectionInterface $collection): CollectionInterface
362
    {
363 2
        return new self(array_diff_assoc(
364 2
            $this->values,
365 2
            $collection->toPrimitive()
366
        ));
367
    }
368
369
    /**
370
     * {@inheritdoc}
371
     */
372 47
    public function hasKey($key, bool $strict = true): bool
373
    {
374 47
        if ($strict === true) {
375 47
            $bool = array_key_exists($key, $this->values);
376
        } else {
377 1
            $bool = isset($this->values[$key]);
378
        }
379
380 47
        return $bool;
381
    }
382
383
    /**
384
     * {@inheritdoc}
385
     */
386 1
    public function countValues(): CollectionInterface
387
    {
388 1
        return new self(array_count_values($this->values));
389
    }
390
391
    /**
392
     * {@inheritdoc}
393
     */
394 2
    public function ukeyIntersect(CollectionInterface $collection, callable $intersecter): CollectionInterface
395
    {
396 2
        return new self(array_intersect_ukey(
397 2
            $this->values,
398 2
            $collection->toPrimitive(),
399
            $intersecter
400
        ));
401
    }
402
403
    /**
404
     * {@inheritdoc}
405
     */
406 2
    public function associativeIntersect(CollectionInterface $collection): CollectionInterface
407
    {
408 2
        return new self(array_intersect_assoc(
409 2
            $this->values,
410 2
            $collection->toPrimitive()
411
        ));
412
    }
413
414
    /**
415
     * {@inheritdoc}
416
     */
417 2 View Code Duplication
    public function sort(int $flags = self::SORT_REGULAR): CollectionInterface
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
418
    {
419 2
        $values = $this->values;
420 2
        $bool = sort($values, $flags);
421
422 2
        if ($bool === false) {
423
            throw new SortException('Sort failure');
424
        }
425
426 2
        return new self($values);
427
    }
428
429
    /**
430
     * {@inheritdoc}
431
     */
432 2 View Code Duplication
    public function associativeSort(int $flags = self::SORT_REGULAR): CollectionInterface
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
433
    {
434 2
        $values = $this->values;
435 2
        $bool = asort($values, $flags);
436
437 2
        if ($bool === false) {
438
            throw new SortException('Sort failure');
439
        }
440
441 2
        return new self($values);
442
    }
443
444
    /**
445
     * {@inheritdoc}
446
     */
447 2 View Code Duplication
    public function keySort(int $flags = self::SORT_REGULAR): CollectionInterface
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
448
    {
449 2
        $values = $this->values;
450 2
        $bool = ksort($values, $flags);
451
452 2
        if ($bool === false) {
453
            throw new SortException('Sort failure');
454
        }
455
456 2
        return new self($values);
457
    }
458
459
    /**
460
     * {@inheritdoc}
461
     */
462 2 View Code Duplication
    public function ukeySort(callable $sorter): CollectionInterface
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
463
    {
464 2
        $values = $this->values;
465 2
        $bool = uksort($values, $sorter);
466
467 2
        if ($bool === false) {
468
            throw new SortException('Sort failure');
469
        }
470
471 2
        return new self($values);
472
    }
473
474
    /**
475
     * {@inheritdoc}
476
     */
477 2 View Code Duplication
    public function reverseSort(int $flags = self::SORT_REGULAR): CollectionInterface
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
478
    {
479 2
        $values = $this->values;
480 2
        $bool = rsort($values, $flags);
481
482 2
        if ($bool === false) {
483
            throw new SortException('Sort failure');
484
        }
485
486 2
        return new self($values);
487
    }
488
489
    /**
490
     * {@inheritdoc}
491
     */
492 2 View Code Duplication
    public function usort(callable $sorter): CollectionInterface
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
493
    {
494 2
        $values = $this->values;
495 2
        $bool = usort($values, $sorter);
496
497 2
        if ($bool === false) {
498
            throw new SortException('Sort failure');
499
        }
500
501 2
        return new self($values);
502
    }
503
504
    /**
505
     * {@inheritdoc}
506
     */
507 2 View Code Duplication
    public function associativeReverseSort(int $flags = self::SORT_REGULAR): CollectionInterface
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
508
    {
509 2
        $values = $this->values;
510 2
        $bool = arsort($values, $flags);
511
512 2
        if ($bool === false) {
513
            throw new SortException('Sort failure');
514
        }
515
516 2
        return new self($values);
517
    }
518
519
    /**
520
     * {@inheritdoc}
521
     */
522 2 View Code Duplication
    public function keyReverseSort(int $flags = self::SORT_REGULAR): CollectionInterface
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
523
    {
524 2
        $values = $this->values;
525 2
        $bool = krsort($values, $flags);
526
527 2
        if ($bool === false) {
528
            throw new SortException('Sort failure');
529
        }
530
531 2
        return new self($values);
532
    }
533
534
    /**
535
     * {@inheritdoc}
536
     */
537 2 View Code Duplication
    public function uassociativeSort(callable $sorter): CollectionInterface
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
538
    {
539 2
        $values = $this->values;
540 2
        $bool = uasort($values, $sorter);
541
542 2
        if ($bool === false) {
543
            throw new SortException('Sort failure');
544
        }
545
546 2
        return new self($values);
547
    }
548
549
    /**
550
     * {@inheritdoc}
551
     */
552 2 View Code Duplication
    public function naturalSort(): CollectionInterface
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
553
    {
554 2
        $values = $this->values;
555 2
        $bool = natsort($values);
556
557 2
        if ($bool === false) {
558
            throw new SortException('Sort failure');
559
        }
560
561 2
        return new self($values);
562
    }
563
564
    /**
565
     * {@inheritdoc}
566
     */
567 2 View Code Duplication
    public function first()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
568
    {
569 2
        if ($this->count() === 0) {
570 1
            throw new OutOfBoundException('There is no first item');
571
        }
572
573 1
        return array_values($this->values)[0];
574
    }
575
576
    /**
577
     * {@inheritdoc}
578
     */
579 2 View Code Duplication
    public function last()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
580
    {
581 2
        if ($this->count() === 0) {
582 1
            throw new OutOfBoundException('There is no last item');
583
        }
584
585 1
        $values = array_values($this->values);
586
587 1
        return end($values);
588
    }
589
590
    /**
591
     * {@inheritdoc}
592
     */
593 1
    public function each(\Closure $callback): CollectionInterface
594
    {
595 1
        foreach ($this->values as $key => $value) {
596 1
            $callback($key, $value);
597
        }
598
599 1
        return $this;
600
    }
601
602
    /**
603
     * {@inheritdoc}
604
     */
605 2
    public function join(string $separator): string
606
    {
607 2
        return implode($separator, $this->values);
608
    }
609
610
    /**
611
     * {@inheritdoc}
612
     */
613 2 View Code Duplication
    public function shuffle(): CollectionInterface
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
614
    {
615 2
        $values = $this->values;
616 2
        $result = shuffle($values);
617
618 2
        if ($result === false) {
619
            throw new RuntimeException('Shuffle operation failed');
620
        }
621
622 2
        return new self($values);
623
    }
624
625
    /**
626
     * {@inheritdoc}
627
     */
628 2
    public function take(int $size, bool $preserveKeys = false): CollectionInterface
629
    {
630 2
        $took = [];
631 2
        $keys = array_keys($this->values);
632
633 2
        while (count($took) < $size) {
634
            do {
635 2
                $random = mt_rand(0, count($keys) - 1);
636 2
            } while (!isset($keys[$random]));
637 2
            $key = $keys[$random];
638 2
            $took[$key] = $this->values[$key];
639 2
            unset($keys[$random]);
640
        }
641
642 2
        if ($preserveKeys === false) {
643 2
            $took = array_values($took);
644
        }
645
646 2
        return new self($took);
647
    }
648
649
    /**
650
     * {@inheritdoc}
651
     */
652 2
    public function grep(string $pattern, bool $revert = false): CollectionInterface
653
    {
654 2
        return new self(preg_grep(
655
            $pattern,
656 2
            $this->values,
657 2
            $revert === false ? 0 : PREG_GREP_INVERT
658
        ));
659
    }
660
661
    /**
662
     * {@inheritdoc}
663
     */
664 2
    public function set($key, $value): CollectionInterface
665
    {
666 2
        $values = $this->values;
667 2
        $values[$key] = $value;
668
669 2
        return new self($values);
670
    }
671
672
    /**
673
     * {@inheritdoc}
674
     */
675 2
    public function contains($value): bool
676
    {
677 2
        return in_array($value, $this->values, true);
678
    }
679
680
    /**
681
     * {@inheritdoc}
682
     */
683 2
    public function get($key)
684
    {
685 2
        return $this->offsetGet($key);
686
    }
687
688
    /**
689
     * {@inheritdoc}
690
     */
691 2 View Code Duplication
    public function walk(callable $walker): CollectionInterface
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
692
    {
693 2
        $values = $this->values;
694
695 2
        if (array_walk($values, $walker) === false) {
696
            throw new RuntimeException('Walk operation failed');
697
        }
698
699 2
        return new self($values);
700
    }
701
702
    /**
703
     * {@inheritdoc}
704
     */
705 4
    public function unset($index): CollectionInterface
706
    {
707 4
        if (!$this->hasKey($index)) {
708 2
            throw new InvalidArgumentException(sprintf(
709 2
                'Unknown index %s',
710
                $index
711
            ));
712
        }
713
714 2
        $values = $this->values;
715 2
        unset($values[$index]);
716
717 2
        return new self($values);
718
    }
719
720
    /**
721
     * {@inheritdoc}
722
     */
723 15
    public function count(): int
724
    {
725 15
        return count($this->values);
726
    }
727
728
    /**
729
     * {@inheritdoc}
730
     */
731 4
    public function current()
732
    {
733 4
        return current($this->values);
734
    }
735
736
    /**
737
     * {@inheritdoc}
738
     */
739 4
    public function key()
740
    {
741 4
        return key($this->values);
742
    }
743
744
    /**
745
     * {@inheritdoc}
746
     */
747 4
    public function next()
748
    {
749 4
        next($this->values);
750 4
    }
751
752
    /**
753
     * {@inheritdoc}
754
     */
755 4
    public function rewind()
756
    {
757 4
        reset($this->values);
758 4
    }
759
760
    /**
761
     * {@inheritdoc}
762
     */
763 4
    public function valid(): bool
764
    {
765 4
        return $this->key() !== null;
766
    }
767
768
    /**
769
     * {@inheritdoc}
770
     */
771 1
    public function offsetExists($offset): bool
772
    {
773 1
        return $this->hasKey($offset);
774
    }
775
776
    /**
777
     * {@inheritdoc}
778
     */
779 42
    public function offsetGet($offset)
780
    {
781 42
        if (!$this->hasKey($offset)) {
782 2
            throw new InvalidArgumentException(sprintf(
783 2
                'Unknown index %s',
784
                $offset
785
            ));
786
        }
787
788 40
        return $this->values[$offset];
789
    }
790
791
    /**
792
     * {@inheritdoc}
793
     */
794 1
    public function offsetSet($offset, $value)
795
    {
796 1
        throw new LogicException('You can\'t modify an immutable collection');
797
    }
798
799
    /**
800
     * {@inheritdoc}
801
     */
802 1
    public function offsetUnset($offset)
803
    {
804 1
        throw new LogicException('You can\'t modify an immutable collection');
805
    }
806
}
807