SchemaDropCommand::getOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 6
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 6
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php namespace Nord\Lumen\Doctrine\ORM\Console;
2
3
use Symfony\Component\Console\Input\InputOption;
4
5 View Code Duplication
class SchemaDropCommand extends DoctrineSchemaCommand
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
6
{
7
8
    /**
9
     * @var string
10
     */
11
    protected $name = 'doctrine:schema:drop';
12
13
    /**
14
     * @var string
15
     */
16
    protected $description = 'Drop database schema';
17
18
19
    /**
20
     * @inheritdoc
21
     * @throws \Doctrine\ORM\Tools\ToolsException
22
     */
23
    public function fire()
24
    {
25
        $tool     = $this->getSchemaTool();
26
        $metadata = $this->getEntityManager()->getMetadataFactory()->getAllMetadata();
27
28
        $sql = $tool->getDropSchemaSQL($metadata);
29
30
        if (count($sql) === 0) {
31
            $this->info('Nothing to drop!');
32
33
            return;
34
        }
35
36
        $this->info('Dropping database schema ...');
37
38
        $tool->dropSchema($metadata);
39
40
        if ($this->option('sql')) {
41
            $this->info(implode(';' . PHP_EOL, $sql));
42
        }
43
44
        $this->info('Schema dropped!');
45
    }
46
47
48
    /**
49
     * @return array
50
     */
51
    protected function getOptions()
52
    {
53
        return [
54
            ['sql', false, InputOption::VALUE_NONE, 'Dumps SQL queries.'],
55
        ];
56
    }
57
}
58