RegisterFactorsPass::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
ccs 8
cts 8
cp 1
rs 9.4285
cc 2
eloc 8
nc 2
nop 1
crap 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\HomeostasisBundle\DependencyInjection\Compiler;
5
6
use Symfony\Component\DependencyInjection\{
7
    ContainerBuilder,
8
    Compiler\CompilerPassInterface,
9
    Reference
10
};
11
12
final class RegisterFactorsPass implements CompilerPassInterface
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17 4
    public function process(ContainerBuilder $container)
18
    {
19 4
        $services = $container->findTaggedServiceIds('innmind.homeostasis.factor');
20 4
        $factors = [];
21
22 4
        foreach ($services as $id => $tags) {
23 4
            $factors[] = new Reference($id);
24
        }
25
26
        $container
27 4
            ->getDefinition('innmind.homeostasis.regulator.default')
28 4
            ->replaceArgument(0, $factors);
29 4
    }
30
}
31