ExecuteCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 49
loc 49
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getInputCommand() 17 17 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
}