Passed
Push — master ( 6b02b9...a180a6 )
by Nico
26:39 queued 18:43
created

GameSettings   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Test Coverage

Coverage 70%

Importance

Changes 0
Metric Value
eloc 19
c 0
b 0
f 0
dl 0
loc 57
ccs 14
cts 20
cp 0.7
rs 10
wmc 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getAdminIds() 0 3 1
A getColonySettings() 0 3 1
A getAdminSettings() 0 3 1
A getMapSettings() 0 3 1
A getTempDir() 0 3 1
A getConfigPath() 0 3 1
A getWebroot() 0 3 1
A useSemaphores() 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_USE_SEMAPHORES = 'useSemaphores';
14
    private const SETTING_VERSION = 'version';
15
    private const SETTING_WEBROOT = 'webroot';
16
17 3
    public function getAdminIds(): array
18
    {
19 3
        return array_map('intval', $this->getArrayConfigValue(self::SETTING_ADMINS, []));
20
    }
21
22
    public function getAdminSettings(): AdminSettingsInterface
23
    {
24
        return new AdminSettings($this->getPath(), $this->getConfig());
25
    }
26
27
    public function getColonySettings(): ColonySettingsInterface
28
    {
29
        return new ColonySettings($this->getPath(), $this->getConfig());
30
    }
31
32
    public function getMapSettings(): MapSettingsInterface
33
    {
34
        return new MapSettings($this->getPath(), $this->getConfig());
35
    }
36
37 2
    public function getTempDir(): string
38
    {
39 2
        return $this->getStringConfigValue(self::SETTING_TEMP_DIR);
40
    }
41
42 3
    public function useSemaphores(): bool
43
    {
44 3
        return $this->getBooleanConfigValue(self::SETTING_USE_SEMAPHORES, false);
45
    }
46
47 3
    public function getVersion(): string|int
48
    {
49
        try {
50 3
            return $this->getIntegerConfigValue(self::SETTING_VERSION);
51 1
        } catch (StuConfigException $e) {
52 1
            return $this->getStringConfigValue(self::SETTING_VERSION);
53
        }
54
    }
55
56 4
    public function getWebroot(): string
57
    {
58 4
        return $this->getStringConfigValue(self::SETTING_WEBROOT);
59
    }
60
61 15
    public function getConfigPath(): string
62
    {
63 15
        return self::CONFIG_PATH;
64
    }
65
}
66