@@ 217-230 (lines=14) @@ | ||
214 | * @param \ArrayAccess|array $items |
|
215 | * @return self |
|
216 | */ |
|
217 | public function diff($items) |
|
218 | { |
|
219 | $diff = new static; |
|
220 | ||
221 | $dictionary = $this->getDictionary($items); |
|
222 | ||
223 | foreach ($this->items as $item) { |
|
224 | if (!isset($dictionary[$this->getEntityKey($item)])) { |
|
225 | $diff->add($item); |
|
226 | } |
|
227 | } |
|
228 | ||
229 | return $diff; |
|
230 | } |
|
231 | ||
232 | /** |
|
233 | * Intersect the collection with the given items. |
|
@@ 239-252 (lines=14) @@ | ||
236 | * @throws MappingException |
|
237 | * @return self |
|
238 | */ |
|
239 | public function intersect($items) |
|
240 | { |
|
241 | $intersect = new static; |
|
242 | ||
243 | $dictionary = $this->getDictionary($items); |
|
244 | ||
245 | foreach ($this->items as $item) { |
|
246 | if (isset($dictionary[$this->getEntityKey($item)])) { |
|
247 | $intersect->add($item); |
|
248 | } |
|
249 | } |
|
250 | ||
251 | return $intersect; |
|
252 | } |
|
253 | ||
254 | /** |
|
255 | * Returns only the models from the collection with the specified keys. |