| @@ 169-183 (lines=15) @@ | ||
| 166 | return new self($items); |
|
| 167 | } |
|
| 168 | ||
| 169 | public function removeAll($value): self |
|
| 170 | { |
|
| 171 | $items = $this->items; |
|
| 172 | $keys = $this->searchAll($value); |
|
| 173 | ||
| 174 | if ($keys->isEmpty()) { |
|
| 175 | return $this; |
|
| 176 | } |
|
| 177 | ||
| 178 | foreach ($keys as $key) { |
|
| 179 | unset($items[$key]); |
|
| 180 | } |
|
| 181 | ||
| 182 | return new self($items); |
|
| 183 | } |
|
| 184 | ||
| 185 | public function removeKey(string $key): self |
|
| 186 | { |
|
| @@ 100-114 (lines=15) @@ | ||
| 97 | return new self($items); |
|
| 98 | } |
|
| 99 | ||
| 100 | public function replaceAll($searchValue, $replacementValue): self |
|
| 101 | { |
|
| 102 | $items = $this->items; |
|
| 103 | $indexes = $this->searchAll($searchValue); |
|
| 104 | ||
| 105 | if ($indexes->isEmpty()) { |
|
| 106 | return $this; |
|
| 107 | } |
|
| 108 | ||
| 109 | foreach ($indexes as $index) { |
|
| 110 | $items[$index] = $replacementValue; |
|
| 111 | } |
|
| 112 | ||
| 113 | return new self($items); |
|
| 114 | } |
|
| 115 | ||
| 116 | public function remove($value): self |
|
| 117 | { |
|
| @@ 126-140 (lines=15) @@ | ||
| 123 | return new self($items); |
|
| 124 | } |
|
| 125 | ||
| 126 | public function removeAll($value): self |
|
| 127 | { |
|
| 128 | $items = $this->items; |
|
| 129 | $indexes = $this->searchAll($value); |
|
| 130 | ||
| 131 | if ($indexes->isEmpty()) { |
|
| 132 | return $this; |
|
| 133 | } |
|
| 134 | ||
| 135 | foreach ($indexes as $index) { |
|
| 136 | unset($items[$index]); |
|
| 137 | } |
|
| 138 | ||
| 139 | return new self($items); |
|
| 140 | } |
|
| 141 | ||
| 142 | public function merge(self $other): self |
|
| 143 | { |
|