ExecuteCommand::getInputCommand()   A
last analyzed

Complexity

Conditions 4
Paths 5

Size

Total Lines 17
Code Lines 11

Duplication

Lines 17
Ratio 100 %

Importance

Changes 0
Metric Value
dl 17
loc 17
rs 9.2
c 0
b 0
f 0
cc 4
eloc 11
nc 5
nop 1
1
<?php
2
/**
3
 * Reddogs (https://github.com/reddogs-at)
4
 *
5
 * @see https://github.com/reddogs-at/reddogs-doctrine-migrations for the canonical source repository
6
 * @license https://github.com/reddogs-at/reddogs-doctrine-migrations/blob/master/LICENSE MIT License
7
 */
8
namespace Reddogs\Doctrine\Migrations;
9
10
use Reddogs\Doctrine\Migrations\AbstractCommand;
11
use ZF\Console\Route;
12
13
/**
14
 * Command for executing single module migrations up or down manually.
15
 */
16 View Code Duplication
class ExecuteCommand extends AbstractCommand
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...
17
{
18
19
    /**
20
     * Boolean rout params
21
     *
22
     * @var array
23
     */
24
    protected $booleanParams = [
25
        '--dry-run',
26
        '--write-sql',
27
        '--up',
28
        '--down',
29
        '--query-time',
30
        '--no-interaction',
31
        '-n',
32
        '--quiet',
33
        '-q',
34
        '--verbose',
35
        '-v',
36
        '-vv',
37
        '-vvv'
38
    ];
39
40
    /**
41
     * Get input command
42
     *
43
     * {@inheritdoc}
44
     *
45
     * @see \Reddogs\Doctrine\Migrations\AbstractCommand::getInputCommand()
46
     */
47
    public function getInputCommand(Route $route)
48
    {
49
        $matches = $route->getMatches();
50
        $inputCommand = 'migrations:execute';
51
52
        if (is_array($matches)) {
53
            $params = [];
54
            $params = $this->applyBooleanParams($params, $matches);
55
            if (isset($matches['version'])) {
56
                $params[] = $matches['version'];
57
            }
58
            if (! empty($params)) {
59
                $inputCommand .= ' ' . implode(' ', $params);
60
            }
61
        }
62
        return $inputCommand;
63
    }
64
}