Parser::buildQueryAst()   A
last analyzed

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