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

Query   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 38
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getProperties() 0 3 1
A __construct() 0 5 1
A getSource() 0 3 1
A __invoke() 0 3 1
A getCapabilities() 0 3 1
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