Passed
Push — master ( b915a1...d7da76 )
by Fabien
02:15
created

AssessComplexityCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 8
dl 0
loc 25
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 5 1
A execute() 0 6 1
1
<?php declare(strict_types = 1);
2
3
namespace Churn\Command;
4
5
use Churn\Assessors\CyclomaticComplexity\CyclomaticComplexityAssessor;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
class AssessComplexityCommand extends Command
12
{
13
    /**
14
     * Configure the command
15
     * @return void
16
     */
17
    protected function configure(): void
18
    {
19
        $this->setName('assess-complexity')
20
            ->addArgument('file', InputArgument::REQUIRED, 'Path to file to analyze.')
21
            ->setDescription('Calculate the Cyclomatic Complexity');
22
    }
23
24
    /**
25
     * Execute the command
26
     * @param InputInterface  $input  Input.
27
     * @param OutputInterface $output Output.
28
     * @return integer
29
     */
30
    protected function execute(InputInterface $input, OutputInterface $output): int
31
    {
32
        $file = $input->getArgument('file');
33
        $assessor = new CyclomaticComplexityAssessor();
34
        $output->writeln($assessor->assess($file));
0 ignored issues
show
Bug introduced by
It seems like $file can also be of type null and string[]; however, parameter $filePath of Churn\Assessors\Cyclomat...exityAssessor::assess() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

34
        $output->writeln($assessor->assess(/** @scrutinizer ignore-type */ $file));
Loading history...
35
        return 0;
36
    }
37
}
38