YamlParser::parse()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace HSkrasek\OpenAPI\Parsers;
4
5
use HSkrasek\OpenAPI\Exceptions\ParseException;
6
use Symfony\Component\Yaml\Exception\ParseException as SymfonyParseException;
7
use Symfony\Component\Yaml\Yaml;
8
9
final class YamlParser implements ParserInterface
10
{
11
    /**
12
     * @inheritDoc
13
     */
14
    public function parse(string $schemaContent): \stdClass
15
    {
16
        try {
17
            // @codingStandardsIgnoreStart
18
            return Yaml::parse(
19
                $schemaContent,
20
                Yaml::PARSE_OBJECT | Yaml::PARSE_OBJECT_FOR_MAP | Yaml::PARSE_DATETIME | Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE
21
            );
22
            // @codingStandardsIgnoreEnd
23
        } catch (SymfonyParseException $parseException) {
24
            throw new ParseException($parseException->getMessage());
25
        }
26
    }
27
}
28