/**
  * Executes the type check if the collection is strict. Always
  * returns true, when the collection is not strictly typed
  *
  * @param mixed $value
  *
  * @return bool
  *
  * @throws \BuildR\Collection\Exception\CollectionException
  */
 protected function doTypeCheck($value)
 {
     if ($this->isStrict()) {
         $result = (bool) call_user_func_array($this->typeChecker, [$value]);
         if ($result === FALSE) {
             $message = $this->typeCheckFailMessage === NULL ? gettype($value) : $this->typeCheckFailMessage;
             throw CollectionException::typeException($message);
         }
         return TRUE;
     }
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 public function add($element)
 {
     if (!is_scalar($element)) {
         throw CollectionException::nonScalarTypeGiven(gettype($element));
     }
     if (!$this->contains($element)) {
         $this->data[] = $element;
     }
 }