Completed
Pull Request — master (#4)
by Alessandro
05:13
created

DropDatabaseCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 0
cts 10
cp 0
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Facile\MongoDbBundle\Commands;
6
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Input\InputOption;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
/**
13
 * Class DropDatabaseCommand.
14
 */
15
class DropDatabaseCommand extends AbstractClientCommand
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    protected function configure()
21
    {
22
        parent::configure();
23
        $this
24
            ->setName('mongodb:database:drop')
25
            ->setDescription('Drops a database')
26
            ->addArgument('database', InputArgument::REQUIRED, 'The database to drop')
27
            ->addOption('if-exists', null, InputOption::VALUE_NONE, 'Don\'t trigger an error, when the database do not exists')
28
        ;
29
    }
30
    /**
31
     * {@inheritdoc}
32
     */
33
    protected function execute(InputInterface $input, OutputInterface $output)
34
    {
35
        $databaseName = $input->getArgument('database');
36
37
        $this->client->dropDatabase($databaseName);
38
        $this->io->writeln(sprintf('Database %s dropped', $databaseName));
39
    }
40
}
41