Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
48.00% covered (danger)
48.00%
12 / 25
CRAP
88.75% covered (warning)
88.75%
481 / 542
Parser
0.00% covered (danger)
0.00%
0 / 1
48.00% covered (danger)
48.00%
12 / 25
487.19
88.75% covered (warning)
88.75%
481 / 542
 parseFile
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
7 / 7
 parse
0.00% covered (danger)
0.00%
0 / 1
4.09
82.35% covered (warning)
82.35%
14 / 17
 doParse
0.00% covered (danger)
0.00%
0 / 1
144.86
89.90% covered (warning)
89.90%
187 / 208
 parseBlock
0.00% covered (danger)
0.00%
0 / 1
3.14
75.00% covered (warning)
75.00%
9 / 12
 getRealCurrentLineNb
0.00% covered (danger)
0.00%
0 / 1
4.12
50.00% covered (danger)
50.00%
3 / 6
 getCurrentLineIndentation
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getNextEmbedBlock
0.00% covered (danger)
0.00%
0 / 1
28
95.74% covered (success)
95.74%
45 / 47
 moveToNextLine
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
4 / 4
 moveToPreviousLine
0.00% covered (danger)
0.00%
0 / 1
2.06
75.00% covered (warning)
75.00%
3 / 4
 parseValue
0.00% covered (danger)
0.00%
0 / 1
37
98.00% covered (success)
98.00%
49 / 50
 parseBlockScalar
0.00% covered (danger)
0.00%
0 / 1
29.23
93.55% covered (success)
93.55%
58 / 62
 isNextLineIndented
100.00% covered (success)
100.00%
1 / 1
7
100.00% covered (success)
100.00%
12 / 12
 isCurrentLineEmpty
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 isCurrentLineBlank
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 isCurrentLineComment
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
2 / 2
 isCurrentLineLastLineInDocument
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 cleanup
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
14 / 14
 isNextLineUnIndentedCollection
100.00% covered (success)
100.00%
1 / 1
8
100.00% covered (success)
100.00%
12 / 12
 isStringUnIndentedCollectionItem
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 preg_match
0.00% covered (danger)
0.00%
0 / 1
42.72
10.00% covered (danger)
10.00%
2 / 20
 trimTag
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
3 / 3
 getLineTag
0.00% covered (danger)
0.00%
0 / 1
10.80
80.00% covered (warning)
80.00%
8 / 10
 parseQuotedString
0.00% covered (danger)
0.00%
0 / 1
26
96.15% covered (success)
96.15%
25 / 26
 lexInlineMapping
0.00% covered (danger)
0.00%
0 / 1
8.09
88.89% covered (warning)
88.89%
8 / 9
 lexInlineSequence
0.00% covered (danger)
0.00%
0 / 1
12.08
91.67% covered (success)
91.67%
11 / 12
<?php
/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace Symfony\Component\Yaml;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Tag\TaggedValue;
/**
 * Parser parses YAML strings to convert them to PHP arrays.
 *
 * @author Fabien Potencier <fabien@symfony.com>
 *
 * @final
 */
class Parser
{
    const TAG_PATTERN = '(?P<tag>![\w!.\/:-]+)';
    const BLOCK_SCALAR_HEADER_PATTERN = '(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?';
    private $filename;
    private $offset = 0;
    private $totalNumberOfLines;
    private $lines = [];
    private $currentLineNb = -1;
    private $currentLine = '';
    private $refs = [];
    private $skippedLineNumbers = [];
    private $locallySkippedLineNumbers = [];
    private $refsBeingParsed = [];
    /**
     * Parses a YAML file into a PHP value.
     *
     * @param string $filename The path to the YAML file to be parsed
     * @param int    $flags    A bit field of PARSE_* constants to customize the YAML parser behavior
     *
     * @return mixed The YAML converted to a PHP value
     *
     * @throws ParseException If the file could not be read or the YAML is not valid
     */
    public function parseFile(string $filename, int $flags = 0)
    {
        if (!is_file($filename)) {
            throw new ParseException(sprintf('File "%s" does not exist.', $filename));
        }
        if (!is_readable($filename)) {
            throw new ParseException(sprintf('File "%s" cannot be read.', $filename));
        }
        $this->filename = $filename;
        try {
            return $this->parse(file_get_contents($filename), $flags);
        } finally {
            $this->filename = null;
        }
    }
    /**
     * Parses a YAML string to a PHP value.
     *
     * @param string $value A YAML string
     * @param int    $flags A bit field of PARSE_* constants to customize the YAML parser behavior
     *
     * @return mixed A PHP value
     *
     * @throws ParseException If the YAML is not valid
     */
    public function parse(string $value, int $flags = 0)
    {
        if (false === preg_match('//u', $value)) {
            throw new ParseException('The YAML value does not appear to be valid UTF-8.', -1, null, $this->filename);
        }
        $this->refs = [];
        $mbEncoding = null;
        if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) {
            $mbEncoding = mb_internal_encoding();
            mb_internal_encoding('UTF-8');
        }
        try {
            $data = $this->doParse($value, $flags);
        } finally {