@@ 205-216 (lines=12) @@ | ||
202 | return new self($items); |
|
203 | } |
|
204 | ||
205 | public function intersect(self $other): self |
|
206 | { |
|
207 | $items = []; |
|
208 | ||
209 | foreach ($this->items as $key => $item) { |
|
210 | if ($other->contains($item)) { |
|
211 | $items[$key] = $item; |
|
212 | } |
|
213 | } |
|
214 | ||
215 | return new self($items); |
|
216 | } |
|
217 | ||
218 | public function intersectKeys(self $other): self |
|
219 | { |
|
@@ 218-229 (lines=12) @@ | ||
215 | return new self($items); |
|
216 | } |
|
217 | ||
218 | public function intersectKeys(self $other): self |
|
219 | { |
|
220 | $items = []; |
|
221 | ||
222 | foreach ($this->items as $key => $item) { |
|
223 | if ($other->containsKey($key)) { |
|
224 | $items[$key] = $item; |
|
225 | } |
|
226 | } |
|
227 | ||
228 | return new self($items); |
|
229 | } |
|
230 | ||
231 | public function diff(self $other): self |
|
232 | { |
|
@@ 231-242 (lines=12) @@ | ||
228 | return new self($items); |
|
229 | } |
|
230 | ||
231 | public function diff(self $other): self |
|
232 | { |
|
233 | $items = []; |
|
234 | ||
235 | foreach ($this->items as $key => $item) { |
|
236 | if (!$other->contains($item)) { |
|
237 | $items[$key] = $item; |
|
238 | } |
|
239 | } |
|
240 | ||
241 | return new self($items); |
|
242 | } |
|
243 | ||
244 | public function diffKeys(self $other): self |
|
245 | { |
|
@@ 244-255 (lines=12) @@ | ||
241 | return new self($items); |
|
242 | } |
|
243 | ||
244 | public function diffKeys(self $other): self |
|
245 | { |
|
246 | $items = []; |
|
247 | ||
248 | foreach ($this->items as $key => $item) { |
|
249 | if (!$other->containsKey($key)) { |
|
250 | $items[$key] = $item; |
|
251 | } |
|
252 | } |
|
253 | ||
254 | return new self($items); |
|
255 | } |
|
256 | ||
257 | /** |
|
258 | * The filter callable is given an item and it's key, and should |
@@ 149-160 (lines=12) @@ | ||
146 | return new self($items); |
|
147 | } |
|
148 | ||
149 | public function intersect(self $other): self |
|
150 | { |
|
151 | $items = []; |
|
152 | ||
153 | foreach ($this->items as $item) { |
|
154 | if ($other->contains($item)) { |
|
155 | $items[] = $item; |
|
156 | } |
|
157 | } |
|
158 | ||
159 | return new self($items); |
|
160 | } |
|
161 | ||
162 | public function diff(self $other): self |
|
163 | { |
|
@@ 162-173 (lines=12) @@ | ||
159 | return new self($items); |
|
160 | } |
|
161 | ||
162 | public function diff(self $other): self |
|
163 | { |
|
164 | $items = []; |
|
165 | ||
166 | foreach ($this->items as $item) { |
|
167 | if (!$other->contains($item)) { |
|
168 | $items[] = $item; |
|
169 | } |
|
170 | } |
|
171 | ||
172 | return new self($items); |
|
173 | } |
|
174 | ||
175 | /** |
|
176 | * The filter callable is given an item, and should return |