Passed
Push — master ( c99af1...ed7248 )
by Edward
54:06
created

AstTranslator::buildQuery()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 6
c 0
b 0
f 0
nc 3
nop 3
dl 0
loc 13
ccs 7
cts 7
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\JSON\Path\Query;
6
7
use Remorhaz\UniLex\AST\Translator;
8
use Remorhaz\UniLex\AST\Tree;
9
use Throwable;
10
11
final class AstTranslator implements AstTranslatorInterface
12
{
13
14
    public function buildQuery(
15
        string $source,
16 6
        Tree $queryAst,
17
        CallbackBuilderInterface $callbackBuilder
18 6
    ): QueryInterface {
19 6
        try {
20
            $translator = new Translator($queryAst, $callbackBuilder);
21 6
            $translator->run();
22
        } catch (Throwable $e) {
23
            throw new Exception\QueryAstNotTranslatedException($queryAst, $e);
24 6
        }
25 6
26 1
        return new Query($source, $callbackBuilder);
27 1
    }
28
}
29