Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
DbResetCommand
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 3
42
0.00% covered (danger)
0.00%
0 / 1
 getAllowedAppEnvs
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 configure
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
2
 handle
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
20
1<?php
2
3namespace Olz\Command;
4
5use Olz\Command\Common\OlzCommand;
6use Symfony\Component\Console\Attribute\AsCommand;
7use Symfony\Component\Console\Command\Command;
8use Symfony\Component\Console\Input\InputArgument;
9use Symfony\Component\Console\Input\InputInterface;
10use Symfony\Component\Console\Output\OutputInterface;
11
12#[AsCommand(name: 'olz:db-reset')]
13class 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}