PatchManagerCompilerPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 42.86%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 21
ccs 3
cts 7
cp 0.4286
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 10 3
1
<?php
2
3
namespace Cypress\PatchManager\Bundle\DependencyInjection;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Reference;
8
9
class PatchManagerCompilerPass implements CompilerPassInterface
10
{
11
    public const PATCH_MANAGER_HANDLER_TAG = 'patch_manager.handler';
12
13
    /**
14
     * You can modify the container here before it is dumped to PHP code.
15
     *
16
     * @param ContainerBuilder $container
17
     *
18
     * @api
19
     */
20 2
    public function process(ContainerBuilder $container): void
21
    {
22 2
        if (!$container->hasDefinition('patch_manager.operation_matcher')) {
23 2
            return;
24
        }
25
26
        $definition = $container->getDefinition('patch_manager.operation_matcher');
27
        $taggedServices = $container->findTaggedServiceIds(self::PATCH_MANAGER_HANDLER_TAG);
28
        foreach ($taggedServices as $id => $tags) {
29
            $definition->addMethodCall('addHandler', [new Reference($id)]);
30
        }
31
    }
32
}
33