Completed
Push — dev ( ade326...e1b211 )
by
unknown
03:23
created

ReasonUserCommand   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 121
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 7

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 2
cbo 7
dl 0
loc 121
ccs 36
cts 36
cp 1
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 0 4 1
A configure() 0 11 1
A execute() 0 17 2
A setParameterLoginDescription() 0 4 1
A setParameterReasonDescription() 0 4 1
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    de Cramer Oliver<[email protected]>
18
 * @copyright 2017 Smile
19
 * @package eXpansion\Bundle\AdminChat\ChatCommand
20
 */
21
class ReasonUserCommand extends AbstractConnectionCommand
22
{
23
    /**
24
     * Description of the login parameter
25
     *
26
     * @var string
27
     */
28
    protected $parameterLoginDescription;
29
30
    /**
31
     * Description of the reason parameter.
32
     *
33
     * @var string
34
     */
35
    protected $parameterReasonDescription;
36
37
    /**
38
     * Description of the command.
39
     *
40
     * @var string
41
     */
42
    protected $description;
43
44
    /**
45
     * Message to display in chat.
46
     *
47
     * @var string
48
     */
49
    protected $chatMessage;
50
51
    /**
52
     * Name of the dedicated function to call.
53
     *
54
     * @var string
55
     */
56
    protected $functionName;
57
58
    /**
59
     * @inheritdoc
60
     */
61 2
    protected function configure()
62
    {
63 2
        parent::configure();
64
65 2
        $this->inputDefinition->addArgument(
66 2
            new InputArgument('login', InputArgument::REQUIRED, $this->parameterLoginDescription)
67
        );
68 2
        $this->inputDefinition->addArgument(
69 2
            new InputArgument('reason', InputArgument::REQUIRED, $this->parameterReasonDescription)
70
        );
71 2
    }
72
73
    /**
74
     * @inheritdoc
75
     */
76 1
    public function getDescription()
77
    {
78 1
        return $this->description;
79
    }
80
81
    /**
82
     * @inheritdoc
83
     */
84 1
    public function execute($login, InputInterface $input)
85
    {
86 1
        $nickName = $this->playerStorage->getPlayerInfo($login)->getNickName();
87 1
        $playerLogin = $input->getArgument('login');
88 1
        $reason = $input->getArgument('reason');
89 1
        $group = $this->getGroupLabel($login);
90
91 1
        $playerNickName = $this->playerStorage->getPlayerInfo($playerLogin)->getNickName();
92
93 1
        $this->chatNotification->sendMessage(
94 1
            $this->chatMessage,
95 1
            $this->isPublic ? null : $login,
96 1
            ['%adminLevel%' => $group, '%admin%' => $nickName, '%player%' => $playerNickName, "%reason%" => $reason]
97
        );
98
99 1
        $this->connection->{$this->functionName}($playerLogin, $reason);
100 1
    }
101
102
    /**
103
     * @param string $parameterLoginDescription
104
     */
105 2
    public function setParameterLoginDescription($parameterLoginDescription)
106
    {
107 2
        $this->parameterLoginDescription = $parameterLoginDescription;
108 2
    }
109
110
    /**
111
     * @param string $parameterReasonDescription
112
     */
113 2
    public function setParameterReasonDescription($parameterReasonDescription)
114
    {
115 2
        $this->parameterReasonDescription = $parameterReasonDescription;
116 2
    }
117
118
    /**
119
     * @param string $description
120
     */
121 2
    public function setDescription($description)
122
    {
123 2
        $this->description = $description;
124 2
    }
125
126
    /**
127
     * @param string $chatMessage
128
     */
129 2
    public function setChatMessage($chatMessage)
130
    {
131 2
        $this->chatMessage = $chatMessage;
132 2
    }
133
134
    /**
135
     * @param string $functionName
136
     */
137 2
    public function setFunctionName($functionName)
138
    {
139 2
        $this->functionName = $functionName;
140 2
    }
141
}
142