Completed
Push — master ( a199f7...eac768 )
by Oleg
06:42
created

PermissionHistoryRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 26
ccs 7
cts 8
cp 0.875
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\Authorization\Repository;
5
6
use Doctrine\Common\Collections\Collection;
7
use Doctrine\Common\Collections\Criteria;
8
use Doctrine\Common\Collections\Selectable;
9
use SlayerBirden\DataFlowServer\Authorization\Entities\History;
10
use SlayerBirden\DataFlowServer\Doctrine\Persistence\EntityManagerRegistry;
11
12
final class PermissionHistoryRepository implements Selectable
13
{
14
    /**
15
     * @var EntityManagerRegistry
16
     */
17
    private $managerRegistry;
18
19 2
    public function __construct(EntityManagerRegistry $managerRegistry)
20
    {
21 2
        $this->managerRegistry = $managerRegistry;
22 2
    }
23
24
    /**
25
     * @inheritdoc
26
     */
27 2
    public function matching(Criteria $criteria): Collection
28
    {
29 2
        $repo = $this->managerRegistry->getRepository(History::class);
30
31 2
        if ($repo instanceof Selectable) {
32 2
            return $repo->matching($criteria);
33
        }
34
35
        throw new \LogicException('Permission history repository does not support "matching"');
36
    }
37
}
38