EntityManagerFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 9 1
1
<?php
2
3
/*
4
 * This file is part of the BenGorFile package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace BenGorFile\DoctrineORMBridge\Infrastructure\Persistence;
14
15
use BenGorFile\DoctrineORMBridge\Infrastructure\Persistence\Types\FileIdType;
16
use Doctrine\DBAL\Types\Type;
17
use Doctrine\ORM\EntityManager;
18
use Doctrine\ORM\Tools\Setup;
19
20
/**
21
 * Doctrine ORM entity manager factory class.
22
 *
23
 * @author Beñat Espiña <[email protected]>
24
 */
25
class EntityManagerFactory
26
{
27
    /**
28
     * Decorates the doctrine entity manager
29
     * with library's mappings and custom types.
30
     *
31
     * @param mixed $aConnection Connection parameters as db driver
32
     * @param bool  $isDevMode   Enables the dev mode, by default is enabled
33
     *
34
     * @return EntityManager
35
     */
36
    public function build($aConnection, $isDevMode = true)
37
    {
38
        Type::addType('file_id', FileIdType::class);
39
40
        return EntityManager::create(
41
            $aConnection,
42
            Setup::createYAMLMetadataConfiguration([__DIR__ . '/Mapping'], $isDevMode)
43
        );
44
    }
45
}
46