ExtensionLoadPass   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 38
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A process() 0 8 3
A loadExtension() 0 6 2
1
<?php
2
3
namespace SymfonyBundles\BundleDependency\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\Extension\Extension;
7
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
9
class ExtensionLoadPass implements CompilerPassInterface
10
{
11
    /**
12
     * @var array
13
     */
14
    private $bundles;
15
16
    /**
17
     * @param array $bundles
18
     */
19 1
    public function __construct(array $bundles)
20
    {
21 1
        $this->bundles = $bundles;
22 1
    }
23
24
    /**
25
     * {@inheritdoc}
26
     */
27 1
    public function process(ContainerBuilder $container)
28
    {
29 1
        foreach ($this->bundles as $bundle) {
30 1
            if ($extension = $bundle->getContainerExtension()) {
31 1
                $this->loadExtension($extension, $container);
32 1
            }
33 1
        }
34 1
    }
35
36
    /**
37
     * @param Extension        $extension
38
     * @param ContainerBuilder $container
39
     */
40 1
    private function loadExtension(Extension $extension, ContainerBuilder $container)
41
    {
42 1
        if (!$container->getExtensionConfig($extension->getAlias())) {
43 1
            $extension->load([], $container);
44 1
        }
45 1
    }
46
}
47