Total Complexity | 6 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Coverage | 70.37% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | final class Query implements QueryInterface |
||
14 | { |
||
15 | |||
16 | private $source; |
||
17 | |||
18 | private $callbackBuilder; |
||
19 | |||
20 | 4 | public function __construct(string $source, CallbackBuilderInterface $callbackBuilder) |
|
21 | { |
||
22 | 4 | $this->source = $source; |
|
23 | 4 | $this->callbackBuilder = $callbackBuilder; |
|
24 | 4 | } |
|
25 | |||
26 | 2 | public function __invoke(NodeValueInterface $rootNode, RuntimeInterface $runtime): ValueListInterface |
|
27 | { |
||
28 | 2 | $input = (new NodeValueListBuilder) |
|
29 | 2 | ->addValue($rootNode, 0) |
|
30 | 2 | ->build(); |
|
31 | |||
32 | try { |
||
33 | return call_user_func( |
||
34 | $this |
||
35 | 2 | ->callbackBuilder |
|
36 | 2 | ->getCallback(), |
|
37 | $input, |
||
38 | 2 | $runtime->getValueListFetcher(), |
|
39 | 2 | $runtime->getEvaluator(), |
|
40 | 2 | $runtime->getLiteralFactory(), |
|
41 | 2 | $runtime->getMatcherFactory(), |
|
42 | ); |
||
43 | } catch (Throwable $e) { |
||
44 | throw new Exception\QueryExecutionFailedException( |
||
45 | $this->source, |
||
46 | $this->callbackBuilder->getCallbackCode(), |
||
47 | $e, |
||
48 | ); |
||
49 | } |
||
50 | } |
||
51 | |||
52 | 1 | public function getCapabilities(): CapabilitiesInterface |
|
53 | { |
||
54 | return $this |
||
55 | 1 | ->callbackBuilder |
|
56 | 1 | ->getCapabilities(); |
|
57 | } |
||
58 | |||
59 | 1 | public function getSource(): string |
|
60 | { |
||
61 | 1 | return $this->source; |
|
62 | } |
||
63 | |||
64 | public function getCallbackCode(): string |
||
69 | } |
||
70 | } |
||
71 |