private function Parser::getNextEmbedBlock in Translation template extractor 6.3
Same name and namespace in other branches
- 7.3 vendor/Symfony/Component/Yaml/Parser.php \Symfony\Component\Yaml\Parser::getNextEmbedBlock()
- 7.2 vendor/Symfony/Component/Yaml/Parser.php \Symfony\Component\Yaml\Parser::getNextEmbedBlock()
Returns the next embed block of YAML.
Parameters
integer $indentation The indent level at which the block is to be read, or null for default:
Return value
string A YAML string
Throws
ParseException When indentation problem are detected
1 call to Parser::getNextEmbedBlock()
- Parser::parse in vendor/
Symfony/ Component/ Yaml/ Parser.php - Parses a YAML string to a PHP value.
File
- vendor/
Symfony/ Component/ Yaml/ Parser.php, line 287
Class
- Parser
- Parser parses YAML strings to convert them to PHP arrays.
Namespace
Symfony\Component\YamlCode
private function getNextEmbedBlock($indentation = null) {
$this
->moveToNextLine();
if (null === $indentation) {
$newIndent = $this
->getCurrentLineIndentation();
$unindentedEmbedBlock = $this
->isStringUnIndentedCollectionItem($this->currentLine);
if (!$this
->isCurrentLineEmpty() && 0 === $newIndent && !$unindentedEmbedBlock) {
throw new ParseException('Indentation problem.', $this
->getRealCurrentLineNb() + 1, $this->currentLine);
}
}
else {
$newIndent = $indentation;
}
$data = array(
substr($this->currentLine, $newIndent),
);
$isItUnindentedCollection = $this
->isStringUnIndentedCollectionItem($this->currentLine);
while ($this
->moveToNextLine()) {
if ($isItUnindentedCollection && !$this
->isStringUnIndentedCollectionItem($this->currentLine)) {
$this
->moveToPreviousLine();
break;
}
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'];
}
elseif ($indent >= $newIndent) {
$data[] = substr($this->currentLine, $newIndent);
}
elseif (0 == $indent) {
$this
->moveToPreviousLine();
break;
}
else {
throw new ParseException('Indentation problem.', $this
->getRealCurrentLineNb() + 1, $this->currentLine);
}
}
return implode("\n", $data);
}