Completed
Push — master ( 3c0a55...3afa22 )
by Maxime
02:42 queued 01:12
created

DoctrineDBALTypesPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A process() 0 12 2
1
<?php
2
3
/*
4
 * This file is part of the "elao/enum" package.
5
 *
6
 * Copyright (C) Elao
7
 *
8
 * @author Elao <[email protected]>
9
 */
10
11
namespace Elao\Enum\Bridge\Symfony\Bundle\DependencyInjection\Compiler;
12
13
use Elao\Enum\Bridge\Doctrine\DBAL\Types\TypesDumper;
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
17
class DoctrineDBALTypesPass implements CompilerPassInterface
18
{
19
    /** @var string */
20
    private $typesFilePath;
21
22
    public function __construct(string $typesFilePath)
23
    {
24
        $this->typesFilePath = $typesFilePath;
25
    }
26
27
    public function process(ContainerBuilder $container)
28
    {
29
        if (!$container->hasParameter('.elao_enum.doctrine_types')) {
30
            return;
31
        }
32
33
        $types = $container->getParameter('.elao_enum.doctrine_types');
34
35
        (new TypesDumper())->dumpToFile($this->typesFilePath, $types);
36
37
        $container->getDefinition('doctrine.dbal.connection_factory')->setFile($this->typesFilePath);
38
    }
39
}
40