Completed
Pull Request — master (#104)
by
unknown
03:28
created

OneParameterCommand::setParameterDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 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 OneParameterCommand extends AbstractConnectionCommand
21
{
22
    /**
23
     * Description of the parameter
24
     *
25
     * @var string
26
     */
27
    protected $parameterDescription;
28
29
    /**
30
     * Description of the command.
31
     *
32
     * @var string
33
     */
34
    protected $description;
35
36
    /**
37
     * Message to display in chat.
38
     *
39
     * @var string
40
     */
41
    protected $chatMessage;
42
43
    /**
44
     * Name of the dedicated function to call.
45
     *
46
     * @var string
47
     */
48
    protected $functionName;
49
50
    /**
51
     * @return string
52
     */
53
    public function getParameterDescription()
54
    {
55
        return $this->parameterDescription;
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    public function getChatMessage()
62
    {
63
        return $this->chatMessage;
64
    }
65
66
    /**
67
     * @return string
68
     */
69
    public function getFunctionName()
70
    {
71
        return $this->functionName;
72
    }
73
74
    /**
75
     * @inheritdoc
76
     */
77 2
    protected function configure()
78
    {
79 2
        parent::configure();
80
81 2
        $this->inputDefinition->addArgument(
82 2
            new InputArgument('parameter', InputArgument::REQUIRED, $this->parameterDescription)
83
        );
84 2
    }
85
86
    /**
87
     * @inheritdoc
88
     */
89 1
    public function getDescription()
90
    {
91 1
        return $this->description;
92
    }
93
94
    /**
95
     * @inheritdoc
96
     */
97 1 View Code Duplication
    public function execute($login, InputInterface $input)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
98
    {
99 1
        $nickName = $this->playerStorage->getPlayerInfo($login)->getNickName();
100 1
        $parameter = $input->getArgument('parameter');
101 1
        $group = $this->getGroupLabel($login);
102
103 1
        $this->chatNotification->sendMessage(
104 1
            $this->chatMessage,
105 1
            $this->isPublic ? null : $login,
106 1
            ['%adminLevel%' => $group, '%admin%' => $nickName, "%parameter%" => $parameter]
107
        );
108
109 1
        $this->connection->{$this->functionName}($parameter);
110 1
    }
111
112
    /**
113
     * @param string $parameterDescription
114
     */
115 2
    public function setParameterDescription($parameterDescription)
116
    {
117 2
        $this->parameterDescription = $parameterDescription;
118 2
    }
119
120
    /**
121
     * @param string $description
122
     */
123 2
    public function setDescription($description)
124
    {
125 2
        $this->description = $description;
126 2
    }
127
128
    /**
129
     * @param string $chatMessage
130
     */
131 2
    public function setChatMessage($chatMessage)
132
    {
133 2
        $this->chatMessage = $chatMessage;
134 2
    }
135
136
    /**
137
     * @param string $functionName
138
     */
139 2
    public function setFunctionName($functionName)
140
    {
141 2
        $this->functionName = $functionName;
142 2
    }
143
}
144