Passed
Push — master ( c6e62a...162b02 )
by Edward
03:02
created

QueryValidator::getDefiniteQuery()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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