4 * This file is part of the Behat.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Behat\Definition\Exception;
13 use Behat\Behat\Definition\Definition;
17 * Represents an exception caused by an ambiguous step definition match.
19 * If multiple definitions match the same step, behat is not able to determine which one is better and thus this
20 * exception is thrown and test suite is stopped.
22 * @author Konstantin Kudryashov <ever.zet@gmail.com>
24 final class AmbiguousMatchException extends RuntimeException implements SearchException
33 private $matches = array();
36 * Initializes ambiguous exception.
38 * @param string $text step description
39 * @param Definition[] $matches ambiguous matches (array of Definition's)
41 public function __construct($text, array $matches)
44 $this->matches = $matches;
46 $message = sprintf("Ambiguous match of \"%s\":", $text);
47 foreach ($matches as $definition) {
50 $definition->getPattern(),
51 $definition->getPath()
55 parent::__construct($message);