예제 #1
0
 /**
  * @todo Generator...
  *
  * @param mixed $element
  * @param int   $times
  *
  * @return Collection
  */
 public static function repeat($element, $times)
 {
     $builder = new CollectionBuilder($times);
     for ($step = 0; $step < $times; $step++) {
         $builder->add($element);
     }
     return $builder->build();
 }
예제 #2
0
 /**
  * Adds only unique elements.
  *
  * @param mixed $element
  *
  * @return \Colada\SetBuilder
  */
 public function add($element)
 {
     foreach ($this->array as $collectionElement) {
         if (ComparisonHelper::isEquals($element, $collectionElement)) {
             // Duplicate.
             return $this;
         }
     }
     return parent::add($element);
 }