Passed
Push — master ( 5cce8c...cb0ced )
by Edward
04:53
created

Parser   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 12
c 2
b 0
f 1
dl 0
loc 22
ccs 11
cts 11
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A buildQueryAst() 0 12 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Remorhaz\JSON\Path\Parser;
5
6
use Remorhaz\UniLex\AST\Tree;
7
use Throwable;
8
9
final class Parser implements ParserInterface
10
{
11
12
    private $ll1ParserFactory;
13
14 3
    public function __construct(Ll1ParserFactoryInterface $ll1ParserFactory)
15
    {
16 3
        $this->ll1ParserFactory = $ll1ParserFactory;
17 3
    }
18
19 3
    public function buildQueryAst(string $path): Tree
20
    {
21
        try {
22 3
            $queryAst = new Tree;
23
            $this
24 3
                ->ll1ParserFactory
25 3
                ->createParser($path, $queryAst)
26 3
                ->run();
27
28 2
            return $queryAst;
29 1
        } catch (Throwable $e) {
30 1
            throw new Exception\QueryAstNotBuiltException($path, $e);
31
        }
32
    }
33
}
34