Completed
Push — master ( 80d94b...95c442 )
by Jonathan
31s
created

CreateDatabases   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 57.14%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 4
dl 0
loc 36
ccs 8
cts 14
cp 0.5714
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getName() 0 4 1
A configure() 0 7 1
A execute() 0 8 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace PHPChunkit\Command;
6
7
use PHPChunkit\Events;
8
use Symfony\Component\Console\Command\Command;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Input\InputOption;
11
use Symfony\Component\Console\Output\OutputInterface;
12
use Symfony\Component\EventDispatcher\EventDispatcher;
13
14
/**
15
 * @testClass PHPChunkit\Test\Command\CreateDatabasesTest
16
 */
17
class CreateDatabases implements CommandInterface
18
{
19
    const NAME = 'create-dbs';
20
21
    /**
22
     * @var EventDispatcher
23
     */
24
    private $eventDispatcher;
25
26 1
    public function __construct(EventDispatcher $eventDispatcher)
27
    {
28 1
        $this->eventDispatcher = $eventDispatcher;
29 1
    }
30
31
    public function getName() : string
32
    {
33
        return self::NAME;
34
    }
35
36
    public function configure(Command $command)
37
    {
38
        $command
39
            ->setDescription('Create the test databases.')
40
            ->addOption('sandbox', null, InputOption::VALUE_NONE, 'Prepare sandbox before creating databases.')
41
        ;
42
    }
43
44 1
    public function execute(InputInterface $input, OutputInterface $output)
45
    {
46 1
        $this->eventDispatcher->dispatch(Events::DATABASES_CREATE);
47
48 1
        if (!$input->getOption('quiet')) {
49 1
            $output->writeln('Done creating databases!');
50
        }
51 1
    }
52
}
53