Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Behat / Definition / Exception / AmbiguousMatchException.php
1 <?php
2
3 /*
4  * This file is part of the Behat.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 namespace Behat\Behat\Definition\Exception;
12
13 use Behat\Behat\Definition\Definition;
14 use RuntimeException;
15
16 /**
17  * Represents an exception caused by an ambiguous step definition match.
18  *
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.
21  *
22  * @author Konstantin Kudryashov <ever.zet@gmail.com>
23  */
24 final class AmbiguousMatchException extends RuntimeException implements SearchException
25 {
26     /**
27      * @var string
28      */
29     private $text;
30     /**
31      * @var Definition[]
32      */
33     private $matches = array();
34
35     /**
36      * Initializes ambiguous exception.
37      *
38      * @param string       $text    step description
39      * @param Definition[] $matches ambiguous matches (array of Definition's)
40      */
41     public function __construct($text, array $matches)
42     {
43         $this->text = $text;
44         $this->matches = $matches;
45
46         $message = sprintf("Ambiguous match of \"%s\":", $text);
47         foreach ($matches as $definition) {
48             $message .= sprintf(
49                 "\nto `%s` from %s",
50                 $definition->getPattern(),
51                 $definition->getPath()
52             );
53         }
54
55         parent::__construct($message);
56     }
57 }