Completed
Pull Request — master (#50)
by De Cramer
02:53
created

GameDataStorage::setVersion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace eXpansion\Framework\Core\Storage;
4
use Maniaplanet\DedicatedServer\Structures\GameInfos;
5
use Maniaplanet\DedicatedServer\Structures\Version;
6
use oliverde8\AssociativeArraySimplified\AssociativeArray;
7
8
/**
9
 * Class GameDataStorage
10
 *
11
 * @author    de Cramer Oliver<[email protected]>
12
 * @copyright 2017 Smile
13
 * @package eXpansion\Framework\Core\Storage
14
 */
15
class GameDataStorage
16
{
17
    /**  */
18
    const GAME_MODE_CODE_UNKNOWN = 'unknown';
19
20
    /** @var  GameInfos */
21
    protected $gameInfos;
22
23
    /** @var Version */
24
    protected $version;
25
26
    /**
27
     * @var AssociativeArray
28
     */
29
    protected $gameModeCodes;
30
31
    /**
32
     * GameDataStorage constructor.
33
     *
34
     * @param array $gameModeCodes
35
     */
36 44
    public function __construct(array $gameModeCodes)
37
    {
38 44
        $this->gameModeCodes = new AssociativeArray($gameModeCodes);
39 44
    }
40
41
42
    /**
43
     * @return GameInfos
44
     */
45 1
    public function getGameInfos()
46
    {
47 1
        return $this->gameInfos;
48
    }
49
50
    /**
51
     * @param GameInfos $gameInfos
52
     */
53
    public function setGameInfos($gameInfos)
54
    {
55
        $this->gameInfos = $gameInfos;
56
    }
57
58
    /**
59
     * @return Version
60
     */
61 1
    public function getVersion()
62
    {
63 1
        return $this->version;
64
    }
65
66
    /**
67
     * @param Version $version
68
     */
69
    public function setVersion($version)
70
    {
71
        $this->version = $version;
72
    }
73
74
    /**
75
     * Get code of the game mode.
76
     *
77
     * @return mixed
78
     */
79 1
    public function getGameModeCode()
80
    {
81 1
        return $this->gameModeCodes->get($this->getGameInfos()->gameMode, self::GAME_MODE_CODE_UNKNOWN);
82
    }
83
}