appliesToContext() public method

public appliesToContext ( Phpro\SoapClient\CodeGenerator\Context\ContextInterface $context ) : boolean
$context Phpro\SoapClient\CodeGenerator\Context\ContextInterface
return boolean
Esempio n. 1
0
 /**
  * @param ContextInterface $context
  *
  * @return bool
  */
 public function appliesToContext(ContextInterface $context)
 {
     if (!$context instanceof TypeContext && !$context instanceof PropertyContext) {
         return false;
     }
     $type = $context->getType();
     if (!preg_match($this->regex, $type->getName())) {
         return false;
     }
     return $this->subRule->appliesToContext($context);
 }
Esempio n. 2
0
 /**
  * @param RuleInterface    $rule
  * @param ContextInterface $context
  */
 private function applyRule(RuleInterface $rule, ContextInterface $context)
 {
     if (!$rule->appliesToContext($context)) {
         return;
     }
     $rule->apply($context);
 }
Esempio n. 3
0
 function it_can_apply_to_multiple_other_rules(RuleInterface $rule1, RuleInterface $rule2, ContextInterface $context)
 {
     $rule1->appliesToContext($context)->willReturn(false);
     $rule1->apply($context)->shouldNotBeCalled();
     $rule2->appliesToContext($context)->willReturn(true);
     $rule2->apply($context)->shouldBeCalled();
     $this->apply($context);
 }
Esempio n. 4
0
 /**
  * @param ContextInterface $context
  *
  * @return bool
  */
 public function appliesToContext(ContextInterface $context)
 {
     if (!$context instanceof TypeContext && !$context instanceof PropertyContext) {
         return false;
     }
     $type = $context->getType();
     $typeExists = array_key_exists($type->getName(), $this->typeMap);
     // The default rule will be used here:
     if (!$typeExists) {
         return $this->defaultRule->appliesToContext($context);
     }
     // It's possible to define a null rule, which means that no code will be generated.
     $rule = $this->typeMap[$type->getName()];
     if ($rule === null) {
         return false;
     }
     return $rule->appliesToContext($context);
 }
 function it_can_apply_if_subrule_does_not_apply(RuleInterface $subRule, TypeContext $context)
 {
     $context->getType()->willReturn(new Type('MyNamespace', 'TypeName', []));
     $subRule->appliesToContext($context)->willReturn(false);
     $this->appliesToContext($context)->shouldReturn(false);
 }
Esempio n. 6
0
 function it_can_skip_rules(RuleInterface $rule, ContextInterface $context)
 {
     $rule->appliesToContext($context)->willReturn(false);
     $rule->apply($context)->shouldNotBeCalled();
     $this->applyRules($context);
 }
 function it_can_apply_if_subrule_does_not_apply(RuleInterface $subRule, PropertyContext $context)
 {
     $context->getProperty()->willReturn(new Property('MyProperty', 'string'));
     $subRule->appliesToContext($context)->willReturn(false);
     $this->appliesToContext($context)->shouldReturn(false);
 }