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

Generate   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 5
dl 0
loc 39
ccs 0
cts 16
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 4 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('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