4 * This file is part of the Behat Gherkin.
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\Gherkin\Filter;
13 use Behat\Gherkin\Node\FeatureNode;
14 use Behat\Gherkin\Node\ScenarioInterface;
17 * Filters features by their actors role.
19 * @author Konstantin Kudryashov <ever.zet@gmail.com>
21 class RoleFilter extends SimpleFilter
28 * @param string $role Approved role wildcard
30 public function __construct($role)
32 $this->pattern = '/as an? ' . strtr(preg_quote($role, '/'), array(
41 * Checks if Feature matches specified filter.
43 * @param FeatureNode $feature Feature instance
47 public function isFeatureMatch(FeatureNode $feature)
49 return 1 === preg_match($this->pattern, $feature->getDescription());
53 * Checks if scenario or outline matches specified filter.
55 * @param ScenarioInterface $scenario Scenario or Outline node instance
57 * @return false This filter is designed to work only with features
59 public function isScenarioMatch(ScenarioInterface $scenario)