ConfirmationPass   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 6
c 3
b 0
f 1
lcom 0
cbo 3
dl 0
loc 35
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 32 6
1
<?php
2
3
namespace DoS\UserBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
class ConfirmationPass implements CompilerPassInterface
10
{
11
    public function process(ContainerBuilder $container)
12
    {
13
        if (!$container->has('dos.user.confirmation.factory')) {
14
            return;
15
        }
16
17
        $definition = $container->findDefinition('dos.user.confirmation.factory');
18
        $taggedServices = $container->findTaggedServiceIds('dos.user.confirmation');
19
        $defaultOptions = $container->getParameter('dos.user.confirmation');
20
21
        foreach ($taggedServices as $id => $tags) {
22
            foreach ($tags as $attributes) {
23
                $def = new Reference($id);
24
                $alias = $attributes['alias'];
25
                $definition->addMethodCall('add', array($def));
26
27
                if (array_key_exists($alias, $defaultOptions['types'])) {
28
                    $container
29
                        ->findDefinition($id)
30
                        ->addMethodCall('resetOptions', array($defaultOptions['types'][$alias]))
31
                    ;
32
                }
33
            }
34
        }
35
36
        if ($container->hasParameter('dos.user.confirmation.actived')) {
37
            $definition->addMethodCall(
38
                'setActivedService',
39
                array($container->getParameter('dos.user.confirmation.actived'))
40
            );
41
        }
42
    }
43
}
44