Completed
Pull Request — master (#75)
by
unknown
02:24
created

Maps::onMapListModified()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 4
crap 2
1
<?php
2
3
namespace eXpansion\Bundle\Maps\Plugins;
4
5
use eXpansion\Framework\AdminGroups\Helpers\AdminGroups;
6
use eXpansion\Framework\Core\DataProviders\Listener\MapDataListenerInterface;
7
use eXpansion\Framework\Core\DataProviders\Listener\MatchDataListenerInterface;
8
use eXpansion\Framework\Core\Helpers\ChatNotification;
9
use eXpansion\Framework\Core\Plugins\StatusAwarePluginInterface;
10
use eXpansion\Framework\Core\Services\Console;
11
use eXpansion\Framework\Core\Storage\MapStorage;
12
use Maniaplanet\DedicatedServer\Connection;
13
use Maniaplanet\DedicatedServer\Structures\Map;
14
15
16
class Maps implements MatchDataListenerInterface, MapDataListenerInterface, StatusAwarePluginInterface
17
{
18
    /** @var Connection */
19
    protected $connection;
20
21
    /** @var Console */
22
    protected $console;
23
24
    /** @var AdminGroups */
25
    protected $adminGroups;
26
27
    /** @var bool */
28
    protected $enabled = true;
29
30
    /** @var MapStorage */
31
    protected $mapStorage;
32
33
    /** @var ChatNotification */
34
    protected $chatNotification;
35
36 View Code Duplication
    function __construct(
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...
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...
37
        Connection $connection,
38
        Console $console,
39
        AdminGroups $adminGroups,
40
        MapStorage $mapStorage,
41
        ChatNotification $chatNotification
42
    ) {
43
        $this->connection = $connection;
44
        $this->console = $console;
45
        $this->adminGroups = $adminGroups;
46
        $this->mapStorage = $mapStorage;
47
        $this->chatNotification = $chatNotification;
48
    }
49
50
    /**
51
     * Set the status of the plugin
52
     *
53
     * @param boolean $status
54
     *
55
     * @return void
56
     */
57
    public function setStatus($status)
58
    {
59
        if (!$status) {
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
60
61
        }
62
    }
63
64
    /**
65
     * @return array
66
     */
67
    public function getMaps()
68
    {
69
        return $this->mapStorage->getMaps();
70
    }
71
72
    /**
73
     * @param \Maniaplanet\DedicatedServer\Structures\Map[] $oldMaps
74
     * @param string $currentMapUid
75
     * @param string $nextMapUid
76
     * @param bool $isListModified
77
     * @return mixed|void
78
     */
79
    public function onMapListModified($oldMaps, $currentMapUid, $nextMapUid, $isListModified)
80
    {
81
82
    }
83
84
    public function onExpansionMapChange($currentMap, $previousMap)
85
    {
86
        // TODO: Implement onExpansionMapChange() method.
87
    }
88
89
    public function onExpansionNextMapChange($nextMap, $previousNextMap)
90
    {
91
        // TODO: Implement onExpansionNextMapChange() method.
92
    }
93
94
    /**
95
     * @param Map $map
96
     *
97
     * @return mixed
98
     */
99
    public function onBeginMap(Map $map)
100
    {
101
        $this->chatNotification->sendMessage('expansion_maps.chat.onbeginmap', null, ['%name%' => $map->name, '%author%' => $map->author]);
102
    }
103
104
    /**
105
     * @param Map $map
106
     *
107
     * @return mixed
108
     */
109
    public function onEndMap(Map $map)
110
    {
111
        // TODO: Implement onEndMap() method.
112
    }
113
}
114