SirenCollectionPass::process()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 21
ccs 0
cts 18
cp 0
rs 9.3142
cc 3
eloc 11
nc 3
nop 1
crap 12
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