Passed
Push — bugfix/support-windows ( 0e99e7...b5ecf8 )
by Jesús
06:33 queued 02:55
created

ListModulesCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
ccs 4
cts 4
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\InputArgument;
12
use Symfony\Component\Console\Input\InputInterface;
13
use Symfony\Component\Console\Output\OutputInterface;
14
15
/**
16
 * @method ConsoleFacade getFacade()
17
 */
18
final class ListModulesCommand extends Command
19
{
20
    use DocBlockResolverAwareTrait;
21
22 4
    protected function configure(): void
23
    {
24 4
        $this->setName('list:modules')
25 4
            ->setDescription('Render all modules found')
26 4
            ->addArgument('filter', InputArgument::OPTIONAL, 'Any filter to simplify the output');
27
    }
28
29 3
    protected function execute(InputInterface $input, OutputInterface $output): int
30
    {
31 3
        $filter = (string)$input->getArgument('filter');
32 3
        $modules = $this->getFacade()->findAllAppModules($filter);
33
34 3
        $table = new Table($output);
35 3
        $table->setHeaders(['Module', 'Facade']);
36
37 3
        foreach ($modules as $module) {
38 3
            $table->addRow([
39 3
                $module->moduleName(),
40 3
                $module->facadeClass(),
41 3
            ]);
42
        }
43
44 3
        $output->writeln('Modules found:');
45 3
        $table->render();
46
47 3
        return self::SUCCESS;
48
    }
49
}
50