AddCommandCompilerPass::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
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 Symfony\Component\Console\Application;
17
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
use Symfony\Component\DependencyInjection\Reference;
20
21
final class AddCommandCompilerPass implements CompilerPassInterface
22
{
23
    public function process(ContainerBuilder $container): void
24
    {
25
        $container->register(Application::class, Application::class);
26
        $definition = $container->getDefinition(Application::class);
27
        $definition->setPublic(true);
28
        $taggedServices = $container->findTaggedServiceIds(Container::COMMAND_TAG);
29
        foreach (array_keys($taggedServices) as $id) {
30
            $definition->addMethodCall('add', [new Reference($id)]);
31
        }
32
    }
33
}
34