canAssemble() 공개 메소드

public canAssemble ( Phpro\SoapClient\CodeGenerator\Context\ContextInterface $context ) : boolean
$context Phpro\SoapClient\CodeGenerator\Context\ContextInterface
리턴 boolean
예제 #1
0
 /**
  * @test
  */
 function it_can_assemble_property_context()
 {
     $assembler = new UseAssembler('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));
 }
예제 #2
0
 /**
  * @param ContextInterface $context
  * @param ClassGenerator   $class
  * @param Property         $property
  *
  * @throws \Zend\Code\Generator\Exception\InvalidArgumentException
  */
 private function implementGetResult(ContextInterface $context, ClassGenerator $class, Property $property)
 {
     $useAssembler = new UseAssembler($this->wrapperClass ?: ResultInterface::class);
     if ($useAssembler->canAssemble($context)) {
         $useAssembler->assemble($context);
     }
     $methodName = 'getResult';
     $class->removeMethod($methodName);
     $class->addMethodFromGenerator(MethodGenerator::fromArray(['name' => $methodName, 'parameters' => [], 'visibility' => MethodGenerator::VISIBILITY_PUBLIC, 'body' => $this->generateGetResultBody($property), 'docblock' => DocBlockGenerator::fromArray(['tags' => [['name' => 'return', 'description' => $this->generateGetResultReturnTag($property)]]])]));
 }
예제 #3
0
 /**
  * @param ContextInterface|TypeContext $context
  */
 public function assemble(ContextInterface $context)
 {
     $class = $context->getClass();
     try {
         $useAssembler = new UseAssembler($this->traitName, $this->traitAlias);
         if ($useAssembler->canAssemble($context)) {
             $useAssembler->assemble($context);
         }
         $traitAlias = $this->traitAlias ?: Normalizer::getClassNameFromFQN($this->traitName);
         $class->addTrait($traitAlias);
     } catch (\Exception $e) {
         throw AssemblerException::fromException($e);
     }
 }
예제 #4
0
 /**
  * @param ContextInterface|TypeContext $context
  */
 public function assemble(ContextInterface $context)
 {
     $class = $context->getClass();
     $interface = $this->interfaceName;
     try {
         $useAssembler = new UseAssembler($interface);
         if ($useAssembler->canAssemble($context)) {
             $useAssembler->assemble($context);
         }
         $interfaces = $class->getImplementedInterfaces();
         if (!in_array($interface, $interfaces)) {
             $interfaces[] = $interface;
             $class->setImplementedInterfaces($interfaces);
         }
     } catch (\Exception $e) {
         throw AssemblerException::fromException($e);
     }
 }