ConsignmentServicePass::process()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 14
ccs 0
cts 11
cp 0
rs 9.4285
cc 3
eloc 7
nc 3
nop 1
crap 12
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Loevgaard\DandomainConsignmentBundle\DependencyInjection\Compiler;
6
7
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\DependencyInjection\Reference;
10
11
class ConsignmentServicePass implements CompilerPassInterface
12
{
13
    public function process(ContainerBuilder $container)
14
    {
15
        if (!$container->has('loevgaard_dandomain_consignment.consignment_service_collection')) {
16
            return;
17
        }
18
19
        $definition = $container->findDefinition('loevgaard_dandomain_consignment.consignment_service_collection');
20
21
        $taggedServices = $container->findTaggedServiceIds('ldc.consignment_service');
22
23
        foreach ($taggedServices as $id => $tags) {
24
            $definition->addMethodCall('addConsignmentService', [new Reference($id)]);
25
        }
26
    }
27
}
28