ReportPatternPass::process()   B
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 23
Code Lines 10

Duplication

Lines 23
Ratio 100 %

Importance

Changes 0
Metric Value
dl 23
loc 23
rs 8.7972
c 0
b 0
f 0
cc 4
eloc 10
nc 4
nop 1
1
<?php
2
3
/*
4
 * This file is part of the ReportBundle package
5
 * 
6
 * (c) symball <http://simonball.me>
7
 * 
8
 * For the full copyright and license information, please view the LICENSE file 
9
 * that was distributed with this source code.
10
 */
11
namespace Symball\ReportBundle\DependencyInjection\Compiler;
12
13
/**
14
 * Description of ReportPatternPass
15
 *
16
 * @author Simon Ball <simonball at simonball dot me>
17
 */
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
20
use Symfony\Component\DependencyInjection\Reference;
21
22 View Code Duplication
class ReportPatternPass implements CompilerPassInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function process(ContainerBuilder $container)
28
    {
29
        
30
        // always first check if the primary service is defined
31
        if (!$container->has('symball_report.pattern')) {
32
            return;
33
        }
34
        
35
        $definition = $container->findDefinition('symball_report.pattern');
36
        
37
        // find all service IDs with the app.mail_transport tag
38
        $taggedServices = $container->findTaggedServiceIds('symball_report.pattern');
39
40
        foreach ($taggedServices as $id => $tags) {
41
            foreach ($tags as $attributes) {
42
                // add the transport service to the ChainTransport service
43
                $definition->addMethodCall('addPattern', array(
44
                    new Reference($id),
45
                    $attributes["alias"],
46
                ));
47
            }
48
        }
49
    }
50
}
51