QueryValidator::getDefiniteQuery()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Remorhaz\JSON\Path\Query;
6
7
use Remorhaz\JSON\Path\Processor\Exception;
8
9
final class QueryValidator implements QueryValidatorInterface
10
{
11
12 2
    public function getDefiniteQuery(QueryInterface $query): QueryInterface
13
    {
14 2
        if (!$query->getCapabilities()->isDefinite()) {
15 1
            throw new Exception\IndefiniteQueryException($query);
16
        }
17
18 1
        return $query;
19
    }
20
21 2
    public function getAddressableQuery(QueryInterface $query): QueryInterface
22
    {
23 2
        if (!$query->getCapabilities()->isAddressable()) {
24 1
            throw new Exception\QueryNotAddressableException($query);
25
        }
26
27 1
        return $query;
28
    }
29
}
30