4 * This file is part of the Behat Gherkin.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Gherkin\Node;
13 use Behat\Gherkin\Exception\NodeException;
16 * Represents Gherkin Step.
18 * @author Konstantin Kudryashov <ever.zet@gmail.com>
20 class StepNode implements NodeInterface
35 * @var ArgumentInterface[]
37 private $arguments = array();
46 * @param string $keyword
48 * @param ArgumentInterface[] $arguments
49 * @param integer $line
50 * @param string $keywordType
52 public function __construct($keyword, $text, array $arguments, $line, $keywordType = null)
54 if (count($arguments) > 1) {
55 throw new NodeException(sprintf(
56 'Steps could have only one argument, but `%s %s` have %d.',
63 $this->keyword = $keyword;
65 $this->arguments = $arguments;
67 $this->keywordType = $keywordType ?: 'Given';
71 * Returns node type string
75 public function getNodeType()
81 * Returns step keyword in provided language (Given, When, Then, etc.).
85 * @deprecated use getKeyword() instead
87 public function getType()
89 return $this->getKeyword();
93 * Returns step keyword in provided language (Given, When, Then, etc.).
98 public function getKeyword()
100 return $this->keyword;
104 * Returns step type keyword (Given, When, Then, etc.).
108 public function getKeywordType()
110 return $this->keywordType;
118 public function getText()
124 * Checks if step has arguments.
128 public function hasArguments()
130 return 0 < count($this->arguments);
134 * Returns step arguments.
136 * @return ArgumentInterface[]
138 public function getArguments()
140 return $this->arguments;
144 * Returns step declaration line number.
148 public function getLine()