Passed
Push — master ( 108ac6...3f16d8 )
by Koldo
01:36 queued 11s
created

EntityRepositoryFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
c 1
b 0
f 1
dl 0
loc 14
ccs 7
cts 7
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 12 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Antidot\Persistence\Doctrine\Container;
6
7
use Antidot\Persistence\Doctrine\Container\Config\ConfigProvider;
8
use Doctrine\ORM\EntityManagerInterface;
9
use Doctrine\Persistence\ObjectRepository;
10
use Psr\Container\ContainerInterface;
11
use RuntimeException;
12
13
class EntityRepositoryFactory
14
{
15 2
    public function __invoke(ContainerInterface $container, string $model): ObjectRepository
16
    {
17 2
        $em = $container->get(EntityManagerInterface::class);
18
19 2
        if (false === $em instanceof EntityManagerInterface) {
20 1
            throw new RuntimeException(sprintf(
21 1
                ConfigProvider::CONTAINER_EXCEPTION_MESSAGE_PATTER,
22 1
                EntityManagerInterface::class
23
            ));
24
        }
25
26 1
        return $em->getRepository($model);
27
    }
28
}
29