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

OneParameterCommand::setFunctionName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 4
cp 0
cc 1
eloc 2
nc 1
nop 1
crap 2
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
     * @inheritdoc
52
     */
53
    protected function configure()
54
    {
55
        parent::configure();
56
57
        $this->inputDefinition->addArgument(
58
            new InputArgument('parameter', InputArgument::REQUIRED, $this->parameterDescription)
59
        );
60
    }
61
62
    /**
63
     * @inheritdoc
64
     */
65
    public function getDescription()
66
    {
67
        return $this->description;
68
    }
69
70
    /**
71
     * @inheritdoc
72
     */
73 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...
74
    {
75
        $nickName = $this->playerStorage->getPlayerInfo($login)->getNickName();
76
        $parameter = $input->getArgument('parameter');
77
        $group = $this->getGroupLabel($login);
78
79
        $this->chatNotification->sendMessage(
80
            $this->chatMessage,
81
            $this->isPublic ? null : $login,
82
            ['%adminLevel%' => $group, '%admin%' => $nickName, "%parameter%" => $parameter]
83
        );
84
85
        $this->connection->{$this->functionName}($parameter);
86
    }
87
88
    /**
89
     * @param string $parameterDescription
90
     */
91
    public function setParameterDescription($parameterDescription)
92
    {
93
        $this->parameterDescription = $parameterDescription;
94
    }
95
96
    /**
97
     * @param string $description
98
     */
99
    public function setDescription($description)
100
    {
101
        $this->description = $description;
102
    }
103
104
    /**
105
     * @param string $chatMessage
106
     */
107
    public function setChatMessage($chatMessage)
108
    {
109
        $this->chatMessage = $chatMessage;
110
    }
111
112
    /**
113
     * @param string $functionName
114
     */
115
    public function setFunctionName($functionName)
116
    {
117
        $this->functionName = $functionName;
118
    }
119
}
120