Passed
Push — main ( fefea7...05b26b )
by mikhail
08:12
created

BaselineCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 1

Importance

Changes 8
Bugs 3 Features 0
Metric Value
eloc 11
c 8
b 3
f 0
dl 0
loc 20
ccs 12
cts 12
cp 1
rs 9.9
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SavinMikhail\CommentsDensity\Commands;
6
7
use SavinMikhail\CommentsDensity\Analyzer\AnalyzerFactory;
0 ignored issues
show
Bug introduced by
The type SavinMikhail\CommentsDen...nalyzer\AnalyzerFactory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use SavinMikhail\CommentsDensity\Baseline\Storage\TreePhpBaselineStorage;
9
use Symfony\Component\Console\Command\Command as SymfonyCommand;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
final class BaselineCommand extends Command
14
{
15 1
    protected function configure(): void
16
    {
17 1
        $this->setName('generate:baseline')
18 1
            ->setDescription('Generate a baseline of comments to ignore them in the future')
19 1
            ->setHelp('This command allows you to ignore old tech debt and start this quality check from this point');
20
    }
21
22
    /**
23
     * @inheritDoc
24
     */
25 1
    protected function execute(InputInterface $input, OutputInterface $output): int
26
    {
27 1
        $path = __DIR__ . '/../../baseline.php';
28
29 1
        $storage = new TreePhpBaselineStorage();
30 1
        $storage->init($path);
31
32 1
        $configDto = $this->getConfigDto();
33
34 1
        $files = $this->getFilesFromDirectories($configDto->directories);
35 1
        $analyzerFactory = new AnalyzerFactory();
36
37 1
        $analyzer = $analyzerFactory->getAnalyzer($configDto, $output, $storage);
38 1
        $outputDTO = $analyzer->analyze($files);
39
40 1
        $storage->setComments($outputDTO->comments);
41
42 1
        $output->writeln('<info>Baseline generated successfully!</info>');
43
44 1
        return SymfonyCommand::SUCCESS;
45
    }
46
}
47