MailhookCompilerPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 16
c 0
b 0
f 0
wmc 3
lcom 0
cbo 2
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 13 3
1
<?php
2
3
namespace Swm\Bundle\MailHookBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\ContainerBuilder;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
class MailhookCompilerPass implements CompilerPassInterface
10
{
11
    public function process(ContainerBuilder $container)
12
    {
13
        foreach ($container->findTaggedServiceIds('swm.mailhook') as $id => $tag) {
14
            $tag = array_pop($tag);
15
16
            if (!isset($tag['alias'])) {
17
                throw new \Exception('You should define an alias for all "swm.mailhook" tagged services');
18
            }
19
20
            $container->getDefinition('swm.mail_hook.provider.api_service')
21
                ->addMethodCall('setApiService', array($tag['alias'], $container->getDefinition($id)));
22
        }
23
    }
24
}