Passed
Push — master ( 03e013...bd5966 )
by Anatoly
01:18 queued 14s
created

DoctrineFactory::createEntityManager()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
nc 1
nop 2
dl 0
loc 13
c 1
b 0
f 0
cc 1
ccs 7
cts 7
cp 1
crap 1
rs 10
1
<?php declare(strict_types=1);
2
3
namespace App\Factory;
4
5
/**
6
 * Import classes
7
 */
8
use Arus\Doctrine\RepositoryFactory\InjectableRepositoryFactory;
9
use Doctrine\ORM\Tools\Setup;
10
use Doctrine\ORM\EntityManager;
11
use Doctrine\ORM\EntityManagerInterface;
12
use Psr\Container\ContainerInterface;
13
14
/**
15
 * DoctrineFactory
16
 *
17
 * Don't use this factory outside the container!
18
 */
19
final class DoctrineFactory
20
{
21
22
    /**
23
     * Creates Doctrine Entity Manager instance
24
     *
25
     * @param array $params
26
     * @param ContainerInterface $container
27
     *
28
     * @return EntityManagerInterface
29
     */
30 14
    public function createEntityManager(array $params, ContainerInterface $container) : EntityManagerInterface
31
    {
32 14
        $configuration = Setup::createConfiguration(false, $params['proxyDir'], $params['cache']);
33
34 14
        $configuration->setMetadataDriverImpl(
35 14
            $configuration->newDefaultAnnotationDriver($params['metadata']['sources'], true)
0 ignored issues
show
Bug introduced by
$configuration->newDefau...ata']['sources'], true) of type Doctrine\ORM\Mapping\Driver\AnnotationDriver is incompatible with the type Doctrine\Common\Persiste...ng\Driver\MappingDriver expected by parameter $driverImpl of Doctrine\ORM\Configurati...setMetadataDriverImpl(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

35
            /** @scrutinizer ignore-type */ $configuration->newDefaultAnnotationDriver($params['metadata']['sources'], true)
Loading history...
36
        );
37
38 14
        $configuration->setRepositoryFactory(
39 14
            new InjectableRepositoryFactory($container)
40
        );
41
42 14
        return EntityManager::create($params['connection'], $configuration);
43
    }
44
}
45