Completed
Pull Request — master (#8)
by De Cramer
12:20
created

MapStorage::getMaps()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
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 $nexMap;
24
25
    /**
26
     * Add a map to the current map list.
27
     *
28
     * @param Map $map
29
     *
30
     */
31
    public function addMap(Map $map)
32
    {
33
        $this->maps[$map->uId] = $map;
34
    }
35
36
    /**
37
     * Get current map list.
38
     *
39
     * @return array
40
     */
41
    public function getMaps()
42
    {
43
        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
    public function getMap($uid)
54
    {
55
        return AssociativeArray::getFromKey($this->maps, $uid, null);
56
    }
57
58
    /**
59
     * Reset map data.
60
     */
61
    public function resetMapData()
62
    {
63
        $this->maps = [];
64
    }
65
66
    /**
67
     * Get current map being played.
68
     *
69
     * @return Map
70
     */
71
    public function getCurrentMap()
72
    {
73
        return $this->currentMap;
74
    }
75
76
    /**
77
     * Set the current map when it's changed.
78
     *
79
     * @param Map $currentMap
80
     */
81
    public function setCurrentMap($currentMap)
82
    {
83
        $this->currentMap = $currentMap;
84
    }
85
86
    /**
87
     * Get next map to be played.
88
     *
89
     * @return Map
90
     */
91
    public function getNexMap()
92
    {
93
        return $this->nexMap;
94
    }
95
96
    /**
97
     * Set the next map that is going to be played.
98
     *
99
     * @param Map $nexMap
100
     */
101
    public function setNexMap($nexMap)
102
    {
103
        $this->nexMap = $nexMap;
104
    }
105
}
106