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

CreateDatabases::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 2
crap 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