SirenCollectionPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 3
c 2
b 1
f 1
lcom 0
cbo 3
dl 0
loc 30
ccs 0
cts 18
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 21 3
1
<?php
2
3
/*
4
 * This file is part of the Doctrine Bundle
5
 *
6
 * (c) Fabien Potencier <[email protected]>
7
 * (c) Doctrine Project, Benjamin Eberlei <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace IncidentBundle\DependencyInjection\Compiler;
14
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
17
use Symfony\Component\DependencyInjection\Reference;
18
19
/**
20
 * Class for SirenCollection
21
 */
22
class SirenCollectionPass implements CompilerPassInterface
23
{
24
    const INCIDENT_SIREN_NOTIFICATION = 'incident.siren.notification';
25
    const INCIDENT_SIREN = 'incident.siren';
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function process(ContainerBuilder $container)
31
    {
32
        if (!$container->hasDefinition(self::INCIDENT_SIREN)) {
33
            return;
34
        }
35
36
        $sirenDefinition = $container->getDefinition(
37
            self::INCIDENT_SIREN
38
        );
39
40
        $taggedServices = $container->findTaggedServiceIds(
41
            self::INCIDENT_SIREN_NOTIFICATION
42
        );
43
44
        foreach ($taggedServices as $id => $tags) {
45
            $sirenDefinition->addMethodCall(
46
                    'add',
47
                    [new Reference($id)]
48
                );
49
        }
50
    }
51
}
52