AbstractCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 47
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
1
<?php
2
3
namespace Assimtech\Tempo\Command;
4
5
use Symfony\Component\Console\Command\Command;
6
use Assimtech\Tempo\Environment;
7
8
abstract class AbstractCommand extends Command
9
{
10
    /**
11
     * @var \Assimtech\Tempo\Environment $env
12
     */
13
    protected $env;
14
15
    /**
16
     * {@inheritdoc}
17
     *
18
     * @param \Assimtech\Tempo\Environment $env
19
     *
20
     * The environment name will be prefixed to the command name, e.g.
21
     *
22
     *      new MyCommand(
23
     *          new \Assimtech\Tempo\Environment('staging'),
24
     *          'deploy'
25
     *      );
26
     *
27
     * would result in a command:
28
     *
29
     *      tempo staging:deploy
30
     *
31
     * if $name is ommited, it will default to the class name of the command, e.g.
32
     *
33
     *      new MyCommand(
34
     *          new \Assimtech\Tempo\Environment('staging')
35
     *      );
36
     *
37
     * would result in a command:
38
     *
39
     *      tempo staging:mycommand
40
     *
41
     */
42 3
    public function __construct(Environment $env, $name = null)
43
    {
44 3
        $this->env = $env;
45
46 3
        if ($name === null) {
47 2
            $components = explode('\\', get_called_class());
48 2
            $class = array_pop($components);
49 2
            $name = strtolower($class);
50 2
        }
51
52 3
        parent::__construct(sprintf('%s:%s', $env, $name));
53 3
    }
54
}
55