Passed
Push — master ( 5cce8c...cb0ced )
by Edward
04:53
created

QueryValidator::getAddressableQuery()   A

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
declare(strict_types=1);
3
4
namespace Remorhaz\JSON\Path\Query;
5
6
use Remorhaz\JSON\Path\Processor\Exception;
7
8
final class QueryValidator implements QueryValidatorInterface
9
{
10
11 2
    public function getDefiniteQuery(QueryInterface $query): QueryInterface
12
    {
13 2
        if (!$query->getCapabilities()->isDefinite()) {
14 1
            throw new Exception\IndefiniteQueryException($query);
15
        }
16
17 1
        return $query;
18
    }
19
20 2
    public function getAddressableQuery(QueryInterface $query): QueryInterface
21
    {
22 2
        if (!$query->getCapabilities()->isAddressable()) {
23 1
            throw new Exception\NotAddressableQueryException($query);
24
        }
25
26 1
        return $query;
27
    }
28
}
29