RuleEngineCompiler   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 8
c 1
b 0
f 0
dl 0
loc 20
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 12 2
1
<?php
2
3
4
namespace Oliverde8\PhpEtlBundle\DependencyInjection\Compiler;
5
6
7
use Oliverde8\Component\RuleEngine\RuleApplier;
8
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9
use Symfony\Component\DependencyInjection\ContainerBuilder;
10
use Symfony\Component\DependencyInjection\Reference;
11
12
class RuleEngineCompiler implements CompilerPassInterface
13
{
14
    public const TAG = "etl.rule";
15
16
17
    /**
18
     * You can modify the container here before it is dumped to PHP code.
19
     */
20
    public function process(ContainerBuilder $container)
21
    {
22
        $ruleApplierDefinition = $container->getDefinition(RuleApplier::class);
23
24
        $rules = $container->findTaggedServiceIds(self::TAG);
25
        $rulesReferences = [];
26
27
        foreach ($rules as $id => $parameters) {
28
            $rulesReferences[] = new Reference($id);
29
        }
30
31
        $ruleApplierDefinition->setArgument('$rules', $rulesReferences);
32
    }
33
34
}