ReportStylePass::process()   B
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 22
Code Lines 10

Duplication

Lines 22
Ratio 100 %

Importance

Changes 0
Metric Value
dl 22
loc 22
rs 8.9197
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
12
namespace Symball\ReportBundle\DependencyInjection\Compiler;
13
14
/**
15
 * Description of ReportStylePass
16
 *
17
 * @author Simon Ball <simonball at simonball dot me>
18
 */
19
use Symfony\Component\DependencyInjection\ContainerBuilder;
20
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
21
use Symfony\Component\DependencyInjection\Reference;
22
23 View Code Duplication
class ReportStylePass 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...
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function process(ContainerBuilder $container)
29
    {
30
        // always first check if the primary service is defined
31
        if (!$container->has('symball_report.style')) {
32
            return;
33
        }
34
35
        $definition = $container->findDefinition('symball_report.style');
36
37
        // find all service IDs with the app.mail_transport tag
38
        $taggedServices = $container->findTaggedServiceIds('symball_report.style');
39
40
        foreach ($taggedServices as $id => $tags) {
41
            foreach ($tags as $attributes) {
42
                // add the transport service to the ChainTransport service
43
                $definition->addMethodCall('addStyle', array(
44
                    new Reference($id),
45
                    $attributes["alias"],
46
                ));
47
            }
48
        }
49
    }
50
}
51