Completed
Branch master (ddb139)
by Yann
02:49
created

ConventionedEnumCollectorCompilerPass::process()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 4.1967

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 19
ccs 10
cts 13
cp 0.7692
rs 9.2
cc 4
eloc 11
nc 5
nop 1
crap 4.1967
1
<?php
2
3
namespace 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 3
    public function process(ContainerBuilder $container)
17
    {
18 3
        $bundles = $container->getParameter('enum.register_bundles');
19
20 3
        if (!$bundles) {
21
            return;
22
        }
23
24 3
        if (true === $bundles) {
25
            $bundles = $container->getParameter('kernel.bundles');
26
        } else {
27 3
            $bundles = (array) $bundles;
28
        }
29
30 3
        foreach ($bundles as $bundleClass) {
31 3
            $declarativePass = new DeclarativeEnumCollectorCompilerPass($bundleClass);
32 3
            $declarativePass->process($container);
33 3
        }
34 3
    }
35
}
36