Completed
Push — develop ( 4c84f9...64a224 )
by Florent
05:18
created

AlgorithmCompilerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 13
Ratio 100 %

Importance

Changes 10
Bugs 5 Features 1
Metric Value
c 10
b 5
f 1
dl 13
loc 13
rs 9.4285
cc 3
eloc 7
nc 3
nop 1
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2016 Spomky-Labs
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license.  See the LICENSE file for details.
10
 */
11
12
namespace SpomkyLabs\JoseBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Reference;
17
18 View Code Duplication
final class AlgorithmCompilerPass 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...
19
{
20
    public function process(ContainerBuilder $container)
21
    {
22
        if (!$container->hasDefinition('jose.algorithm_manager')) {
23
            return;
24
        }
25
26
        $definition = $container->getDefinition('jose.algorithm_manager');
27
28
        $taggedServices = $container->findTaggedServiceIds('jose.algorithm');
29
        foreach ($taggedServices as $id => $tags) {
30
            $definition->addMethodCall('addAlgorithm', [new Reference($id)]);
31
        }
32
    }
33
}
34