Behat\Gherkin\Parser::parseOutline PHP Method

parseOutline() protected method

Parses scenario outline token & returns it's node.
protected parseOutline ( ) : Behat\Gherkin\Node\OutlineNode
return Behat\Gherkin\Node\OutlineNode
    protected function parseOutline()
    {
        $token = $this->expectTokenType('Outline');
        $title = trim($token['value']);
        $tags = $this->popTags();
        $keyword = $token['keyword'];
        $examples = null;
        $line = $token['line'];
        // Parse description, steps and examples
        $steps = array();
        while (in_array($this->predictTokenType(), array('Step', 'Examples', 'Newline', 'Text', 'Comment'))) {
            $node = $this->parseExpression();
            if ($node instanceof StepNode) {
                $steps[] = $this->normalizeStepNodeKeywordType($node, $steps);
                continue;
            }
            if ($node instanceof ExampleTableNode) {
                $examples = $node;
                continue;
            }
            if (!count($steps) && is_string($node)) {
                $text = preg_replace('/^\\s{0,' . ($token['indent'] + 2) . '}|\\s*$/', '', $node);
                $title .= "\n" . $text;
                continue;
            }
            if ("\n" === $node) {
                continue;
            }
            if (is_string($node)) {
                throw new ParserException(sprintf('Expected Step or Examples table, but got text: "%s"%s', $node, $this->file ? ' in file: ' . $this->file : ''));
            }
            if (!$node instanceof StepNode) {
                throw new ParserException(sprintf('Expected Step or Examples table, but got %s on line: %d%s', $node->getNodeType(), $node->getLine(), $this->file ? ' in file: ' . $this->file : ''));
            }
        }
        if (null === $examples) {
            throw new ParserException(sprintf('Outline should have examples table, but got none for outline "%s" on line: %d%s', rtrim($title), $line, $this->file ? ' in file: ' . $this->file : ''));
        }
        return new OutlineNode(rtrim($title) ?: null, $tags, $steps, $examples, $keyword, $line);
    }