Parser::__construct()   A
last analyzed

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
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