CommandLoader   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 18
rs 10
ccs 5
cts 5
cp 1
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A load() 0 8 2
1
<?php
2
/**
3
 * Copyright (c) 2020.
4
 * @author Paweł Antosiak <[email protected]>
5
 */
6
7
declare(strict_types=1);
8
9
namespace Gorynych\Util;
10
11
use Symfony\Component\Console\Application;
12
use Symfony\Component\Console\Command\Command;
13
use Symfony\Component\DependencyInjection\ContainerBuilder;
14
15
final class CommandLoader
16
{
17
    public const COMMAND_TAG = 'console.command';
18
19
    /**
20
     * Loads tagged command services into CLI application
21
     *
22
     * @param Application $cliApp
23
     * @param ContainerBuilder $container
24
     */
25 1
    public function load(Application $cliApp, ContainerBuilder $container): void
26
    {
27 1
        $commandServices = $container->findTaggedServiceIds(self::COMMAND_TAG);
28
29 1
        foreach ($commandServices as $commandId => $tags) {
30
            /** @var Command $command */
31 1
            $command = $container->get($commandId);
32 1
            $cliApp->add($command);
33
        }
34 1
    }
35
}
36