ScenarioNode   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 133
Duplicated Lines 6.02 %

Coupling/Cohesion

Components 2
Dependencies 0

Test Coverage

Coverage 76%

Importance

Changes 0
Metric Value
wmc 10
lcom 2
cbo 0
dl 8
loc 133
ccs 19
cts 25
cp 0.76
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 8 8 1
A getNodeType() 0 4 1
A getTitle() 0 4 1
A hasTag() 0 4 1
A hasTags() 0 4 1
A getTags() 0 4 1
A hasSteps() 0 4 1
A getSteps() 0 4 1
A getKeyword() 0 4 1
A getLine() 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 Scenario.
15
 *
16
 * @author Konstantin Kudryashov <[email protected]>
17
 */
18
class ScenarioNode implements ScenarioInterface
19
{
20
    /**
21
     * @var string
22
     */
23
    private $title;
24
    /**
25
     * @var array
26
     */
27
    private $tags = array();
28
    /**
29
     * @var StepNode[]
30
     */
31
    private $steps = array();
32
    /**
33
     * @var string
34
     */
35
    private $keyword;
36
    /**
37
     * @var integer
38
     */
39
    private $line;
40
41
    /**
42
     * Initializes scenario.
43
     *
44
     * @param null|string $title
45
     * @param array       $tags
46
     * @param StepNode[]  $steps
47
     * @param string      $keyword
48
     * @param integer     $line
49
     */
50 245 View Code Duplication
    public function __construct($title, array $tags, 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...
51
    {
52 245
        $this->title = $title;
53 245
        $this->tags = $tags;
54 245
        $this->steps = $steps;
55 245
        $this->keyword = $keyword;
56 245
        $this->line = $line;
57 245
    }
58
59
    /**
60
     * Returns node type string
61
     *
62
     * @return string
63
     */
64
    public function getNodeType()
65
    {
66
        return 'Scenario';
67
    }
68
69
    /**
70
     * Returns scenario title.
71
     *
72
     * @return null|string
73
     */
74 7
    public function getTitle()
75
    {
76 7
        return $this->title;
77
    }
78
79
    /**
80
     * Checks if scenario is tagged with tag.
81
     *
82
     * @param string $tag
83
     *
84
     * @return Boolean
85
     */
86
    public function hasTag($tag)
87
    {
88
        return in_array($tag, $this->getTags());
89
    }
90
91
    /**
92
     * Checks if scenario has tags (both inherited from feature and own).
93
     *
94
     * @return Boolean
95
     */
96 1
    public function hasTags()
97
    {
98 1
        return 0 < count($this->getTags());
99
    }
100
101
    /**
102
     * Returns scenario tags (including inherited from feature).
103
     *
104
     * @return array
105
     */
106 3
    public function getTags()
107
    {
108 3
        return $this->tags;
109
    }
110
111
    /**
112
     * Checks if scenario has steps.
113
     *
114
     * @return Boolean
115
     */
116 1
    public function hasSteps()
117
    {
118 1
        return 0 < count($this->steps);
119
    }
120
121
    /**
122
     * Returns scenario steps.
123
     *
124
     * @return StepNode[]
125
     */
126 3
    public function getSteps()
127
    {
128 3
        return $this->steps;
129
    }
130
131
    /**
132
     * Returns scenario keyword.
133
     *
134
     * @return string
135
     */
136
    public function getKeyword()
137
    {
138
        return $this->keyword;
139
    }
140
141
    /**
142
     * Returns scenario declaration line number.
143
     *
144
     * @return integer
145
     */
146 16
    public function getLine()
147
    {
148 16
        return $this->line;
149
    }
150
}
151