Passed
Push — master ( c2f53d...1e149c )
by Edward
02:16
created

Query   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 21
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isDefinite() 0 3 1
A __invoke() 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 $isDefinite;
17
18
    public function __construct(callable $callback, bool $isDefinite)
19
    {
20
        $this->callback = $callback;
21
        $this->isDefinite = $isDefinite;
22
    }
23
24
    public function __invoke(RuntimeInterface $runtime, NodeValueInterface $rootNode): ValueListInterface
25
    {
26
        return call_user_func($this->callback, $runtime, $rootNode);
27
    }
28
29
    public function isDefinite(): bool
30
    {
31
        return $this->isDefinite;
32
    }
33
}
34