1 | <?php |
||
20 | class FeatureNode implements KeywordNodeInterface, TaggedNodeInterface |
||
21 | { |
||
22 | /** |
||
23 | * @var null|string |
||
24 | */ |
||
25 | private $title; |
||
26 | /** |
||
27 | * @var null|string |
||
28 | */ |
||
29 | private $description; |
||
30 | /** |
||
31 | * @var string[] |
||
32 | */ |
||
33 | private $tags = array(); |
||
34 | /** |
||
35 | * @var null|BackgroundNode |
||
36 | */ |
||
37 | private $background; |
||
38 | /** |
||
39 | * @var ScenarioInterface[] |
||
40 | */ |
||
41 | private $scenarios = array(); |
||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | private $keyword; |
||
46 | /** |
||
47 | * @var string |
||
48 | */ |
||
49 | private $language; |
||
50 | /** |
||
51 | * @var null|string |
||
52 | */ |
||
53 | private $file; |
||
54 | /** |
||
55 | * @var integer |
||
56 | */ |
||
57 | private $line; |
||
58 | |||
59 | /** |
||
60 | * Initializes feature. |
||
61 | * |
||
62 | * @param null|string $title |
||
63 | * @param null|string $description |
||
64 | * @param string[] $tags |
||
65 | * @param null|BackgroundNode $background |
||
66 | * @param ScenarioInterface[] $scenarios |
||
67 | * @param string $keyword |
||
68 | * @param string $language |
||
69 | * @param null|string $file The absolute path to the feature file. |
||
70 | * @param integer $line |
||
71 | */ |
||
72 | 268 | public function __construct( |
|
73 | $title, |
||
74 | $description, |
||
75 | array $tags, |
||
76 | BackgroundNode $background = null, |
||
77 | array $scenarios, |
||
78 | $keyword, |
||
79 | $language, |
||
80 | $file, |
||
81 | $line |
||
82 | ) { |
||
83 | // Verify that the feature file is an absolute path. |
||
84 | 268 | $filesystem = new Filesystem(); |
|
85 | 268 | if (!empty($file) && !$filesystem->isAbsolutePath($file)) { |
|
86 | 188 | throw new \InvalidArgumentException('The file should be an absolute path.'); |
|
87 | } |
||
88 | 80 | $this->title = $title; |
|
89 | 80 | $this->description = $description; |
|
90 | 80 | $this->tags = $tags; |
|
91 | 80 | $this->background = $background; |
|
92 | 80 | $this->scenarios = $scenarios; |
|
93 | 80 | $this->keyword = $keyword; |
|
94 | 80 | $this->language = $language; |
|
95 | 80 | $this->file = $file; |
|
96 | 80 | $this->line = $line; |
|
97 | 80 | } |
|
98 | |||
99 | /** |
||
100 | * Returns node type string |
||
101 | * |
||
102 | * @return string |
||
103 | */ |
||
104 | 1 | public function getNodeType() |
|
105 | { |
||
106 | 1 | return 'Feature'; |
|
107 | } |
||
108 | |||
109 | /** |
||
110 | * Returns feature title. |
||
111 | * |
||
112 | * @return null|string |
||
113 | */ |
||
114 | 45 | public function getTitle() |
|
118 | |||
119 | /** |
||
120 | * Checks if feature has a description. |
||
121 | * |
||
122 | * @return Boolean |
||
123 | */ |
||
124 | public function hasDescription() |
||
128 | |||
129 | /** |
||
130 | * Returns feature description. |
||
131 | * |
||
132 | * @return null|string |
||
133 | */ |
||
134 | 45 | public function getDescription() |
|
138 | |||
139 | /** |
||
140 | * Checks if feature is tagged with tag. |
||
141 | * |
||
142 | * @param string $tag |
||
143 | * |
||
144 | * @return Boolean |
||
145 | */ |
||
146 | public function hasTag($tag) |
||
150 | |||
151 | /** |
||
152 | * Checks if feature has tags. |
||
153 | * |
||
154 | * @return Boolean |
||
155 | */ |
||
156 | 2 | public function hasTags() |
|
160 | |||
161 | /** |
||
162 | * Returns feature tags. |
||
163 | * |
||
164 | * @return string[] |
||
165 | */ |
||
166 | 43 | public function getTags() |
|
170 | |||
171 | /** |
||
172 | * Checks if feature has background. |
||
173 | * |
||
174 | * @return Boolean |
||
175 | */ |
||
176 | 1 | public function hasBackground() |
|
180 | |||
181 | /** |
||
182 | * Returns feature background. |
||
183 | * |
||
184 | * @return null|BackgroundNode |
||
185 | */ |
||
186 | 43 | public function getBackground() |
|
190 | |||
191 | /** |
||
192 | * Checks if feature has scenarios. |
||
193 | * |
||
194 | * @return Boolean |
||
195 | */ |
||
196 | 2 | public function hasScenarios() |
|
200 | |||
201 | /** |
||
202 | * Returns feature scenarios. |
||
203 | * |
||
204 | * @return ScenarioInterface[] |
||
205 | */ |
||
206 | 46 | public function getScenarios() |
|
210 | |||
211 | /** |
||
212 | * Returns feature keyword. |
||
213 | * |
||
214 | * @return string |
||
215 | */ |
||
216 | 40 | public function getKeyword() |
|
220 | |||
221 | /** |
||
222 | * Returns feature language. |
||
223 | * |
||
224 | * @return string |
||
225 | */ |
||
226 | 41 | public function getLanguage() |
|
230 | |||
231 | /** |
||
232 | * Returns feature file as an absolute path. |
||
233 | * |
||
234 | * @return null|string |
||
235 | */ |
||
236 | 13 | public function getFile() |
|
240 | |||
241 | /** |
||
242 | * Returns feature declaration line number. |
||
243 | * |
||
244 | * @return integer |
||
245 | */ |
||
246 | 48 | public function getLine() |
|
250 | } |
||
251 |