Completed
Push — master ( aba493...5356ed )
by Ruud
315:38 queued 305:00
created

Compiler/AddLogProcessorsCompilerPass.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\AdminBundle\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
 * This compiler pass makes it possible to add processors for the Kunstmaan logger
11
 */
12 View Code Duplication
class AddLogProcessorsCompilerPass implements CompilerPassInterface
0 ignored issues
show
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...
13
{
14
    /**
15
     * @param ContainerBuilder $container
16
     */
17 5
    public function process(ContainerBuilder $container)
18
    {
19 5
        if (!$container->hasDefinition('kunstmaan_admin.logger')) {
20 1
            return;
21
        }
22
23 4
        $definition = $container->getDefinition('kunstmaan_admin.logger');
24
25 4
        foreach ($container->findTaggedServiceIds('kunstmaan_admin.logger.processor') as $id => $tags) {
26 4
            foreach ($tags as $tag) {
27 4
                if (!empty($tag['method'])) {
28 4
                    $processor = array(new Reference($id), $tag['method']);
29
                } else {
30
                    // If no method is defined, fallback to use __invoke
31 1
                    $processor = new Reference($id);
32
                }
33 4
                $definition->addMethodCall('pushProcessor', array($processor));
34
            }
35
        }
36 4
    }
37
}
38