Completed
Pull Request — master (#316)
by De Cramer
04:05
created

StopExpansion   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 60
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 1
A getDescription() 0 4 1
A getHelp() 0 4 1
A execute() 0 11 1
1
<?php
2
3
4
namespace eXpansion\Framework\Core\ChatCommand;
5
use eXpansion\Framework\AdminGroups\Helpers\AdminGroups;
6
use eXpansion\Framework\AdminGroups\Model\AbstractAdminChatCommand;
7
use eXpansion\Framework\Core\Helpers\ChatNotification;
8
use eXpansion\Framework\Core\Services\Application;
9
use eXpansion\Framework\Core\Storage\PlayerStorage;
10
use Symfony\Component\Console\Input\InputInterface;
11
12
13
/**
14
 * Class StopExpansion
15
 *
16
 * @package eXpansion\Framework\Core\ChatCommand;
17
 * @author  oliver de Cramer <[email protected]>
18
 */
19
class StopExpansion extends AbstractAdminChatCommand
20
{
21
    /** @var ChatNotification */
22
    protected $chatNotificaiton;
23
24
    /** @var Application */
25
    protected $application;
26
27
    /** @var PlayerStorage */
28
    protected $playerStorage;
29
30
    /**
31
     * StopExpansion constructor.
32
     *
33
     * @param ChatNotification $chatNotification
34
     * @param Application      $application
35
     * @param PlayerStorage    $playerStorage
36
     */
37
    public function __construct(
38
        $command,
39
        $permission,
40
        array $aliases = [],
41
        AdminGroups $adminGroups,
42
        ChatNotification $chatNotification,
43
        Application $application,
44
        PlayerStorage $playerStorage
45
    ) {
46
        parent::__construct($command, $permission, $aliases, $adminGroups);
47
48
        $this->chatNotificaiton = $chatNotification;
49
        $this->application = $application;
50
        $this->playerStorage = $playerStorage;
51
    }
52
53
    public function getDescription()
54
    {
55
        return "expansion_core.chat_commands.stop.help";
56
    }
57
58
    public function getHelp()
59
    {
60
        return "expansion_core.chat_commands.stop.help";
61
    }
62
63
64
    /**
65
     * @inheritdoc
66
     */
67
    public function execute($login, InputInterface $input)
68
    {
69
        $player = $this->playerStorage->getPlayerInfo($login);
70
        $this->chatNotificaiton->sendMessage(
71
            'expansion_core.chat_commands.stop.message',
72
            null,
73
            ['%nickname%' => $player->getNickName()]
74
        );
75
76
        $this->application->stopApplication();
77
    }
78
}
79