YamlParser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 13 2
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