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

DbConfigurationRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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