Пример #1
0
 public function add(string $key, string $type, array $options = []) : BaseNode
 {
     $child = $this->typeHandler->getType($type);
     if (isset($options['handler'])) {
         /** @var InputHandler $handler */
         $handler = $options['handler'];
         $handler->setRootType($type);
         $handler->define();
         $child = $handler->getRoot();
     }
     if (isset($options['required'])) {
         $child->setRequired($options['required']);
     }
     if (isset($options['default'])) {
         $child->setDefault($options['default']);
     }
     if (isset($options['instantiator'])) {
         $child->setInstantiator($options['instantiator']);
     }
     if (isset($options['transformer'])) {
         $child->setTransformer($options['transformer']);
     }
     if (isset($options['constraints'])) {
         $child->setConstraints($options['constraints']);
     }
     if (isset($options['allow_null'])) {
         $child->setAllowNull($options['allow_null']);
     }
     $this->children[$key] = $child;
     return $child;
 }
Пример #2
0
 public function add(string $key, string $type, array $options = []) : BaseNode
 {
     $child = $this->typeHandler->getType($type);
     $child->setTypeHandler($this->typeHandler);
     if (isset($options['required'])) {
         $child->setRequired($options['required']);
     }
     if (isset($options['default'])) {
         $child->setDefault($options['default']);
     }
     if (isset($options['instantiator'])) {
         $child->setInstantiator($options['instantiator']);
     }
     if (isset($options['transformer'])) {
         $child->setTransformer($options['transformer']);
     }
     if (isset($options['constraints'])) {
         $child->setConstraints($options['constraints']);
     }
     $this->children[$key] = $child;
     return $child;
 }
Пример #3
0
 public function testIsDetectingConflictWithCaseInsensitive()
 {
     $typeHandler = new TypeHandler();
     $type = $typeHandler->getType('datetime');
     $this->assertInstanceOf(DateTimeNode::class, $type);
 }
Пример #4
0
 public function setRootType(string $type)
 {
     $this->root = $this->typeHandler->getType($type);
 }