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

AstTranslator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 16
ccs 7
cts 7
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A buildQuery() 0 13 2
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