/**
  * {@inheritdoc}
  *
  * @throws AmbiguousMatchException
  */
 public function searchDefinition(Environment $environment, FeatureNode $feature, StepNode $step)
 {
     $suite = $environment->getSuite();
     $language = $feature->getLanguage();
     $stepText = $step->getText();
     $multi = $step->getArguments();
     $definitions = array();
     $result = null;
     foreach ($this->repository->getEnvironmentDefinitions($environment) as $definition) {
         $definition = $this->translator->translateDefinition($suite, $definition, $language);
         if (!($newResult = $this->match($definition, $stepText, $multi))) {
             continue;
         }
         $result = $newResult;
         $definitions[] = $newResult->getMatchedDefinition();
     }
     if (count($definitions) > 1) {
         throw new AmbiguousMatchException($result->getMatchedText(), $definitions);
     }
     return $result;
 }
 /**
  * Translates definition using translator.
  *
  * @param Suite      $suite
  * @param Definition $definition
  *
  * @return Definition
  */
 protected final function translateDefinition(Suite $suite, Definition $definition)
 {
     return $this->translator->translateDefinition($suite, $definition);
 }