Security update for permissions_by_term
[yaffs-website] / vendor / behat / gherkin / src / Behat / Gherkin / Filter / SimpleFilter.php
1 <?php
2
3 /*
4  * This file is part of the Behat Gherkin.
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\Gherkin\Filter;
12
13 use Behat\Gherkin\Node\FeatureNode;
14
15 /**
16  * Abstract filter class.
17  *
18  * @author Konstantin Kudryashov <ever.zet@gmail.com>
19  */
20 abstract class SimpleFilter implements FilterInterface
21 {
22     /**
23      * Filters feature according to the filter.
24      *
25      * @param FeatureNode $feature
26      *
27      * @return FeatureNode
28      */
29     public function filterFeature(FeatureNode $feature)
30     {
31         if ($this->isFeatureMatch($feature)) {
32             return $feature;
33         }
34
35         $scenarios = array();
36         foreach ($feature->getScenarios() as $scenario) {
37             if (!$this->isScenarioMatch($scenario)) {
38                 continue;
39             }
40
41             $scenarios[] = $scenario;
42         }
43
44         return new FeatureNode(
45             $feature->getTitle(),
46             $feature->getDescription(),
47             $feature->getTags(),
48             $feature->getBackground(),
49             $scenarios,
50             $feature->getKeyword(),
51             $feature->getLanguage(),
52             $feature->getFile(),
53             $feature->getLine()
54         );
55     }
56 }