Completed
Push — master ( 1c87cd...c75e6a )
by Alejandro
03:14
created

DumpTypeClassesCommand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 39
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A configure() 0 6 1
A execute() 0 13 3
1
<?php
2
namespace Acelaya\Doctrine\Console;
3
4
use Acelaya\Doctrine\Exception\InvalidArgumentException;
5
use Acelaya\Doctrine\Registrator\EnumTypeRegistratorInterface;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
class DumpTypeClassesCommand extends Command
11
{
12
    /**
13
     * @var EnumTypeRegistratorInterface
14
     */
15
    private $registrator;
16
    /**
17
     * @var array
18
     */
19
    private $enums;
20
21 4
    public function __construct(EnumTypeRegistratorInterface $registrator, array $enums)
22
    {
23 4
        parent::__construct();
24 4
        $this->registrator = $registrator;
25 4
        $this->enums = $enums;
26 4
    }
27
28 4
    protected function configure()
29
    {
30 4
        $this
31 4
            ->setName('det:dump-type-files')
32 4
            ->setDescription('Generates the doctrine type class files for every configured enum');
33 4
    }
34
35 3
    protected function execute(InputInterface $input, OutputInterface $output)
36
    {
37 3
        $output->write('Generating enum doctrine type files...');
38
        try {
39 3
            $this->registrator->registerEnumTypes($this->enums);
40 1
            $output->writeln(' <info>Success!</info>');
41 3
        } catch (InvalidArgumentException $e) {
42 2
            $output->writeln(' <error>Error!</error>');
43 2
            if ($output->isVerbose()) {
44 1
                $this->getApplication()->renderException($e, $output);
45 1
            }
46
        }
47 3
    }
48
}
49