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
|
|
|
|