Completed
Push — master ( d99440...b71151 )
by Hunter
13:25
created

Parser::parse()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php namespace HSkrasek\OpenAPI\Parsers;
2
3
use HSkrasek\OpenAPI\Exceptions\ParseException;
4
use League\JsonReference\DecodingException;
5
use League\JsonReference\DereferencerInterface;
6
7
final class Parser implements ParserInterface
8
{
9
    /**
10
     * @var DereferencerInterface
11
     */
12
    private $dereferencer;
13
14
    public function __construct(DereferencerInterface $dereferencer)
15
    {
16
        $this->dereferencer = $dereferencer;
17
    }
18
19
    /**
20
     * @inheritDoc
21
     */
22
    public function parse(string $schemaPath): \stdClass
23
    {
24
        try {
25
            return $this->dereferencer->dereference('file://' . $schemaPath);
26
        } catch (DecodingException $decodingException) {
27
            throw new ParseException($decodingException->getMessage());
28
        }
29
    }
30
}
31