InstallItemPass   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 24
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 18 5
1
<?php
2
/**
3
 * AnimeDb package.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2011, Peter Gribanov
7
 * @license   http://opensource.org/licenses/GPL-3.0 GPL v3
8
 */
9
10
namespace AnimeDb\Bundle\CatalogBundle\DependencyInjection\Compiler;
11
12
use Symfony\Component\DependencyInjection\ContainerBuilder;
13
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
14
use Symfony\Component\DependencyInjection\Reference;
15
16
/**
17
 * Install item compiler pass.
18
 *
19
 * @author  Peter Gribanov <[email protected]>
20
 */
21
class InstallItemPass implements CompilerPassInterface
22
{
23
    /**
24
     * @param ContainerBuilder $container
25
     */
26
    public function process(ContainerBuilder $container)
27
    {
28
        if (
29
            $container->getParameter('anime_db.catalog.installed') ||
30
            !$container->has('anime_db.install.item.chain')
31
        ) {
32
            return;
33
        }
34
35
        $definition = $container->findDefinition('anime_db.install.item.chain');
36
        $taggedServices = $container->findTaggedServiceIds('anime_db.install_item');
37
        foreach ($taggedServices as $id => $attributes) {
38
            $definition->addMethodCall(
39
                !empty($attributes[0]['debug']) ? 'addDebugItem' : 'addPublicItem',
40
                [new Reference($id)]
41
            );
42
        }
43
    }
44
}
45