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

Parser::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
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