CheckTypes::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Marcosh\PhpTypeChecker\Command;
6
7
use Marcosh\PhpTypeChecker\Checker;
8
use Symfony\Component\Console\Command\Command;
9
use Symfony\Component\Console\Input\InputArgument;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
final class CheckTypes extends Command
14
{
15
    protected function configure(): void
16
    {
17
        $this->setName('check');
18
        $this->setDescription('Check methods return types');
19
        $this->addArgument('path', InputArgument::OPTIONAL, 'The path to check', '.');
20
        $this->setHelp(
21
            'This command allows you to check if all the methods ' .
22
            'of your application have an explicit return type'
23
        );
24
    }
25
26
    protected function execute(InputInterface $input, OutputInterface $output): void
27
    {
28
        $path = $input->getArgument('path');
29
30
        $check = new Checker();
31
32
        foreach ($check($path) as $typeHint) {
33
            $output->writeln($typeHint->message());
34
        }
35
36
        $output->writeln('Done!');
37
    }
38
}
39