Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
17 / 17 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
DbResetCommand | |
100.00% |
17 / 17 |
|
100.00% |
3 / 3 |
6 | |
100.00% |
1 / 1 |
getAllowedAppEnvs | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
configure | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
handle | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
4 |
1 | <?php |
2 | |
3 | namespace Olz\Command; |
4 | |
5 | use Olz\Command\Common\OlzCommand; |
6 | use Symfony\Component\Console\Attribute\AsCommand; |
7 | use Symfony\Component\Console\Command\Command; |
8 | use Symfony\Component\Console\Input\InputArgument; |
9 | use Symfony\Component\Console\Input\InputInterface; |
10 | use Symfony\Component\Console\Output\OutputInterface; |
11 | |
12 | #[AsCommand(name: 'olz:db-reset')] |
13 | class DbResetCommand extends OlzCommand { |
14 | /** @return array<string> */ |
15 | protected function getAllowedAppEnvs(): array { |
16 | return ['dev', 'test', 'staging']; |
17 | } |
18 | |
19 | protected function configure(): void { |
20 | $this->addArgument( |
21 | 'mode', |
22 | InputArgument::REQUIRED, |
23 | 'Mode (`content`, `structure` or `full`)' |
24 | ); |
25 | } |
26 | |
27 | protected function handle(InputInterface $input, OutputInterface $output): int { |
28 | $mode = $input->getArgument('mode'); |
29 | if ($mode === 'content') { |
30 | $this->devDataUtils()->resetDbContent(); |
31 | } elseif ($mode === 'structure') { |
32 | $this->devDataUtils()->resetDbStructure(); |
33 | } elseif ($mode === 'full') { |
34 | $this->devDataUtils()->fullResetDb(); |
35 | } else { |
36 | $output->writeln("Invalid mode: {$mode}."); |
37 | return Command::INVALID; |
38 | } |
39 | $output->writeln("Database {$mode} reset successful."); |
40 | return Command::SUCCESS; |
41 | } |
42 | } |