BackgroundNode   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 95
Duplicated Lines 7.37 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 7
loc 95
ccs 14
cts 18
cp 0.7778
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 1
A getNodeType() 0 4 1
A hasSteps() 0 4 1
A getSteps() 0 4 1
A getKeyword() 0 4 1
A getLine() 0 4 1
A getTitle() 0 4 1

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\Node;
12
13
/**
14
 * Represents Gherkin Background.
15
 *
16
 * @author Konstantin Kudryashov <[email protected]>
17
 */
18
class BackgroundNode implements ScenarioLikeInterface
19
{
20
    /**
21
     * @var string
22
     */
23
    private $title;
24
    /**
25
     * @var StepNode[]
26
     */
27
    private $steps = array();
28
    /**
29
     * @var string
30
     */
31
    private $keyword;
32
    /**
33
     * @var integer
34
     */
35
    private $line;
36
37
    /**
38
     * Initializes background.
39
     *
40
     * @param null|string $title
41
     * @param StepNode[]  $steps
42
     * @param string      $keyword
43
     * @param integer     $line
44
     */
45 200 View Code Duplication
    public function __construct($title, array $steps, $keyword, $line)
0 ignored issues
show
Duplication introduced by
This method 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...
46
    {
47 200
        $this->title = $title;
48 200
        $this->steps = $steps;
49 200
        $this->keyword = $keyword;
50 200
        $this->line = $line;
51 200
    }
52
53
    /**
54
     * Returns node type string
55
     *
56
     * @return string
57
     */
58
    public function getNodeType()
59
    {
60
        return 'Background';
61
    }
62
63
    /**
64
     * Returns background title.
65
     *
66
     * @return null|string
67
     */
68 1
    public function getTitle()
69
    {
70 1
        return $this->title;
71
    }
72
73
    /**
74
     * Checks if background has steps.
75
     *
76
     * @return Boolean
77
     */
78 2
    public function hasSteps()
79
    {
80 2
        return 0 < count($this->steps);
81
    }
82
83
    /**
84
     * Returns background steps.
85
     *
86
     * @return StepNode[]
87
     */
88 2
    public function getSteps()
89
    {
90 2
        return $this->steps;
91
    }
92
93
    /**
94
     * Returns background keyword.
95
     *
96
     * @return string
97
     */
98
    public function getKeyword()
99
    {
100
        return $this->keyword;
101
    }
102
103
    /**
104
     * Returns background declaration line number.
105
     *
106
     * @return integer
107
     */
108 2
    public function getLine()
109
    {
110 2
        return $this->line;
111
    }
112
}
113