QueryValidator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 19
ccs 8
cts 8
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAddressableQuery() 0 7 2
A getDefiniteQuery() 0 7 2
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