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

Parser   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A parse() 0 8 2
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