Test Failed
Push — main ( 645eda...aff472 )
by mikhail
03:07
created

Command::getFilesFromDirectories()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 2
b 0
f 0
nc 3
nop 1
dl 0
loc 10
rs 10
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\CommentDensity;
10
use SavinMikhail\CommentsDensity\ConfigLoader;
0 ignored issues
show
Bug introduced by
The type SavinMikhail\CommentsDensity\ConfigLoader 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...
11
use SavinMikhail\CommentsDensity\DTO\Input\ConfigDTO;
0 ignored issues
show
Bug introduced by
The type SavinMikhail\CommentsDensity\DTO\Input\ConfigDTO 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...
12
use SavinMikhail\CommentsDensity\Reporters\ReporterInterface;
13
use Symfony\Component\Console\Command\Command as SymfonyCommand;
14
use Symfony\Component\Console\Output\OutputInterface;
15
16
abstract class Command extends SymfonyCommand
17
{
18
    protected function getConfigDto(): ConfigDTO
19
    {
20
        $configLoader = new ConfigLoader();
21
        return $configLoader->getConfigDto();
22
    }
23
24
    protected function analyze(CommentDensity $analyzer, Generator $files, OutputInterface $output): int
25
    {
26
        $limitExceeded = $analyzer->analyze($files);
27
28
        if ($limitExceeded) {
29
            $output->writeln('<error>Comment thresholds were exceeded!</error>');
30
            return SymfonyCommand::FAILURE;
31
        }
32
        $output->writeln('<info>Comment thresholds are passed!</info>');
33
        return SymfonyCommand::SUCCESS;
34
    }
35
36
    protected function getAnalyzer(
37
        AnalyzerFactory $factory,
38
        ConfigDTO $configDto,
39
        OutputInterface $output,
40
        ReporterInterface $reporter
41
    ): CommentDensity {
42
        return $factory->getAnalyzer($configDto, $output, $reporter);
43
    }
44
}
45