| Total Complexity | 2 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | trait Purging |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * @see Purgeable::delete() |
||
| 23 | * @param int $index |
||
| 24 | * @return static |
||
| 25 | */ |
||
| 26 | public function delete(int $index) |
||
| 27 | { |
||
| 28 | $items = $this->items(); |
||
| 29 | unset($items[$index]); |
||
| 30 | return $this->newCopy($items); |
||
|
|
|||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @see Purgeable::remove() |
||
| 35 | * @param mixed ...$itemsToRemove |
||
| 36 | * @return static |
||
| 37 | */ |
||
| 38 | public function remove(...$itemsToRemove) |
||
| 44 | } |
||
| 45 | )); |
||
| 46 | } |
||
| 47 | |||
| 48 | /** @see Collection::items() */ |
||
| 49 | abstract public function items(): array; |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @see ImmutableCollection::newCopy() |
||
| 53 | * @param array $items |
||
| 54 | * @return Collection|static |
||
| 55 | */ |
||
| 56 | abstract protected function newCopy(array $items): Collection; |
||
| 57 | } |