Example #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);
 }