/** * Generates type using registered type builders * Uses the first (respecting priority of type builders) matched type builder to create a type * * @param TypeOutlineInterface $typeOutline * @param ImplementationInterface $implementation * @throws UnableToGenerateTypeException * @return TypeInterface */ public function generateType(TypeOutlineInterface $typeOutline, ImplementationInterface $implementation) { if ($this->schema && $this->schema->hasType($typeOutline->getName())) { return $this->schema->getType($typeOutline->getName()); } foreach ($this->typeBuilders as $builders) { foreach ($builders as $builder) { /* @var \Wookieb\ZorroDataSchema\Schema\Builder\TypeBuilders\TypeBuilderInterface $builder */ if ($builder->isAbleToGenerate($typeOutline)) { return $builder->generate($typeOutline, $implementation); } } } $msg = 'There is no type builder able to generate "' . $typeOutline->getName() . '" type outline'; throw new UnableToGenerateTypeException($msg, $typeOutline); }
protected function setUp() { $this->type = $this->getMockForAbstractClass('Wookieb\\ZorroDataSchema\\SchemaOutline\\TypeOutline\\TypeOutlineInterface'); $this->type->expects($this->any())->method('getName')->will($this->returnValue('OrnatePatient')); $this->object = new SchemaOutline(); }
/** * {@inheritDoc} */ public function addTypeOutline(TypeOutlineInterface $type) { $this->types[$type->getName()] = $type; return $this; }
public function isAbleToGenerate(TypeOutlineInterface $typeOutline) { return isset($this->map[$typeOutline->getName()]); }