Completed
Push — dev ( 04be10...0e3c94 )
by
unknown
11:22
created

Kick::getDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace eXpansion\Bundle\AdminChat\ChatCommand;
4
5
use Symfony\Component\Console\Input\InputArgument;
6
use Symfony\Component\Console\Input\InputInterface;
7
8
/**
9
 * Class Kick
10
 *
11
 * @package eXpansion\Bundle\AdminChat\ChatCommand;
12
 * @author reaby
13
 */
14 View Code Duplication
class Kick 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...
15
{
16
    /**
17
     * @inheritdoc
18
     */
19
    protected function configure()
20
    {
21
        parent::configure();
22
23
        $this->inputDefinition->addArgument(
24
            new InputArgument('login', InputArgument::REQUIRED, 'Login of player to kick.')
25
        );
26
        $this->inputDefinition->addArgument(
27
            new InputArgument('reason', InputArgument::REQUIRED, 'The reason for kicking.')
28
        );
29
    }
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public function getDescription()
35
    {
36
        return 'expansion_admin_chat.kick.description';
37
    }
38
39
    /**
40
     * @inheritdoc
41
     */
42
    public function execute($login, InputInterface $input)
43
    {
44
        $nickName = $this->playerStorage->getPlayerInfo($login)->getNickName();
45
        $playerLogin = $input->getArgument('login');
46
        $reason = $input->getArgument('reason');
47
48
        $playerNickName = $this->playerStorage->getPlayerInfo($playerLogin)->getNickName();
49
50
        $this->chatNotification->sendMessage(
51
            'expansion_admin_chat.kick.msg',
52
            null,
53
            ['%admin%' => $nickName, '%player%' => $playerNickName, "%reason%" => $reason]
54
        );
55
56
        $this->connection->kick($playerLogin, $reason);
57
    }
58
}
59