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

Black::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 16
Ratio 100 %

Importance

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