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

Parser::buildQueryAst()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

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