CheckTypes   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 26
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 10 1
A execute() 0 12 2
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