Completed
Pull Request — master (#94)
by
unknown
02:15
created

AdminCommand   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 98
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 4
dl 0
loc 98
ccs 27
cts 27
cp 1
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 5 1
A getDescription() 0 4 1
A execute() 0 13 2
A setDescription() 0 4 1
A setChatMessage() 0 4 1
A setFunctionName() 0 4 1
A getFunctionName() 0 4 1
A getChatMessage() 0 4 1
1
<?php
2
3
namespace eXpansion\Bundle\AdminChat\ChatCommand;
4
5
use eXpansion\Framework\AdminGroups\Helpers\AdminGroups;
6
use eXpansion\Framework\Core\Helpers\ChatNotification;
7
use eXpansion\Framework\Core\Storage\PlayerStorage;
8
use Maniaplanet\DedicatedServer\Connection;
9
use Monolog\Logger;
10
use Psr\Log\LoggerInterface;
11
use Symfony\Component\Console\Input\InputArgument;
12
use Symfony\Component\Console\Input\InputInterface;
13
14
/**
15
 * Class ReasonUserCommand
16
 *
17
 * @author  Reaby
18
 * @package eXpansion\Bundle\AdminChat\ChatCommand
19
 */
20
class AdminCommand extends AbstractConnectionCommand
21
{
22
    /**
23
     * Description of the command.
24
     *
25
     * @var string
26
     */
27
    protected $description;
28
29
    /**
30
     * Message to display in chat.
31
     *
32
     * @var string
33
     */
34
    protected $chatMessage;
35
36
    /**
37
     * Name of the dedicated function to call.
38
     *
39
     * @var string
40
     */
41
    protected $functionName;
42
43
    /**
44
     * @return string
45
     */
46 2
    public function getFunctionName()
47
    {
48 2
        return $this->functionName;
49
    }
50
51
    /**
52
     * @return string
53
     */
54 2
    public function getChatMessage()
55
    {
56 2
        return $this->chatMessage;
57
    }
58
59
    /**
60
     * @inheritdoc
61
     */
62 10
    protected function configure()
63
    {
64 10
        parent::configure();
65
66 10
    }
67
68
    /**
69
     * @inheritdoc
70
     */
71 2
    public function getDescription()
72
    {
73 2
        return $this->description;
74
    }
75
76
    /**
77
     * @inheritdoc
78
     */
79 1
    public function execute($login, InputInterface $input)
80
    {
81 1
        $nickName = $this->playerStorage->getPlayerInfo($login)->getNickName();
82 1
        $group = $this->getGroupLabel($login);
83
84 1
        $this->chatNotification->sendMessage(
85 1
            $this->chatMessage,
86 1
            $this->isPublic ? null : $login,
87 1
            ['%adminLevel%' => $group, '%admin%' => $nickName]
88
        );
89
90 1
        $this->connection->{$this->functionName}();
91 1
    }
92
93
    /**
94
     * @param string $description
95
     */
96 10
    public function setDescription($description)
97
    {
98 10
        $this->description = $description;
99 10
    }
100
101
    /**
102
     * @param string $chatMessage
103
     */
104 10
    public function setChatMessage($chatMessage)
105
    {
106 10
        $this->chatMessage = $chatMessage;
107 10
    }
108
109
    /**
110
     * @param string $functionName
111
     */
112 10
    public function setFunctionName($functionName)
113
    {
114 10
        $this->functionName = $functionName;
115 10
    }
116
117
}
118