assemble() public method

public assemble ( Phpro\SoapClient\CodeGenerator\Context\ContextInterface $context )
$context Phpro\SoapClient\CodeGenerator\Context\ContextInterface
Exemplo n.º 1
0
 /**
  * @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);
     }
 }
Exemplo n.º 2
0
 /**
  * @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);
     }
 }
Exemplo n.º 3
0
    /**
     * @test
     */
    function it_assembles_a_type()
    {
        $assembler = new InterfaceAssembler(\Iterator::class);
        $context = $this->createContext();
        $assembler->assemble($context);
        $code = $context->getClass()->generate();
        $expected = <<<CODE
namespace MyNamespace;

use Iterator;

class MyType implements Iterator
{


}

CODE;
        $this->assertEquals($expected, $code);
    }