SelectorValidationTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 17
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A validateSelector() 0 9 3
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
namespace Spiral\Listing\Traits;
9
10
use Spiral\Listing\Exceptions\InvalidSelectorException;
11
use Spiral\ODM\Entities\DocumentSelector;
12
use Spiral\ORM\Entities\RecordSelector;
13
use Spiral\Pagination\PaginatorAwareInterface;
14
15
trait SelectorValidationTrait
16
{
17
    /**
18
     * @param PaginatorAwareInterface|RecordSelector|DocumentSelector $selector
19
     *
20
     * @throws InvalidSelectorException
21
     */
22
    protected function validateSelector(PaginatorAwareInterface $selector)
23
    {
24
        if (!$selector instanceof RecordSelector && !$selector instanceof DocumentSelector) {
25
            throw new InvalidSelectorException(
26
                "Only instance of Record/Document selectors are allowed, '"
27
                . get_class($selector) . "'"
28
            );
29
        }
30
    }
31
}