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

GameDataStorage   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 60%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 69
ccs 9
cts 15
cp 0.6
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getGameInfos() 0 4 1
A setGameInfos() 0 4 1
A getVersion() 0 4 1
A setVersion() 0 4 1
A getGameModeCode() 0 4 1
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
}