| @@ 85-93 (lines=9) @@ | ||
| 82 | * @param bool $strict |
|
| 83 | * @return bool |
|
| 84 | */ |
|
| 85 | public function removeAll(CollectionInterface $collection, bool $strict = true): bool |
|
| 86 | { |
|
| 87 | $size = $this->count(); |
|
| 88 | foreach ($collection as $element) { |
|
| 89 | $this->remove($element, $strict); |
|
| 90 | } |
|
| 91 | ||
| 92 | return $size !== $this->count(); |
|
| 93 | } |
|
| 94 | ||
| 95 | /** |
|
| 96 | * Remove all items from this collection that don't exist in specified collection |
|
| @@ 107-117 (lines=11) @@ | ||
| 104 | * @param bool $strict |
|
| 105 | * @return bool |
|
| 106 | */ |
|
| 107 | public function retainAll(CollectionInterface $collection, bool $strict = true): bool |
|
| 108 | { |
|
| 109 | $size = $this->count(); |
|
| 110 | foreach ($this as $element) { |
|
| 111 | if (!$collection->contains($element, $strict)) { |
|
| 112 | $this->remove($element, $strict); |
|
| 113 | } |
|
| 114 | } |
|
| 115 | ||
| 116 | return $size !== $this->count(); |
|
| 117 | } |
|
| 118 | ||
| 119 | /** |
|
| 120 | * Use a closure to determine existence in the collection |
|
| @@ 74-82 (lines=9) @@ | ||
| 71 | * @param bool $strict |
|
| 72 | * @return bool |
|
| 73 | */ |
|
| 74 | public function addAll(CollectionInterface $collection, bool $strict = true): bool |
|
| 75 | { |
|
| 76 | $size = $this->count(); |
|
| 77 | foreach ($collection as $element) { |
|
| 78 | $this->add($element, $strict); |
|
| 79 | } |
|
| 80 | ||
| 81 | return $size !== $this->count(); |
|
| 82 | } |
|
| 83 | ||
| 84 | /** |
|
| 85 | * Removes all elements from a collection |
|