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

Parser::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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