PackageManagerCompilerPass::process()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 16
Code Lines 8

Duplication

Lines 16
Ratio 100 %

Importance

Changes 0
Metric Value
dl 16
loc 16
rs 9.2
c 0
b 0
f 0
cc 4
eloc 8
nc 4
nop 1
1
<?php declare(strict_types=1);
2
3
/**
4
 * This file is part of Packy.
5
 *
6
 * (c) Peter Nijssen
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace AppBundle\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
class PackageManagerCompilerPass 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
    /**
21
     * Process compiler.
22
     *
23
     * @param ContainerBuilder $container
24
     */
25
    public function process(ContainerBuilder $container)
26
    {
27
        if (!$container->has('packy.package_managers')) {
28
            return;
29
        }
30
31
        $definition = $container->findDefinition('packy.package_managers');
32
33
        $taggedServices = $container->findTaggedServiceIds('packy_package_manager');
34
35
        foreach ($taggedServices as $id => $tags) {
36
            foreach ($tags as $attributes) {
37
                $definition->addMethodCall('add', [new Reference($id), $attributes["alias"]]);
38
            }
39
        }
40
    }
41
}
42