Passed
Push — master ( c6e62a...162b02 )
by Edward
03:02
created

Query::getCapabilities()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace Remorhaz\JSON\Path\Query;
5
6
use function call_user_func;
7
use Remorhaz\JSON\Data\Value\NodeValueInterface;
8
use Remorhaz\JSON\Path\Value\ValueListInterface;
9
use Remorhaz\JSON\Path\Runtime\RuntimeInterface;
10
11
final class Query implements QueryInterface
12
{
13
14
    private $source;
15
16
    private $callback;
17
18
    private $properties;
19
20
    public function __construct(string $source, callable $callback, QueryCapabilitiesInterface $properties)
21
    {
22
        $this->source = $source;
23
        $this->callback = $callback;
24
        $this->properties = $properties;
25
    }
26
27
    public function __invoke(RuntimeInterface $runtime, NodeValueInterface $rootNode): ValueListInterface
28
    {
29
        return call_user_func($this->callback, $runtime, $rootNode);
30
    }
31
32
    /**
33
     * @return QueryCapabilitiesInterface
34
     * @deprecated
35
     */
36
    public function getProperties(): QueryCapabilitiesInterface
37
    {
38
        return $this->getCapabilities();
39
    }
40
41
    public function getCapabilities(): QueryCapabilitiesInterface
42
    {
43
        return $this->properties;
44
    }
45
46
    public function getSource(): string
47
    {
48
        return $this->source;
49
    }
50
}
51