Esempio n. 1
0
 /**
  * @param TypeInterface $type
  * @throws \Exception
  */
 public function addType(TypeInterface $type)
 {
     if (isset($this->types[$type->getName()])) {
         throw new \Exception();
         // todo
     }
     $this->types[$type->getName()] = $type;
 }
Esempio n. 2
0
 private function addType(TypeInterface $test)
 {
     if (array_key_exists($test->getAlias(), $this->types)) {
         $msg = 'Duplicate test alias %s!';
         throw new \RuntimeException(sprintf($msg, $test->getAlias()));
     }
     $this->types[$test->getAlias()] = $test;
 }
 /**
  * @param $value
  *
  * @return mixed
  */
 public function transform($value)
 {
     if ($value === null) {
         return;
     }
     $res = array();
     foreach ($value as $key => $item) {
         $res[$this->keyType->transform($key)] = $this->valueType->transform($item);
     }
     return $res;
 }
Esempio n. 4
0
 /**
  * Adds two types together and returns a new integer
  * @param TypeInterface $type
  */
 public function add(TypeInterface $type) : TypeInterface
 {
     return new static($this->toInt() + $type->toInt());
 }