Completed
Pull Request — master (#112)
by Christophe
02:50
created

SimpleFilter::filterFeature()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 27
Code Lines 18

Duplication

Lines 27
Ratio 100 %

Code Coverage

Tests 20
CRAP Score 4

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 27
loc 27
ccs 20
cts 20
cp 1
rs 8.5806
cc 4
eloc 18
nc 4
nop 1
crap 4
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 SimpleFilter implements FilterInterface
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 1
    public function filterFeature(FeatureNode $feature)
30
    {
31 1
        if ($this->isFeatureMatch($feature)) {
32 1
            return $feature;
33
        }
34
35 1
        $scenarios = array();
36 1
        foreach ($feature->getScenarios() as $scenario) {
37 1
            if (!$this->isScenarioMatch($scenario)) {
38 1
                continue;
39
            }
40
41 1
            $scenarios[] = $scenario;
42 1
        }
43
44 1
        return new FeatureNode(
45 1
            $feature->getTitle(),
46 1
            $feature->getDescription(),
47 1
            $feature->getTags(),
48 1
            $feature->getBackground(),
49 1
            $scenarios,
50 1
            $feature->getKeyword(),
51 1
            $feature->getLanguage(),
52 1
            $feature->getFile(),
53 1
            $feature->getLine()
54 1
        );
55
    }
56
}
57