Exemplo n.º 1
0
 /**
  * Adds a set of elements as long no duplicates are found
  *
  * @param CollectionInterface $collection
  * @return boolean
  */
 public function addAll(CollectionInterface $collection = NULL)
 {
     $iterator = $collection->getIterator();
     foreach ($iterator as $element) {
         if ($this->contains($element)) {
             throw new \InvalidArgumentException('Duplicate element are not allowed');
         }
     }
     return parent::addAll($collection);
 }
Exemplo n.º 2
0
 /**
  *
  * @param CollectionInterface $collection
  * @return boolean
  */
 public function containsAll(CollectionInterface $collection)
 {
     $iterator = $collection->getIterator();
     foreach ($iterator as $element) {
         if (!$this->contains($element)) {
             return false;
         }
     }
     return true;
 }