Command   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 127
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 15
lcom 2
cbo 1
dl 0
loc 127
ccs 38
cts 38
cp 1
rs 10
c 0
b 0
f 0

13 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getKey() 0 4 1
A setKey() 0 4 1
A getPlugin() 0 4 1
A setPlugin() 0 4 1
A getDescription() 0 4 1
A setDescription() 0 4 1
A getAction() 0 8 2
A setAction() 0 4 1
A getClass() 0 9 2
A setClass() 0 4 1
A getKeywords() 0 4 1
A setKeywords() 0 4 1
1
<?php
2
3
namespace Botonomous;
4
5
/**
6
 * Class Command.
7
 */
8
class Command extends AbstractBaseSlack
9
{
10
    const DEFAULT_ACTION = 'index';
11
    const PLUGIN_DIR = 'plugin';
12
13
    private $key;
14
    private $plugin;
15
    private $description;
16
    private $action;
17
    private $class;
18
    private $keywords;
19
20
    /**
21
     * Command constructor.
22
     *
23
     * @param $key
24
     */
25 16
    public function __construct($key)
26
    {
27 16
        $this->setKey($key);
28 16
    }
29
30
    /**
31
     * @return string
32
     */
33 1
    public function getKey(): string
34
    {
35 1
        return $this->key;
36
    }
37
38
    /**
39
     * @param string $key
40
     */
41 16
    public function setKey(string $key)
42
    {
43 16
        $this->key = $key;
44 16
    }
45
46
    /**
47
     * @return string
48
     */
49 7
    public function getPlugin(): string
50
    {
51 7
        return $this->plugin;
52
    }
53
54
    /**
55
     * @param string $plugin
56
     */
57 13
    public function setPlugin(string $plugin)
58
    {
59 13
        $this->plugin = $plugin;
60 13
    }
61
62
    /**
63
     * @return string
64
     */
65 1
    public function getDescription(): string
66
    {
67 1
        return $this->description;
68
    }
69
70
    /**
71
     * @param string $description
72
     */
73 13
    public function setDescription(string $description)
74
    {
75 13
        $this->description = $description;
76 13
    }
77
78
    /**
79
     * @return string
80
     */
81 5
    public function getAction(): string
82
    {
83 5
        if (empty($this->action)) {
84 4
            $this->setAction(self::DEFAULT_ACTION);
85
        }
86
87 5
        return $this->action;
88
    }
89
90
    /**
91
     * @param string $action
92
     */
93 12
    public function setAction(string $action)
94
    {
95 12
        $this->action = $action;
96 12
    }
97
98
    /**
99
     * @return string
100
     */
101 3
    public function getClass(): string
102
    {
103 3
        if (empty($this->class)) {
104 3
            $class = __NAMESPACE__.'\\'.self::PLUGIN_DIR.'\\'.strtolower($this->getPlugin()).'\\'.$this->getPlugin();
105 3
            $this->setClass($class);
106
        }
107
108 3
        return $this->class;
109
    }
110
111
    /**
112
     * @param string $class
113
     */
114 3
    public function setClass(string $class)
115
    {
116 3
        $this->class = $class;
117 3
    }
118
119
    /**
120
     * @return array
121
     */
122 5
    public function getKeywords()
123
    {
124 5
        return $this->keywords;
125
    }
126
127
    /**
128
     * @param array $keywords
129
     */
130 8
    public function setKeywords(array $keywords)
131
    {
132 8
        $this->keywords = $keywords;
133 8
    }
134
}
135