Passed
Push — master ( f73d2a...b6f14a )
by f
14:52
created

FormatsCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

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
rs 10
1
<?php
2
3
namespace wapmorgan\UnifiedArchive\Commands;
4
5
use Symfony\Component\Console\Helper\Table;
6
use Symfony\Component\Console\Helper\TableCell;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use wapmorgan\UnifiedArchive\Formats;
10
11
class FormatsCommand extends BaseCommand
12
{
13
    protected static $defaultName = 'system:formats';
14
15
    protected function configure()
16
    {
17
        $this
18
            ->setDescription('Lists supported archive formats with current system configuration')
19
            ->setHelp('Lists supported archive formats with current system configuration. You can check supported formats and supported actions with them.')
20
        ;
21
    }
22
23
    public function execute(InputInterface $input, OutputInterface $output)
24
    {
25
        $table = new Table($output);
26
        $table->setHeaders(['format', 'open', 'stream', 'create', 'append', 'update', 'encrypt', 'drivers']);
27
28
        $i = 0;
29
        foreach (Formats::getFormatsReport() as $format => $config) {
30
            $table->setRow($i++, [
31
                $format,
32
                $config['open'] ? '+' : '',
33
                $config['stream'] ? '+' : '',
34
                $config['create'] ? '+' : '',
35
                $config['append'] ? '+' : '',
36
                $config['update'] ? '+' : '',
37
                $config['encrypt'] ? '+' : '',
38
                new TableCell(implode("\n", $config['drivers']), ['rowspan' => count($config['drivers'])])
39
            ]);
40
        }
41
        $table->render();
42
    }
43
}
44