TemplateIdGuesserCompilerPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 15 3
1
<?php
2
3
namespace Dekalee\MailjetBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
/**
10
 * Class TemplateIdGuesserCompilerPass
11
 */
12
class TemplateIdGuesserCompilerPass implements CompilerPassInterface
13
{
14
    /**
15
     * You can modify the container here before it is dumped to PHP code.
16
     *
17
     * @param ContainerBuilder $container
18
     */
19
    public function process(ContainerBuilder $container)
20
    {
21
        $managerName = 'dekalee_mailjet.guesser.template_id.manager';
22
        $tagName = 'dekalee_mailjet.guesser.template_id.strategy';
23
        $methodName = 'addGuesser';
24
25
        if (!$container->hasDefinition($managerName)) {
26
            return;
27
        }
28
        $manager = $container->getDefinition($managerName);
29
        $strategies = $container->findTaggedServiceIds($tagName);
30
        foreach ($strategies as $id => $attributes) {
31
            $manager->addMethodCall($methodName, array(new Reference($id)));
32
        }
33
    }
34
}
35