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

GameSettings::getAdminSettings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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