Completed
Push — sensio-insight-fixes ( 787c3e )
by Yann
07:09
created

ConventionedEnumCollectorCompilerPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 19 4
1
<?php
2
3
namespace Yokai\EnumBundle\DependencyInjection\CompilerPass;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
8
/**
9
 * @author Yann Eugoné <[email protected]>
10
 */
11
class ConventionedEnumCollectorCompilerPass implements CompilerPassInterface
12
{
13
    /**
14
     * @inheritdoc
15
     */
16
    public function process(ContainerBuilder $container)
17
    {
18
        $bundles = $container->getParameter('enum.register_bundles');
19
20
        if (!$bundles) {
21
            return;
22
        }
23
24
        if (true === $bundles) {
25
            $bundles = $container->getParameter('kernel.bundles');
26
        } else {
27
            $bundles = (array) $bundles;
28
        }
29
30
        foreach ($bundles as $bundleClass) {
31
            $declarativePass = new DeclarativeEnumCollectorCompilerPass($bundleClass);
32
            $declarativePass->process($container);
33
        }
34
    }
35
}
36