Completed
Pull Request — master (#37)
by De Cramer
08:24
created

AbstractChatCommand   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getCommand() 0 4 1
A getAliases() 0 4 1
A validate() 0 4 1
A parseParameters() 0 7 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: olive
5
 * Date: 01/04/2017
6
 * Time: 10:44
7
 */
8
9
namespace eXpansion\Core\Model\ChatCommand;
10
11
12
/**
13
 * Class AbstractChatCommand
14
 *
15
 * @package eXpansion\Core\Model\ChatCommand;
16
 * @author oliver de Cramer <[email protected]>
17
 */
18
abstract class AbstractChatCommand implements ChatCommandInterface
19
{
20
    protected $command;
21
22
    protected $aliases = [];
23
24
    protected $parametersAsArray = true;
25
26
    /**
27
     * AbstractChatCommand constructor.
28
     *
29
     * @param $command
30
     * @param array $aliases
31
     * @param bool $parametersAsArray
32
     */
33 2
    public function __construct($command, array $aliases = [], $parametersAsArray = true)
34
    {
35 2
        $this->command = $command;
36 2
        $this->aliases = $aliases;
37 2
        $this->parametersAsArray = $parametersAsArray;
38 2
    }
39
40
    /**
41
     * @inheritdoc
42
     */
43 1
    public function getCommand()
44
    {
45 1
        return $this->command;
46
    }
47
48
    /**
49
     * @inheritdoc
50
     */
51 1
    public function getAliases()
52
    {
53 1
        return $this->aliases;
54
    }
55
56
    /**
57
     * @inheritdoc
58
     */
59 1
    public function validate($login, $parameter)
60
    {
61 1
        return true;
62
    }
63
64
    /**
65
     * @inheritdoc
66
     */
67 1
    public function parseParameters($parameter) {
68 1
        if ($this->parametersAsArray) {
69 1
            return explode(' ', $parameter);
70
        } else {
71 1
            return $parameter;
72
        }
73
    }
74
}