ComplexFilter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 33
loc 33
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A filterFeature() 23 23 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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