Passed
Push — master ( 78e027...fa2487 )
by Edward
02:26
created

Query   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
dl 0
loc 30
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 3 1
A getProperties() 0 3 1
A isDefinite() 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 $callback;
15
16
    private $properties;
17
18
    public function __construct(callable $callback, QueryPropertiesInterface $properties)
19
    {
20
        $this->callback = $callback;
21
        $this->properties = $properties;
22
    }
23
24
    public function __invoke(RuntimeInterface $runtime, NodeValueInterface $rootNode): ValueListInterface
25
    {
26
        return call_user_func($this->callback, $runtime, $rootNode);
27
    }
28
29
    /**
30
     * @return bool
31
     * @deprecated
32
     */
33
    public function isDefinite(): bool
34
    {
35
        return $this->properties->isDefinite();
36
    }
37
38
    public function getProperties(): QueryPropertiesInterface
39
    {
40
        return $this->properties;
41
    }
42
}
43