Completed
Pull Request — master (#8)
by Antonio Oertel
04:37 queued 01:48
created

Generate::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 2
crap 6
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('path', InputArgument::REQUIRED);
32
    }
33
34
    protected function execute(InputInterface $input, OutputInterface $output)
35
    {
36
        $this->stateReader->read();
37
38
        $output->writeln('Start writing files.');
39
40
        foreach ($this->stateReader as $state) {
41
            $output->write($state->getClassName() . ' ... ');
42
43
            $this->writer->write($input->getArgument('path'), $state);
44
45
            $output->writeln('done!');
46
        }
47
    }
48
}
49