Generate   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 6
dl 0
loc 46
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A configure() 0 11 1
A execute() 0 14 2
1
<?php
2
3
namespace Brazanation\States\Console\Commands;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
class Generate extends Command
11
{
12
    /**
13
     * @var Generate\ReaderDataset
14
     */
15
    private $stateReader;
16
17
    /**
18
     * @var Generate\ClassFileWriter
19
     */
20
    private $writer;
21
22
    public function __construct()
23
    {
24
        parent::__construct('states:generate');
25
        $this->stateReader = new Generate\ReaderDataset(null);
26
        $this->writer = new Generate\ClassFileWriter();
27
    }
28
29
    protected function configure()
30
    {
31
        $this->addArgument(
32
            new InputArgument(
0 ignored issues
show
Documentation introduced by
new \Symfony\Component\C...es', __DIR__ . './src') is of type object<Symfony\Component...le\Input\InputArgument>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
33
                'path',
34
                InputArgument::REQUIRED,
35
                'Directory to create states classes',
36
                __DIR__ . './src'
37
            )
38
        );
39
    }
40
41
    protected function execute(InputInterface $input, OutputInterface $output)
42
    {
43
        $this->stateReader->read();
44
45
        $output->writeln('Start writing files.');
46
47
        foreach ($this->stateReader as $state) {
48
            $output->write($state->getClassName() . ' ... ');
49
50
            $this->writer->write($input->getArgument('path'), $state);
51
52
            $output->writeln('done!');
53
        }
54
    }
55
}
56