Completed
Push — master ( faf631...885177 )
by Konstantin
11s
created

FeatureNode   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 226
Duplicated Lines 0 %

Coupling/Cohesion

Components 4
Dependencies 0

Test Coverage

Coverage 90.24%

Importance

Changes 4
Bugs 3 Features 0
Metric Value
wmc 16
c 4
b 3
f 0
lcom 4
cbo 0
dl 0
loc 226
ccs 37
cts 41
cp 0.9024
rs 10

16 Methods

Rating   Name   Duplication   Size   Complexity  
A getNodeType() 0 4 1
A getTitle() 0 4 1
A hasDescription() 0 4 1
A getDescription() 0 4 1
A hasTag() 0 4 1
A hasTags() 0 4 1
A getTags() 0 4 1
A hasBackground() 0 4 1
A getBackground() 0 4 1
A hasScenarios() 0 4 1
A getScenarios() 0 4 1
A getKeyword() 0 4 1
A getLanguage() 0 4 1
A getFile() 0 4 1
A getLine() 0 4 1
A __construct() 0 21 1
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 Feature.
15
 *
16
 * @author Konstantin Kudryashov <[email protected]>
17
 */
18
class FeatureNode implements KeywordNodeInterface, TaggedNodeInterface
19
{
20
    /**
21
     * @var null|string
22
     */
23
    private $title;
24
    /**
25
     * @var null|string
26
     */
27
    private $description;
28
    /**
29
     * @var string[]
30
     */
31
    private $tags = array();
32
    /**
33
     * @var null|BackgroundNode
34
     */
35
    private $background;
36
    /**
37
     * @var ScenarioInterface[]
38
     */
39
    private $scenarios = array();
40
    /**
41
     * @var string
42
     */
43
    private $keyword;
44
    /**
45
     * @var string
46
     */
47
    private $language;
48
    /**
49
     * @var null|string
50
     */
51
    private $file;
52
    /**
53
     * @var integer
54
     */
55
    private $line;
56
57
    /**
58
     * Initializes feature.
59
     *
60
     * @param null|string         $title
61
     * @param null|string         $description
62
     * @param string[]            $tags
63
     * @param null|BackgroundNode $background
64
     * @param ScenarioInterface[] $scenarios
65
     * @param string              $keyword
66
     * @param string              $language
67
     * @param null|string         $file
68
     * @param integer             $line
69
     */
70 77
    public function __construct(
71
        $title,
72
        $description,
73
        array $tags,
74
        BackgroundNode $background = null,
75
        array $scenarios,
0 ignored issues
show
Coding Style introduced by
Parameters which have default values should be placed at the end.

If you place a parameter with a default value before a parameter with a default value, the default value of the first parameter will never be used as it will always need to be passed anyway:

// $a must always be passed; it's default value is never used.
function someFunction($a = 5, $b) { }
Loading history...
76
        $keyword,
77
        $language,
78
        $file,
79
        $line
80
    ) {
81 77
        $this->title = $title;
82 77
        $this->description = $description;
83 77
        $this->tags = $tags;
84 77
        $this->background = $background;
85 77
        $this->scenarios = $scenarios;
86 77
        $this->keyword = $keyword;
87 77
        $this->language = $language;
88 77
        $this->file = $file;
89 77
        $this->line = $line;
90 77
    }
91
92
    /**
93
     * Returns node type string
94
     *
95
     * @return string
96
     */
97 1
    public function getNodeType()
98
    {
99 1
        return 'Feature';
100
    }
101
102
    /**
103
     * Returns feature title.
104
     *
105
     * @return null|string
106
     */
107 45
    public function getTitle()
108
    {
109 45
        return $this->title;
110
    }
111
112
    /**
113
     * Checks if feature has a description.
114
     *
115
     * @return Boolean
116
     */
117
    public function hasDescription()
118
    {
119
        return !empty($this->description);
120
    }
121
122
    /**
123
     * Returns feature description.
124
     *
125
     * @return null|string
126
     */
127 45
    public function getDescription()
128
    {
129 45
        return $this->description;
130
    }
131
132
    /**
133
     * Checks if feature is tagged with tag.
134
     *
135
     * @param string $tag
136
     *
137
     * @return Boolean
138
     */
139
    public function hasTag($tag)
140
    {
141
        return in_array($tag, $this->tags);
142
    }
143
144
    /**
145
     * Checks if feature has tags.
146
     *
147
     * @return Boolean
148
     */
149 1
    public function hasTags()
150
    {
151 1
        return 0 < count($this->tags);
152
    }
153
154
    /**
155
     * Returns feature tags.
156
     *
157
     * @return string[]
158
     */
159 43
    public function getTags()
160
    {
161 43
        return $this->tags;
162
    }
163
164
    /**
165
     * Checks if feature has background.
166
     *
167
     * @return Boolean
168
     */
169 1
    public function hasBackground()
170
    {
171 1
        return null !== $this->background;
172
    }
173
174
    /**
175
     * Returns feature background.
176
     *
177
     * @return null|BackgroundNode
178
     */
179 43
    public function getBackground()
180
    {
181 43
        return $this->background;
182
    }
183
184
    /**
185
     * Checks if feature has scenarios.
186
     *
187
     * @return Boolean
188
     */
189 2
    public function hasScenarios()
190
    {
191 2
        return 0 < count($this->scenarios);
192
    }
193
194
    /**
195
     * Returns feature scenarios.
196
     *
197
     * @return ScenarioInterface[]
198
     */
199 46
    public function getScenarios()
200
    {
201 46
        return $this->scenarios;
202
    }
203
204
    /**
205
     * Returns feature keyword.
206
     *
207
     * @return string
208
     */
209 40
    public function getKeyword()
210
    {
211 40
        return $this->keyword;
212
    }
213
214
    /**
215
     * Returns feature language.
216
     *
217
     * @return string
218
     */
219 41
    public function getLanguage()
220
    {
221 41
        return $this->language;
222
    }
223
224
    /**
225
     * Returns feature file.
226
     *
227
     * @return null|string
228
     */
229 11
    public function getFile()
230
    {
231 11
        return $this->file;
232
    }
233
234
    /**
235
     * Returns feature declaration line number.
236
     *
237
     * @return integer
238
     */
239 48
    public function getLine()
240
    {
241 48
        return $this->line;
242
    }
243
}
244