Completed
Push — master ( cac559...b1b643 )
by De Cramer
12s
created

MapStorage::getMap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

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
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace eXpansion\Core\Storage;
4
5
use Maniaplanet\DedicatedServer\Structures\Map;
6
use oliverde8\AssociativeArraySimplified\AssociativeArray;
7
8
/**
9
 * Class MapStorage stores data on the maps to be played & that is being currently played.
10
 *
11
 * @package eXpansion\Core\Storage
12
 * @author Oliver de Cramer
13
 */
14
class MapStorage
15
{
16
    /** @var Map[] List of all current maps on the server. */
17
    protected $maps = [];
18
19
    /** @var Map Current map being played. */
20
    protected $currentMap;
21
22
    /** @var Map Next map to be played. */
23
    protected $nextMap;
24
25
    /**
26
     * Add a map to the current map list.
27
     *
28
     * @param Map $map
29
     *
30
     */
31 4
    public function addMap(Map $map)
32
    {
33 4
        $this->maps[$map->uId] = $map;
34 4
    }
35
36
    /**
37
     * Get current map list.
38
     *
39
     * @return array
40
     */
41 2
    public function getMaps()
42
    {
43 2
        return $this->maps;
44
    }
45
46
    /**
47
     * Get a map.
48
     *
49
     * @param string $uid The unique id of the map to get.
50
     *
51
     * @return mixed
52
     */
53 1
    public function getMap($uid)
54
    {
55 1
        return AssociativeArray::getFromKey($this->maps, $uid, null);
56
    }
57
58
    /**
59
     * Reset map data.
60
     */
61 1
    public function resetMapData()
62
    {
63 1
        $this->maps = [];
64 1
    }
65
66
    /**
67
     * Get current map being played.
68
     *
69
     * @return Map
70
     */
71 1
    public function getCurrentMap()
72
    {
73 1
        return $this->currentMap;
74
    }
75
76
    /**
77
     * Set the current map when it's changed.
78
     *
79
     * @param Map $currentMap
80
     */
81 1
    public function setCurrentMap($currentMap)
82
    {
83 1
        $this->currentMap = $currentMap;
84 1
    }
85
86
    /**
87
     * Get next map to be played.
88
     *
89
     * @return Map
90
     */
91 1
    public function getNextMap()
92
    {
93 1
        return $this->nextMap;
94
    }
95
96
    /**
97
     * Set the next map that is going to be played.
98
     *
99
     * @param Map $nextMap
100
     */
101 1
    public function setNextMap($nextMap)
102
    {
103 1
        $this->nextMap = $nextMap;
104 1
    }
105
}
106