| Total Complexity | 5 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | #[AsCommand('prime:database:drop', 'Drops the database from the configuration')] |
||
| 13 | class DropDatabaseCommand extends DatabaseCommand |
||
| 14 | { |
||
| 15 | protected static $defaultName = 'prime:database:drop'; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * {@inheritdoc} |
||
| 19 | */ |
||
| 20 | protected function configure(): void |
||
| 21 | { |
||
| 22 | parent::configure(); |
||
| 23 | |||
| 24 | $this |
||
| 25 | ->setDescription('Drops the database from the configuration') |
||
| 26 | ->addOption('force', 'f', InputOption::VALUE_NONE, 'Force the database deletion.') |
||
| 27 | ; |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * {@inheritdoc} |
||
| 32 | */ |
||
| 33 | protected function interactWithDatabase(ConnectionInterface $connection, ?string $dbName): void |
||
| 34 | { |
||
| 35 | if ($this->io->option('force') || $this->io->confirm("Would you like to drop database <comment>$dbName</comment>?")) { |
||
| 36 | $connection->schema()->dropDatabase($dbName); |
||
|
|
|||
| 37 | |||
| 38 | $this->io->line('Database <comment>%s</comment> has been <info>dropped</info> for connection <comment>%s</comment>.', $dbName, $connection->getName()); |
||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * {@inheritdoc} |
||
| 44 | */ |
||
| 45 | protected function interactWithNoDatabase(ConnectionInterface $connection, ?string $dbName): void |
||
| 48 | } |
||
| 49 | } |
||
| 50 |