/**
  * {@inheritdoc}
  */
 public function transformArgument(CallCenter $callCenter, DefinitionCall $definitionCall, $argumentIndex, $argumentValue)
 {
     $call = new TransformationCall($definitionCall->getEnvironment(), $definitionCall->getCallee(), $this, array($argumentValue));
     $result = $callCenter->makeCall($call);
     if ($result->hasException()) {
         throw $result->getException();
     }
     return $result->getReturn();
 }
Example #2
0
 /**
  * Transforms argument value using transformation and returns a new one.
  *
  * @param RegexGenerator $regexGenerator
  * @param CallCenter     $callCenter
  * @param DefinitionCall $definitionCall
  * @param mixed          $argumentValue
  *
  * @return mixed
  *
  * @throws Exception If transformation throws exception
  */
 public function transformArgument(RegexGenerator $regexGenerator, CallCenter $callCenter, DefinitionCall $definitionCall, $argumentValue)
 {
     $regex = $regexGenerator->generateRegex($definitionCall->getEnvironment()->getSuite()->getName(), $this->pattern, $definitionCall->getFeature()->getLanguage());
     $this->match($regex, $argumentValue, $arguments);
     $call = new TransformationCall($definitionCall->getEnvironment(), $definitionCall->getCallee(), $this, $arguments);
     $result = $callCenter->makeCall($call);
     if ($result->hasException()) {
         throw $result->getException();
     }
     return $result->getReturn();
 }
 public function transformArgument(DefinitionCall $definitionCall, $argumentIndex, $argumentValue)
 {
     /** @var InitializedContextEnvironment $environment */
     $environment = $definitionCall->getEnvironment();
     $class = $this->getParameter($definitionCall->getCallee()->getReflection(), $argumentIndex)->getClass();
     foreach ($environment->getContexts() as $context) {
         if ($class->isInstance($context)) {
             return $context;
         }
     }
     return $argumentValue;
 }
 /**
  * Executes transformation.
  *
  * @param DefinitionCall $definitionCall
  * @param Transformation $transformation
  * @param array          $arguments
  *
  * @return mixed
  *
  * @throws Exception If transformation call throws one
  */
 private function execute(DefinitionCall $definitionCall, Transformation $transformation, array $arguments)
 {
     $call = new TransformationCall($definitionCall->getEnvironment(), $definitionCall->getCallee(), $transformation, $arguments);
     $result = $this->callCenter->makeCall($call);
     if ($result->hasException()) {
         throw $result->getException();
     }
     return $result->getReturn();
 }
Example #5
0
 /**
  * Extracts parameters from provided definition call.
  *
  * @param DefinitionCall $definitionCall
  *
  * @return ReflectionParameter[]
  */
 private function getCallParameters(DefinitionCall $definitionCall)
 {
     return $definitionCall->getCallee()->getReflection()->getParameters();
 }