ReinstallCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 51
ccs 0
cts 32
cp 0
rs 10
c 1
b 0
f 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 6 1
B execute() 0 30 2
1
<?php
2
3
/**
4
 * This file is part of Packy.
5
 *
6
 * (c) Peter Nijssen
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace AppBundle\Command;
13
14
use Symfony\Component\Console\Command\Command;
15
use Symfony\Component\Console\Input\ArrayInput;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Output\OutputInterface;
18
use Symfony\Component\Console\Question\ConfirmationQuestion;
19
20
class ReinstallCommand extends Command
21
{
22
    /**
23
     * Configure the command.
24
     */
25
    protected function configure()
26
    {
27
        $this
28
            ->setName('packy:reinstall')
29
            ->setDescription('Reinstall packy');
30
    }
31
32
    /**
33
     * Execute the command.
34
     *
35
     * @param InputInterface  $input
36
     * @param OutputInterface $output
37
     *
38
     * @throws \Exception
39
     */
40
    protected function execute(InputInterface $input, OutputInterface $output)
41
    {
42
        $helper = $this->getHelper('question');
43
        $question = new ConfirmationQuestion(
44
            'Do you really want to reinstall packy? All data will be lost. (y/n) ',
45
            false
46
        );
47
48
        if (!$helper->ask($input, $output, $question)) {
49
            return;
50
        }
51
52
        $command = $this->getApplication()->find('doctrine:database:drop');
53
        $arguments = [
54
            'command' => 'doctrine:database:drop',
55
            '--force' => true,
56
            '--quiet' => true,
57
        ];
58
59
        $input = new ArrayInput($arguments);
60
        $input->setInteractive(false);
61
        $command->run($input, $output);
62
63
        $installCommand = $this->getApplication()->find('packy:install');
64
        $arguments = [
65
            'command' => 'packy:install',
66
        ];
67
        $installInput = new ArrayInput($arguments);
68
        $installCommand->run($installInput, $output);
69
    }
70
}
71