YamlParser::getNextEmbedBlock PHP Method

getNextEmbedBlock() protected method

Returns the next embed block of YAML.
protected getNextEmbedBlock ( )
    protected function getNextEmbedBlock()
    {
        $this->moveToNextLine();
        $newIndent = $this->getCurrentLineIndentation();
        if (!$this->isCurrentLineEmpty() && 0 == $newIndent) {
            throw new InvalidArgumentException(sprintf('Indentation problem at line %d (%s)', $this->getRealCurrentLineNb() + 1, $this->currentLine));
        }
        $data = array(substr($this->currentLine, $newIndent));
        while ($this->moveToNextLine()) {
            if ($this->isCurrentLineEmpty()) {
                if ($this->isCurrentLineBlank()) {
                    $data[] = substr($this->currentLine, $newIndent);
                }
                continue;
            }
            $indent = $this->getCurrentLineIndentation();
            if (preg_match('#^(?P<text> *)$#', $this->currentLine, $match)) {
                // empty line
                $data[] = $match['text'];
            } else {
                if ($indent >= $newIndent) {
                    $data[] = substr($this->currentLine, $newIndent);
                } else {
                    if (0 == $indent) {
                        $this->moveToPreviousLine();
                        break;
                    } else {
                        throw new InvalidArgumentException(sprintf('Indentation problem at line %d (%s)', $this->getRealCurrentLineNb() + 1, $this->currentLine));
                    }
                }
            }
        }
        return implode("\n", $data);
    }