Parser   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 14
c 0
b 0
f 0
dl 0
loc 37
ccs 14
cts 14
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A buildLocator() 0 9 1
A create() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\JSON\Pointer\Parser;
6
7
use Remorhaz\JSON\Pointer\Locator\LocatorBuilder;
8
use Remorhaz\JSON\Pointer\Locator\LocatorInterface;
9
use Remorhaz\JSON\Pointer\Locator\ReferenceFactory;
10
use Remorhaz\JSON\Pointer\Locator\ReferenceFactoryInterface;
11
use Remorhaz\UniLex\Exception as UniLexException;
12
13
final class Parser implements ParserInterface
14
{
15
16
    private $ll1ParserFactory;
17
18
    private $referenceFactory;
19
20 1
    public static function create(): ParserInterface
21
    {
22 1
        return new self(
23 1
            new Ll1ParserFactory(),
24 1
            new ReferenceFactory()
25
        );
26
    }
27
28 5
    public function __construct(
29
        Ll1ParserFactoryInterface $ll1ParserFactory,
30
        ReferenceFactoryInterface $referenceFactory
31
    ) {
32 5
        $this->ll1ParserFactory = $ll1ParserFactory;
33 5
        $this->referenceFactory = $referenceFactory;
34 5
    }
35
36
    /**
37
     * @param string $pointer
38
     * @return LocatorInterface
39
     * @throws UniLexException
40
     */
41 4
    public function buildLocator(string $pointer): LocatorInterface
42
    {
43 4
        $locatorBuilder = new LocatorBuilder($this->referenceFactory);
44
        $this
45 4
            ->ll1ParserFactory
46 4
            ->createParser($pointer, $locatorBuilder)
47 4
            ->run();
48
49 4
        return $locatorBuilder->getLocator();
50
    }
51
}
52