Test Failed
Push — dev ( 6168ca...8d99a1 )
by Nico
33:22 queued 26:34
created

GameSettings   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
eloc 16
c 0
b 0
f 0
dl 0
loc 46
rs 10
ccs 12
cts 14
cp 0.8571
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getAdminIds() 0 3 1
A getAdminSettings() 0 3 1
A getWebroot() 0 3 1
A getColonySettings() 0 3 1
A getTempDir() 0 3 1
A getConfigPath() 0 3 1
A getVersion() 0 6 2
1
<?php
2
3
namespace Stu\Module\Config\Model;
4
5
use Stu\Module\Config\StuConfigException;
6
7
final class GameSettings extends AbstractSettings implements GameSettingsInterface
8
{
9
    private const CONFIG_PATH = 'game';
10
11
    private const SETTING_ADMINS = 'admins';
12
    private const SETTING_TEMP_DIR = 'temp_dir';
13
    private const SETTING_VERSION = 'version';
14
    private const SETTING_WEBROOT = 'webroot';
15
16 3
    public function getAdminIds(): array
17
    {
18 3
        return array_map('intval', $this->getArrayConfigValue(self::SETTING_ADMINS, []));
19
    }
20
21
    public function getAdminSettings(): AdminSettingsInterface
22
    {
23
        return new AdminSettings($this->getPath(), $this->getConfig());
24
    }
25
26 2
    public function getColonySettings(): ColonySettingsInterface
27
    {
28 2
        return new ColonySettings($this->getPath(), $this->getConfig());
29
    }
30
31 3
    public function getTempDir(): string
32
    {
33
        return $this->getStringConfigValue(self::SETTING_TEMP_DIR);
34 3
    }
35 1
36 1
    public function getVersion(): string|int
37
    {
38
        try {
39
            return $this->getIntegerConfigValue(self::SETTING_VERSION);
40 4
        } catch (StuConfigException $e) {
41
            return $this->getStringConfigValue(self::SETTING_VERSION);
42 4
        }
43
    }
44
45 12
    public function getWebroot(): string
46
    {
47 12
        return $this->getStringConfigValue(self::SETTING_WEBROOT);
48
    }
49
50
    public function getConfigPath(): string
51
    {
52
        return self::CONFIG_PATH;
53
    }
54
}
55