DoctrineORMCustomTypesPass   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 15 1
1
<?php
2
3
/*
4
 * This file is part of the Shared Kernel library.
5
 *
6
 * Copyright (c) 2016-present LIN3S <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace LIN3S\SharedKernel\Infrastructure\Symfony\Bundle\DependencyInjection\Compiler;
15
16
use LIN3S\SharedKernel\Infrastructure\Persistence\Doctrine\DBAL\Domain\Model\Phone\Types\PhoneType;
17
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
20
/**
21
 * @author Beñat Espiña <[email protected]>
22
 */
23
class DoctrineORMCustomTypesPass implements CompilerPassInterface
24
{
25
    public function process(ContainerBuilder $container)
26
    {
27
        $customTypes = $container->getParameter('doctrine.dbal.connection_factory.types');
28
        $customTypes = array_merge($customTypes, [
29
            'phone' => [
30
                'class'     => PhoneType::class,
31
                'commented' => true,
32
            ],
33
        ]);
34
35
        $container->setParameter('doctrine.dbal.connection_factory.types', $customTypes);
36
        $container->findDefinition('doctrine.dbal.connection_factory')->replaceArgument(
37
            0, '%doctrine.dbal.connection_factory.types%'
38
        );
39
    }
40
}
41