Passed
Push — master ( 78a1e9...1a588d )
by Nils
03:05
created

LogfileListCommand::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 17
rs 10
1
<?php
2
3
namespace Startwind\Inventorio\Command;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Helper\Table;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
class LogfileListCommand extends InventorioCommand
11
{
12
    protected static $defaultName = 'logfile:list';
13
    protected static $defaultDescription = 'List all registered commands';
14
15
    /**
16
     * @inheritDoc
17
     */
18
    protected function execute(InputInterface $input, OutputInterface $output): int
19
    {
20
        $this->initConfiguration($input->getOption('configFile'));
21
22
        $logfiles = $this->config->getLogfiles();
23
24
        $table = new Table($output);
25
26
        $table->setHeaders(['Name', 'File']);
27
28
        foreach ($logfiles as $row) {
29
            $table->addRow([$row['name'], $row['file']]);
30
        }
31
32
        $table->render();
33
34
        return Command::SUCCESS;
35
    }
36
}
37