JsonParser::parse()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 10
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
7
final class JsonParser implements ParserInterface
8
{
9
    /**
10
     * @inheritdoc
11
     */
12
    public function parse(string $schemaContent): \stdClass
13
    {
14
        $parsedSchema = \json_decode($schemaContent);
15
16
        if (json_last_error() !== JSON_ERROR_NONE) {
17
            throw new ParseException(json_last_error_msg());
18
        }
19
20
        return $parsedSchema;
21
    }
22
}
23