Completed
Pull Request — master (#75)
by
unknown
02:24
created

AdminCommand   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 4
dl 0
loc 82
ccs 0
cts 31
cp 0
rs 10
c 0
b 0
f 0

6 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
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
     * @inheritdoc
45
     */
46
    protected function configure()
47
    {
48
        parent::configure();
49
50
    }
51
52
    /**
53
     * @inheritdoc
54
     */
55
    public function getDescription()
56
    {
57
        return $this->description;
58
    }
59
60
    /**
61
     * @inheritdoc
62
     */
63
    public function execute($login, InputInterface $input)
64
    {
65
        $nickName = $this->playerStorage->getPlayerInfo($login)->getNickName();
66
        $group = $this->getGroupLabel($login);
67
68
        $this->chatNotification->sendMessage(
69
            $this->chatMessage,
70
            $this->isPublic ? null : $login,
71
            ['%adminLevel%' => $group, '%admin%' => $nickName]
72
        );
73
74
        $this->connection->{$this->functionName}();
75
    }
76
77
    /**
78
     * @param string $description
79
     */
80
    public function setDescription($description)
81
    {
82
        $this->description = $description;
83
    }
84
85
    /**
86
     * @param string $chatMessage
87
     */
88
    public function setChatMessage($chatMessage)
89
    {
90
        $this->chatMessage = $chatMessage;
91
    }
92
93
    /**
94
     * @param string $functionName
95
     */
96
    public function setFunctionName($functionName)
97
    {
98
        $this->functionName = $functionName;
99
    }
100
101
}
102