Completed
Pull Request — master (#38)
by Jonathan
02:53
created

CreateDatabases   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 29
ccs 8
cts 12
cp 0.6667
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 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
    /**
20
     * @var EventDispatcher
21
     */
22
    private $eventDispatcher;
23
24 1
    public function __construct(EventDispatcher $eventDispatcher)
25
    {
26 1
        $this->eventDispatcher = $eventDispatcher;
27 1
    }
28
29
    public function configure(Command $command)
30
    {
31
        $command
32
            ->setDescription('Create the test databases.')
33
            ->addOption('sandbox', null, InputOption::VALUE_NONE, 'Prepare sandbox before creating databases.')
34
        ;
35
    }
36
37 1
    public function execute(InputInterface $input, OutputInterface $output)
38
    {
39 1
        $this->eventDispatcher->dispatch(Events::DATABASES_CREATE);
40
41 1
        if (!$input->getOption('quiet')) {
42 1
            $output->writeln('Done creating databases!');
43
        }
44 1
    }
45
}
46