ListResultsParsesCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
c 0
b 0
f 0
dl 0
loc 49
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 31 2
A __construct() 0 4 1
1
<?php
2
3
/**
4
 * Static Analysis Results Baseliner (sarb).
5
 *
6
 * (c) Dave Liddament
7
 *
8
 * For the full copyright and licence information please view the LICENSE file distributed with this source code.
9
 */
10
11
declare(strict_types=1);
12
13
namespace DaveLiddament\StaticAnalysisResultsBaseliner\Framework\Command;
14
15
use DaveLiddament\StaticAnalysisResultsBaseliner\Framework\Container\ResultsParsersRegistry;
16
use Symfony\Component\Console\Command\Command;
17
use Symfony\Component\Console\Input\InputInterface;
18
use Symfony\Component\Console\Output\OutputInterface;
19
20
final class ListResultsParsesCommand extends Command
21
{
22
    public const COMMAND_NAME = 'list-static-analysis-tools';
23
24
    /**
25
     * @var string|null
26
     */
27
    protected static $defaultName = self::COMMAND_NAME;
28
29
    /**
30
     * Constructor.
31
     */
32
    public function __construct(
33
        private ResultsParsersRegistry $staticAnalysisResultsParsersRegistry,
34
    ) {
35
        parent::__construct(self::COMMAND_NAME);
36
    }
37
38
    protected function execute(InputInterface $input, OutputInterface $output): int
39
    {
40
        $output->writeln('Supported static analysers');
41
        foreach ($this->staticAnalysisResultsParsersRegistry->getAll() as $resultsParser) {
42
            $identifier = $resultsParser->getIdentifier();
43
44
            $output->writeln(
45
                sprintf(
46
                    '[<info>%s</info>] %s',
47
                    $identifier->getCode(),
48
                    $identifier->getDescription(),
49
                ),
50
            );
51
52
            $output->writeln(
53
                sprintf(
54
                    '    Create baseline:         <info>%s | sarb create --input-format="%s"</info>',
55
                    $identifier->getToolCommand(),
56
                    $identifier->getCode(),
57
                ),
58
            );
59
60
            $output->writeln(
61
                sprintf(
62
                    '    Remove baseline results: <info>%s | sarb remove</info>',
63
                    $identifier->getToolCommand(),
64
                ),
65
            );
66
        }
67
68
        return 0;
69
    }
70
}
71