Passed
Push — main ( 28fe2f...804823 )
by mikhail
03:26
created

AnalyzeFilesCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
eloc 14
c 3
b 1
f 0
dl 0
loc 30
ccs 0
cts 16
cp 0
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A generateFiles() 0 4 2
A execute() 0 14 1
A configure() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SavinMikhail\CommentsDensity\Commands;
6
7
use Generator;
8
use SavinMikhail\CommentsDensity\AnalyzerFactory;
0 ignored issues
show
Bug introduced by
The type SavinMikhail\CommentsDensity\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...
9
use SavinMikhail\CommentsDensity\Reporters\ConsoleReporter;
0 ignored issues
show
Bug introduced by
The type SavinMikhail\CommentsDen...porters\ConsoleReporter 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...
10
use Symfony\Component\Console\Input\InputArgument;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Output\OutputInterface;
13
use SplFileInfo;
14
15
class AnalyzeFilesCommand extends Command
16
{
17
    protected function configure(): void
18
    {
19
        $this->setName('analyze:files')
20
            ->setDescription('Analyzes the comment density in multiple PHP files.')
21
            ->addArgument('files', InputArgument::IS_ARRAY, 'The PHP files to analyze')
22
            ->setHelp('This command allows you to analyze the comments in multiple PHP files.');
23
    }
24
25
    protected function execute(InputInterface $input, OutputInterface $output): int
26
    {
27
        $configDto = $this->getConfigDto();
28
29
        $filePaths = $input->getArgument('files');
30
31
        $files = $this->generateFiles($filePaths);
32
33
        $reporter = new ConsoleReporter($output);
34
        $analyzerFactory = new AnalyzerFactory();
35
36
        $analyzer = $this->getAnalyzer($analyzerFactory, $configDto, $output, $reporter);
37
38
        return $this->analyze($analyzer, $files, $output);
39
    }
40
41
    protected function generateFiles(array $filePaths): Generator
42
    {
43
        foreach ($filePaths as $filePath) {
44
            yield new SplFileInfo($filePath);
45
        }
46
    }
47
}
48