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

AdminCommand::execute()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 11
cp 0
cc 2
eloc 8
nc 1
nop 2
crap 6
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