Completed
Pull Request — master (#4)
by Alessandro
15:15 queued 12:50
created

DropDatabaseCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
c 2
b 1
f 0
lcom 1
cbo 5
dl 0
loc 27
ccs 0
cts 16
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 10 1
A execute() 0 7 1
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
    /**
32
     * {@inheritdoc}
33
     */
34
    protected function execute(InputInterface $input, OutputInterface $output)
35
    {
36
        $databaseName = $input->getArgument('database');
37
38
        $this->client->dropDatabase($databaseName);
39
        $this->io->writeln(sprintf('Database %s dropped', $databaseName));
40
    }
41
}
42