AbstractUserGroupPlugin::onPlayerAlliesChanged()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
4
namespace eXpansion\Framework\Core\Plugins\UserGroups;
5
6
use eXpansion\Framework\GameManiaplanet\DataProviders\Listener\ListenerInterfaceMpLegacyPlayer;
7
use eXpansion\Framework\Core\Model\UserGroups\Group;
8
use eXpansion\Framework\Core\Plugins\StatusAwarePluginInterface;
9
use eXpansion\Framework\Core\Storage\Data\Player;
10
use eXpansion\Framework\Core\Storage\PlayerStorage;
11
12
abstract class AbstractUserGroupPlugin implements ListenerInterfaceMpLegacyPlayer, StatusAwarePluginInterface
13
{
14
    /** @var Group  */
15
    protected $userGroup;
16
17
    /** @var PlayerStorage  */
18
    protected $playerStorage;
19
20
    /**
21
     * AbstractUserGroupPlugin constructor.
22
     *
23
     * @param Group $userGroup
24
     */
25 5
    public function __construct(Group $userGroup, PlayerStorage $playerStorage)
26
    {
27 5
        $this->userGroup = $userGroup;
28 5
        $this->playerStorage = $playerStorage;
29 5
    }
30
31
    /**
32
     * @inheritdoc
33
     */
34 View Code Duplication
    public function setStatus($status)
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...
35
    {
36
        if ($status && !empty($this->playerStorage->getOnline())) {
37
            foreach ($this->playerStorage->getOnline() as $player) {
38
                $this->onPlayerConnect($player);
39
            }
40
        }
41
    }
42
43
    /**
44
     * @inheritdoc
45
     */
46 1
    public function onPlayerDisconnect(Player $player, $disconnectionReason)
47
    {
48 1
        $this->userGroup->removeLogin($player->getLogin());
49 1
    }
50
51
    /**
52
     * @inheritdoc
53
     */
54 1
    public function onPlayerInfoChanged(Player $oldPlayer, Player $player)
55
    {
56
        // By default nothing.
57 1
    }
58
59
    /**
60
     * @inheritdoc
61
     */
62 1
    public function onPlayerAlliesChanged(Player $oldPlayer, Player $player)
63
    {
64
        // By default nothing.
65 1
    }
66
}
67