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

Ban::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
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 Ban
10
 *
11
 * @package eXpansion\Bundle\AdminChat\ChatCommand;
12
 * @author reaby
13
 */
14 View Code Duplication
class Ban 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 ban.')
25
        );
26
        $this->inputDefinition->addArgument(
27
            new InputArgument('reason', InputArgument::REQUIRED, 'The reason for banning.')
28
        );
29
    }
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public function getDescription()
35
    {
36
        return 'expansion_admin_chat.ban.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.ban.msg',
52
            null,
53
            ['%admin%' => $nickName, '%player%' => $playerNickName, "%reason%" => $reason]
54
        );
55
56
        $this->connection->ban($playerLogin, $reason);
57
    }
58
}
59