SchemaUpdateCommand::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 SchemaUpdateCommand 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:update';
12
13
    /**
14
     * @var string
15
     */
16
    protected $description = 'Update database schema to match entities';
17
18
19
    /**
20
     * @inheritdoc
21
     */
22
    public function fire()
23
    {
24
        $tool     = $this->getSchemaTool();
25
        $metadata = $this->getEntityManager()->getMetadataFactory()->getAllMetadata();
26
27
        $sql = $tool->getUpdateSchemaSql($metadata);
28
29
        if (count($sql) === 0) {
30
            $this->info('Nothing to update!');
31
32
            return;
33
        }
34
35
        $this->info('Updating database schema ...');
36
37
        $tool->updateSchema($metadata);
38
39
        if ($this->option('sql')) {
40
            $this->info(implode(';' . PHP_EOL, $sql));
41
        }
42
43
        $this->info('Schema updated!');
44
    }
45
46
47
    /**
48
     * @return array
49
     */
50
    protected function getOptions()
51
    {
52
        return [
53
            ['sql', false, InputOption::VALUE_NONE, 'Dumps SQL queries.'],
54
        ];
55
    }
56
}
57