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

LogfileListCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 17 2
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