Completed
Pull Request — master (#4)
by Alessandro
03:48
created

DropCollectionCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Facile\MongoDbBundle\Command;
6
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
class DropCollectionCommand extends AbstractCommand
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 1
    protected function configure()
17
    {
18 1
        parent::configure();
19
        $this
20 1
            ->setName('mongodb:collection:drop')
21 1
            ->addArgument('collection', InputArgument::REQUIRED, 'collection to drop')
22 1
            ->setDescription('Drops a database');
23
        ;
24 1
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 1
    protected function execute(InputInterface $input, OutputInterface $output)
30
    {
31 1
        $collection = $input->getArgument('collection');
32
33 1
        $this->io->writeln(sprintf('Dropping collection %s', $collection));
34 1
        $this->connection->dropCollection($collection);
35 1
        $this->io->writeln('Collection dropped');
36
    }
37
}