Completed
Push — master ( f3bed7...d2e601 )
by De Cramer
9s
created

JoinLeaveMessages::onPlayerAlliesChanged()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 0
cts 3
cp 0
cc 1
eloc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace eXpansion\Bundle\JoinLeaveMessages\Plugins;
4
5
use eXpansion\Core\DataProviders\Listener\PlayerDataListenerInterface;
6
use eXpansion\Core\Services\Console;
7
use eXpansion\Core\Storage\Data\Player;
8
use Maniaplanet\DedicatedServer\Connection;
9
10
class JoinLeaveMessages implements PlayerDataListenerInterface
11
{
12
    /** @var Connection  */
13
    protected $connection;
14
    /** @var Console  */
15
    protected $console;
16
    /** @var bool  */
17
    private $enabled = true;
18
19
    /**
20
     * JoinLeaveMessages constructor.
21
     *
22
     * @param Connection $connection
23
     * @param Console $console
24
     */
25
    function __construct(Connection $connection, Console $console)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
26
    {
27
        $this->connection = $connection;
28
        $this->console = $console;
29
    }
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public function onRun()
35
    {
36
        // @todo make this callback work!
37
        $this->enabled = true;
38
    }
39
40
    /**
41
     * @inheritdoc
42
     */
43 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...
44
    {
45
        $msg = '$fffHello, ' . $player->getNickName() . '  $n$fff($888' . $player->getLogin() . '$fff)';
46
        if ($this->enabled) {
47
            $this->connection->chatSendServerMessage($msg);
48
        }
49
    }
50
51
    /**
52
     * @inheritdoc
53
     */
54 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...
55
    {
56
        $msg = '$fffSee you, ' . $player->getNickName() . '  $n$fff($888' . $player->getLogin() . '$fff)';
57
        if ($this->enabled) {
58
            $this->connection->chatSendServerMessage($msg);
59
        }
60
    }
61
62
    /**
63
     * @inheritdoc
64
     */
65
    public function onPlayerInfoChanged(Player $oldPlayer, Player $player)
66
    {
67
    }
68
69
    /**
70
     * @inheritdoc
71
     */
72
    public function onPlayerAlliesChanged(Player $oldPlayer, Player $player)
73
    {
74
    }
75
}
76