QueryFactory::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\JSON\Path\Query;
6
7
use Remorhaz\JSON\Path\Parser\Ll1ParserFactory;
8
use Remorhaz\JSON\Path\Parser\Parser;
9
use Remorhaz\JSON\Path\Parser\ParserInterface;
10
11
final class QueryFactory implements QueryFactoryInterface
12
{
13
14
    private $parser;
15
16
    private $astTranslator;
17
18 1
    public static function create(): QueryFactoryInterface
19
    {
20 1
        return new QueryFactory(
21 1
            new Parser(new Ll1ParserFactory()),
22 1
            new AstTranslator(),
23
        );
24
    }
25
26 5
    public function __construct(ParserInterface $parser, AstTranslatorInterface $astTranslator)
27
    {
28 5
        $this->parser = $parser;
29 5
        $this->astTranslator = $astTranslator;
30 5
    }
31
32 4
    public function createQuery(string $path): QueryInterface
33
    {
34 4
        return new LazyQuery($path, $this->parser, $this->astTranslator, new CallbackBuilder());
35
    }
36
}
37