Completed
Push — dev ( 007c56...e65940 )
by
unknown
04:40
created

AdminReturnCommand   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 84
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 5
dl 84
loc 84
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 5 5 1
A getDescription() 4 4 1
A execute() 15 15 2
A setDescription() 4 4 1
A setChatMessage() 4 4 1
A setFunctionName() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 View Code Duplication
class AdminReturnCommand extends AbstractConnectionCommand
0 ignored issues
show
Duplication introduced by
This class 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...
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->adminGroupsHelper->getLoginUserGroups($login)->getName();
67
68
        $return = $this->connection->{$this->functionName}();
69
70
        $this->chatNotification->sendMessage(
71
            $this->chatMessage,
72
            $this->isPublic ? null : $login,
73
            ['%adminLevel%' => $group, '%admin%' => $nickName, '%return%' => $return]
74
        );
75
76
77
    }
78
79
    /**
80
     * @param string $description
81
     */
82
    public function setDescription($description)
83
    {
84
        $this->description = $description;
85
    }
86
87
    /**
88
     * @param string $chatMessage
89
     */
90
    public function setChatMessage($chatMessage)
91
    {
92
        $this->chatMessage = $chatMessage;
93
    }
94
95
    /**
96
     * @param string $functionName
97
     */
98
    public function setFunctionName($functionName)
99
    {
100
        $this->functionName = $functionName;
101
    }
102
103
}
104