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

AssessComplexityCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 6
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 2
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