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

GrantRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 26
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A matching() 0 10 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