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;
14 * Represents Gherkin Outline.
16 * @author Konstantin Kudryashov <ever.zet@gmail.com>
18 class OutlineNode implements ScenarioInterface
33 * @var ExampleTableNode
45 * @var null|ExampleNode[]
50 * Initializes outline.
52 * @param null|string $title
53 * @param string[] $tags
54 * @param StepNode[] $steps
55 * @param ExampleTableNode $table
56 * @param string $keyword
57 * @param integer $line
59 public function __construct(
63 ExampleTableNode $table,
67 $this->title = $title;
69 $this->steps = $steps;
70 $this->table = $table;
71 $this->keyword = $keyword;
76 * Returns node type string
80 public function getNodeType()
86 * Returns outline title.
90 public function getTitle()
96 * Checks if outline is tagged with tag.
102 public function hasTag($tag)
104 return in_array($tag, $this->getTags());
108 * Checks if outline has tags (both inherited from feature and own).
112 public function hasTags()
114 return 0 < count($this->getTags());
118 * Returns outline tags (including inherited from feature).
122 public function getTags()
128 * Checks if outline has steps.
132 public function hasSteps()
134 return 0 < count($this->steps);
138 * Returns outline steps.
142 public function getSteps()
148 * Checks if outline has examples.
152 public function hasExamples()
154 return 0 < count($this->table->getColumnsHash());
158 * Returns examples table.
160 * @return ExampleTableNode
162 public function getExampleTable()
168 * Returns list of examples for the outline.
170 * @return ExampleNode[]
172 public function getExamples()
174 return $this->examples = $this->examples ? : $this->createExamples();
178 * Returns outline keyword.
182 public function getKeyword()
184 return $this->keyword;
188 * Returns outline declaration line number.
192 public function getLine()
198 * Creates examples for this outline using examples table.
200 * @return ExampleNode[]
202 protected function createExamples()
205 foreach ($this->table->getColumnsHash() as $rowNum => $row) {
206 $examples[] = new ExampleNode(
207 $this->table->getRowAsString($rowNum + 1),
211 $this->table->getRowLine($rowNum + 1),