public canAssemble ( Phpro\SoapClient\CodeGenerator\Context\ContextInterface $context ) : boolean | ||
$context | Phpro\SoapClient\CodeGenerator\Context\ContextInterface | |
return | boolean |
/** * @test */ function it_can_assemble_property_context() { $assembler = new InterfaceAssembler('MyUsedClass'); $class = new ClassGenerator('MyType', 'MyNamespace'); $type = new Type('MyNamespace', 'MyType', []); $property = new Property('prop1', 'string'); $context = new PropertyContext($class, $type, $property); $this->assertTrue($assembler->canAssemble($context)); }
/** * @param ContextInterface|TypeContext $context * * @throws AssemblerException */ public function assemble(ContextInterface $context) { try { $interfaceAssembler = new InterfaceAssembler(RequestInterface::class); if ($interfaceAssembler->canAssemble($context)) { $interfaceAssembler->assemble($context); } } catch (\Exception $e) { throw AssemblerException::fromException($e); } }
/** * @param ContextInterface|TypeContext $context * * @throws AssemblerException */ public function assemble(ContextInterface $context) { $class = $context->getClass(); $properties = $context->getType()->getProperties(); $firstProperty = count($properties) ? current($properties) : null; try { $interfaceAssembler = new InterfaceAssembler(\IteratorAggregate::class); if ($interfaceAssembler->canAssemble($context)) { $interfaceAssembler->assemble($context); } if ($firstProperty) { $this->implementGetIterator($class, $firstProperty); } } catch (\Exception $e) { throw AssemblerException::fromException($e); } }