ConsoleCommandPass   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 13 1
1
<?php declare(strict_types=1);
2
3
namespace Cocotte\DependencyInjection;
4
5
use Symfony\Component\Console\Application;
6
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
final class ConsoleCommandPass implements CompilerPassInterface
11
{
12
13
    public function process(ContainerBuilder $container)
14
    {
15
        $ids = array_keys($container->findTaggedServiceIds('console.command', true));
16
17
        $refs = array_map(
18
            function ($id) {
19
                return new Reference($id);
20
            },
21
            $ids
22
        );
23
24
        $console = $container->getDefinition(Application::class);
25
        $console->addMethodCall('addCommands', [$refs]);
26
    }
27
}
28