Command   A
last analyzed

Coupling/Cohesion

Components 1
Dependencies 1

Complexity

Total Complexity 6

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 73
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 4 1
A all() 0 4 1
A get() 0 8 2
A set() 0 6 2
1
<?php
2
3
namespace League\CLImate\Decorator\Component;
4
5
class Command extends BaseDecorator
6
{
7
    /**
8
     * Commands that correspond to a color in the $colors property
9
     *
10
     * @var array
11
     */
12
    public $commands = [];
13
14
    /**
15
     * The default commands available
16
     *
17
     * @var array $defaults
18
     */
19
    protected $defaults = [
20
            'info'    => 'green',
21
            'comment' => 'yellow',
22
            'whisper' => 'light_gray',
23
            'shout'   => 'red',
24
            'error'   => 'light_red',
25
        ];
26
27
    /**
28
     * Add a command into the mix
29
     *
30
     * @param string $key
31
     * @param mixed  $value
32
     */
33 948
    public function add($key, $value)
34
    {
35 948
        $this->commands[$key] = $value;
36 948
    }
37
38
    /**
39
     * Retrieve all of the available commands
40
     *
41
     * @return array
42
     */
43 580
    public function all()
44
    {
45 580
        return $this->commands;
46
    }
47
48
    /**
49
     * Get the style that corresponds to the command
50
     *
51
     * @param  string  $val
52
     *
53
     * @return string
54
     */
55 32
    public function get($val)
56
    {
57 32
        if (array_key_exists($val, $this->commands)) {
58 24
            return $this->commands[$val];
59
        }
60
61 8
        return null;
62
    }
63
64
    /**
65
     * Set the currently used command
66
     *
67
     * @param  string       $val
68
     *
69
     * @return string|false
70
     */
71 24
    public function set($val)
72
    {
73
        // Return the code because it is a string corresponding
74
        // to a property in another class
75 24
        return ($code = $this->get($val)) ? $code : false;
76
    }
77
}
78