1 | <?php |
||
20 | class StepNode implements NodeInterface |
||
21 | { |
||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | private $keyword; |
||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | private $keywordType; |
||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | private $text; |
||
34 | /** |
||
35 | * @var ArgumentInterface[] |
||
36 | */ |
||
37 | private $arguments = array(); |
||
38 | /** |
||
39 | * @var integer |
||
40 | */ |
||
41 | private $line; |
||
42 | |||
43 | /** |
||
44 | * Initializes step. |
||
45 | * |
||
46 | * @param string $keyword |
||
47 | * @param string $text |
||
48 | * @param ArgumentInterface[] $arguments |
||
49 | * @param integer $line |
||
50 | * @param string $keywordType |
||
51 | */ |
||
52 | 236 | public function __construct($keyword, $text, array $arguments, $line, $keywordType = null) |
|
53 | { |
||
54 | 236 | if (count($arguments) > 1) { |
|
55 | 1 | throw new NodeException(sprintf( |
|
56 | 1 | 'Steps could have only one argument, but `%s %s` have %d.', |
|
57 | $keyword, |
||
58 | $text, |
||
59 | 1 | count($arguments) |
|
60 | )); |
||
61 | } |
||
62 | |||
63 | 235 | $this->keyword = $keyword; |
|
64 | 235 | $this->text = $text; |
|
65 | 235 | $this->arguments = $arguments; |
|
66 | 235 | $this->line = $line; |
|
67 | 235 | $this->keywordType = $keywordType ?: 'Given'; |
|
68 | 235 | } |
|
69 | |||
70 | /** |
||
71 | * Returns node type string |
||
72 | * |
||
73 | * @return string |
||
74 | */ |
||
75 | 1 | public function getNodeType() |
|
79 | |||
80 | /** |
||
81 | * Returns step keyword in provided language (Given, When, Then, etc.). |
||
82 | * |
||
83 | * @return string |
||
84 | * |
||
85 | * @deprecated use getKeyword() instead |
||
86 | */ |
||
87 | 4 | public function getType() |
|
91 | |||
92 | /** |
||
93 | * Returns step keyword in provided language (Given, When, Then, etc.). |
||
94 | * |
||
95 | * @return string |
||
96 | * |
||
97 | */ |
||
98 | 207 | public function getKeyword() |
|
102 | |||
103 | /** |
||
104 | * Returns step type keyword (Given, When, Then, etc.). |
||
105 | * |
||
106 | * @return string |
||
107 | */ |
||
108 | 232 | public function getKeywordType() |
|
112 | |||
113 | /** |
||
114 | * Returns step text. |
||
115 | * |
||
116 | * @return string |
||
117 | */ |
||
118 | 207 | public function getText() |
|
122 | |||
123 | /** |
||
124 | * Checks if step has arguments. |
||
125 | * |
||
126 | * @return Boolean |
||
127 | */ |
||
128 | public function hasArguments() |
||
132 | |||
133 | /** |
||
134 | * Returns step arguments. |
||
135 | * |
||
136 | * @return ArgumentInterface[] |
||
137 | */ |
||
138 | 205 | public function getArguments() |
|
142 | |||
143 | /** |
||
144 | * Returns step declaration line number. |
||
145 | * |
||
146 | * @return integer |
||
147 | */ |
||
148 | 207 | public function getLine() |
|
152 | } |
||
153 |