Completed
Push — master ( 5c0b6f...5c71f2 )
by Oleg
10:16
created

GrantRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DataFlowServer\Authentication\Repository;
5
6
use Doctrine\Common\Collections\Collection;
7
use Doctrine\Common\Collections\Criteria;
8
use Doctrine\Common\Collections\Selectable;
9
use Doctrine\Common\Persistence\ManagerRegistry;
10
use SlayerBirden\DataFlowServer\Authentication\Entities\Grant;
11
12
final class GrantRepository implements Selectable
13
{
14
    /**
15
     * @var ManagerRegistry
16
     */
17
    private $managerRegistry;
18
19
    public function __construct(ManagerRegistry $managerRegistry)
20
    {
21
        $this->managerRegistry = $managerRegistry;
22
    }
23
24
    /**
25
     * @inheritdoc
26
     */
27
    public function matching(Criteria $criteria): Collection
28
    {
29
        $repo = $this->managerRegistry->getRepository(Grant::class);
30
31
        if ($repo instanceof Selectable) {
32
            return $repo->matching($criteria);
33
        }
34
35
        throw new \LogicException('Grant repository does not support "matching"');
36
    }
37
}
38