Passed
Push — master ( dc1dd1...6a10bf )
by Valery
09:48
created

InstallCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Command;
6
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\ArrayInput;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
final class InstallCommand extends Command
13
{
14
    protected static $defaultName = 'app:install';
15
16
    protected function configure()
17
    {
18
        $this->setDescription('Install the application');
19
    }
20
21
    protected function execute(InputInterface $input, OutputInterface $output): int
22
    {
23
        foreach ($this->getCommands() as $c) {
24
            $input = new ArrayInput($c['arguments']);
25
            $input->setInteractive(false);
26
            $this->getApplication()
27
                ->find($c['command'])
28
                ->run($input, $output);
29
        }
30
31
        return Command::SUCCESS;
32
    }
33
34
    private function getCommands(): array
35
    {
36
        return [
37
            [
38
                'command' => 'doctrine:database:create',
39
                'arguments' => [
40
                    '--if-not-exists' => true,
41
                ],
42
            ],
43
            [
44
                'command' => 'doctrine:migrations:migrate',
45
                'arguments' => [],
46
            ],
47
            [
48
                'command' => 'doctrine:fixtures:load',
49
                'arguments' => [],
50
            ],
51
        ];
52
    }
53
}
54