ComplexFilter::filterFeature()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 23

Duplication

Lines 23
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 23
loc 23
ccs 0
cts 16
cp 0
rs 9.552
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 12
1
<?php
2
3
/*
4
 * This file is part of the Behat 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\FeatureNode;
14
15
/**
16
 * Abstract filter class.
17
 *
18
 * @author Konstantin Kudryashov <[email protected]>
19
 */
20 View Code Duplication
abstract class ComplexFilter implements ComplexFilterInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
        $scenarios = array();
32
        foreach ($feature->getScenarios() as $scenario) {
33
            if (!$this->isScenarioMatch($feature, $scenario)) {
34
                continue;
35
            }
36
37
            $scenarios[] = $scenario;
38
        }
39
40
        return new FeatureNode(
41
            $feature->getTitle(),
42
            $feature->getDescription(),
43
            $feature->getTags(),
44
            $feature->getBackground(),
45
            $scenarios,
46
            $feature->getKeyword(),
47
            $feature->getLanguage(),
48
            $feature->getFile(),
49
            $feature->getLine()
50
        );
51
    }
52
}
53