NarrativeFilter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 71.43%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 41
ccs 5
cts 7
cp 0.7143
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isFeatureMatch() 0 4 1
A isScenarioMatch() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Gherkin.
5
 * (c) Konstantin Kudryashov <[email protected]>
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\ScenarioInterface;
14
use Behat\Gherkin\Node\FeatureNode;
15
16
/**
17
 * Filters features by their narrative using regular expression.
18
 *
19
 * @author Konstantin Kudryashov <[email protected]>
20
 */
21
class NarrativeFilter extends SimpleFilter
22
{
23
    /**
24
     * @var string
25
     */
26
    private $regex;
27
28
    /**
29
     * Initializes filter.
30
     *
31
     * @param string $regex
32
     */
33 1
    public function __construct($regex)
34
    {
35 1
        $this->regex = $regex;
36 1
    }
37
38
    /**
39
     * Checks if Feature matches specified filter.
40
     *
41
     * @param FeatureNode $feature Feature instance
42
     *
43
     * @return Boolean
44
     */
45 1
    public function isFeatureMatch(FeatureNode $feature)
46
    {
47 1
        return 1 === preg_match($this->regex, $feature->getDescription());
48
    }
49
50
    /**
51
     * Checks if scenario or outline matches specified filter.
52
     *
53
     * @param ScenarioInterface $scenario Scenario or Outline node instance
54
     *
55
     * @return Boolean
56
     */
57
    public function isScenarioMatch(ScenarioInterface $scenario)
58
    {
59
        return false;
60
    }
61
}
62