Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function generateSnippet(Environment $environment, StepNode $step)
 {
     if (!$environment instanceof ContextEnvironment) {
         throw new EnvironmentSnippetGenerationException(sprintf('ContextSnippetGenerator does not support `%s` environment.', get_class($environment)), $environment);
     }
     $contextClass = $this->getSnippetAcceptingContextClass($environment);
     $patternType = $this->getPatternType($contextClass);
     $stepText = $step->getText();
     $pattern = $this->patternTransformer->generatePattern($patternType, $stepText);
     $methodName = $this->getMethodName($contextClass, $pattern->getCanonicalText(), $pattern->getPattern());
     $methodArguments = $this->getMethodArguments($step, $pattern->getPlaceholderCount());
     $snippetTemplate = $this->getSnippetTemplate($pattern->getPattern(), $methodName, $methodArguments);
     return new ContextSnippet($step, $snippetTemplate, $contextClass);
 }