Security update for permissions_by_term
[yaffs-website] / vendor / behat / gherkin / src / Behat / Gherkin / Node / StepNode.php
1 <?php
2
3 /*
4  * This file is part of the Behat Gherkin.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
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 use Behat\Gherkin\Exception\NodeException;
14
15 /**
16  * Represents Gherkin Step.
17  *
18  * @author Konstantin Kudryashov <ever.zet@gmail.com>
19  */
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     public function __construct($keyword, $text, array $arguments, $line, $keywordType = null)
53     {
54         if (count($arguments) > 1) {
55             throw new NodeException(sprintf(
56                 'Steps could have only one argument, but `%s %s` have %d.',
57                 $keyword,
58                 $text,
59                 count($arguments)
60             ));
61         }
62
63         $this->keyword = $keyword;
64         $this->text = $text;
65         $this->arguments = $arguments;
66         $this->line = $line;
67         $this->keywordType = $keywordType ?: 'Given';
68     }
69
70     /**
71      * Returns node type string
72      *
73      * @return string
74      */
75     public function getNodeType()
76     {
77         return 'Step';
78     }
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     public function getType()
88     {
89         return $this->getKeyword();
90     }
91
92     /**
93      * Returns step keyword in provided language (Given, When, Then, etc.).
94      *
95      * @return string
96      *
97      */
98     public function getKeyword()
99     {
100         return $this->keyword;
101     }
102
103     /**
104      * Returns step type keyword (Given, When, Then, etc.).
105      *
106      * @return string
107      */
108     public function getKeywordType()
109     {
110         return $this->keywordType;
111     }
112
113     /**
114      * Returns step text.
115      *
116      * @return string
117      */
118     public function getText()
119     {
120         return $this->text;
121     }
122
123     /**
124      * Checks if step has arguments.
125      *
126      * @return Boolean
127      */
128     public function hasArguments()
129     {
130         return 0 < count($this->arguments);
131     }
132
133     /**
134      * Returns step arguments.
135      *
136      * @return ArgumentInterface[]
137      */
138     public function getArguments()
139     {
140         return $this->arguments;
141     }
142
143     /**
144      * Returns step declaration line number.
145      *
146      * @return integer
147      */
148     public function getLine()
149     {
150         return $this->line;
151     }
152 }