Passed
Push — add-command-list-modules ( fd1ae6 )
by Chema
11:55
created

ListModulesCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Console\Infrastructure\Command;
6
7
use Gacela\Console\ConsoleFacade;
8
use Gacela\Framework\DocBlockResolverAwareTrait;
9
use Symfony\Component\Console\Command\Command;
10
use Symfony\Component\Console\Helper\Table;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Output\OutputInterface;
13
14
/**
15
 * @method ConsoleFacade getFacade()
16
 */
17
final class ListModulesCommand extends Command
18
{
19
    use DocBlockResolverAwareTrait;
20
21 3
    protected function configure(): void
22
    {
23 3
        $this->setName('list:modules')
24 3
            ->setDescription('Render all modules found');
25
    }
26
27 1
    protected function execute(InputInterface $input, OutputInterface $output): int
28
    {
29 1
        $modules = $this->getFacade()->findAllAppModules();
30
31 1
        $table = new Table($output);
32 1
        $table->setHeaders(['class_name', 'namespace']);
33
34 1
        foreach ($modules as $module) {
35 1
            $table->addRow([
36 1
                $module->className(),
37 1
                $module->fullyQualifiedClassName(),
38 1
            ]);
39
        }
40
41 1
        $output->writeln('Modules found:');
42 1
        $table->render();
43
44 1
        return self::SUCCESS;
45
    }
46
}
47