AddHistoryFactoryCompilerPass   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 11
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 9 2
1
<?php
2
3
/**
4
 * Static Analysis Results Baseliner (sarb).
5
 *
6
 * (c) Dave Liddament
7
 *
8
 * For the full copyright and licence information please view the LICENSE file distributed with this source code.
9
 */
10
11
declare(strict_types=1);
12
13
namespace DaveLiddament\StaticAnalysisResultsBaseliner\Framework\Container\internal;
14
15
use DaveLiddament\StaticAnalysisResultsBaseliner\Framework\Container\Container;
16
use DaveLiddament\StaticAnalysisResultsBaseliner\Framework\Container\HistoryFactoryRegistry;
17
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
use Symfony\Component\DependencyInjection\Reference;
20
21
final class AddHistoryFactoryCompilerPass implements CompilerPassInterface
22
{
23
    public function process(ContainerBuilder $container): void
24
    {
25
        $definition = $container->getDefinition(HistoryFactoryRegistry::class);
26
        $taggedServices = $container->findTaggedServiceIds(Container::HISTORY_FACTORY_TAG);
27
        $services = [];
28
        foreach (array_keys($taggedServices) as $id) {
29
            $services[] = new Reference($id);
30
        }
31
        $definition->setArgument(0, $services);
32
    }
33
}
34