Completed
Pull Request — master (#106)
by De Cramer
03:01
created

JoinLeaveMessages::onPlayerInfoChanged()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 2
1
<?php
2
3
namespace eXpansion\Bundle\JoinLeaveMessages\Plugins;
4
5
use eXpansion\Bundle\AdminChat\AdminChatBundle;
6
use eXpansion\Framework\AdminGroups\Helpers\AdminGroups;
7
use eXpansion\Framework\Core\DataProviders\Listener\ListenerInterfaceMpLegacyPlayer;
8
use eXpansion\Framework\Core\Helpers\ChatNotification;
9
use eXpansion\Framework\Core\Services\Console;
10
use eXpansion\Framework\Core\Storage\Data\Player;
11
use Maniaplanet\DedicatedServer\Connection;
12
13
class JoinLeaveMessages implements ListenerInterfaceMpLegacyPlayer
14
{
15
    /** @var Connection */
16
    protected $connection;
17
18
    /** @var Console */
19
    protected $console;
20
21
    /** @var ChatNotification $chat */
22
    protected $chat;
23
24
    /** @var AdminGroups */
25
    protected $adminGroups;
26
27
    /**
28
     * JoinLeaveMessages constructor.
29
     *
30
     * @param Connection $connection
31
     * @param Console $console
32
     */
33
    public function __construct(
34
        Connection $connection,
35
        Console $console,
36
        ChatNotification $chatNotification,
37
        AdminGroups $adminGroups
38
    ) {
39
        $this->connection = $connection;
40
        $this->console = $console;
41
        $this->chat = $chatNotification;
42
        $this->adminGroups = $adminGroups;
43
    }
44
45
    /**
46
     * @inheritdoc
47
     */
48 View Code Duplication
    public function onPlayerConnect(Player $player)
0 ignored issues
show
Duplication introduced by
This method 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...
49
    {
50
        $groupName = $this->adminGroups->getLoginUserGroups($player->getLogin())->getName();
51
52
        $this->chat->sendMessage(
53
            "expansion_join_leave_messages.connect",
54
            null,
55
            [
56
                "%group%" => $this->adminGroups->getGroupLabel($groupName),
57
                "%nickname%" => $player->getNickName(),
58
                "%login%" => $player->getLogin(),
59
                "%path%" => $player->getPath(),
60
                "%ladder%" => $player->getLadderScore(),
61
            ]);
62
    }
63
64
    /**
65
     * @inheritdoc
66
     */
67 View Code Duplication
    public function onPlayerDisconnect(Player $player, $disconnectionReason)
0 ignored issues
show
Duplication introduced by
This method 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...
68
    {
69
        $groupName = $this->adminGroups->getLoginUserGroups($player->getLogin())->getName();
70
71
        $this->chat->sendMessage(
72
            "expansion_join_leave_messages.disconnect",
73
            null,
74
            [
75
                "%group%" => $this->adminGroups->getGroupLabel($groupName),
76
                "%nickname%" => $player->getNickName(),
77
                "%login%" => $player->getLogin(),
78
                "%path%" => $player->getPath(),
79
                "%ladder%" => $player->getLadderScore(),
80
            ]);
81
    }
82
83
    /**
84
     * @inheritdoc
85
     */
86
    public function onPlayerInfoChanged(Player $oldPlayer, Player $player)
87
    {
88
89
    }
90
91
    /**
92
     * @inheritdoc
93
     */
94
    public function onPlayerAlliesChanged(Player $oldPlayer, Player $player)
95
    {
96
    }
97
}
98