1 | <?php |
||
13 | class Configuration |
||
14 | { |
||
15 | |||
16 | const SECTION_TYPE_INSTANCE = 'instance'; |
||
17 | |||
18 | const OPTION_UPDATE_INTERVAL = 'updateInterval'; |
||
19 | const OPTION_LISTEN_ADDRESS = 'listenAddress'; |
||
20 | const OPTION_LISTEN_PORT = 'listenPort'; |
||
21 | |||
22 | const DEFAULT_UPDATE_INTERVAL = 2; |
||
23 | const DEFAULT_LISTEN_ADDRESS = '0.0.0.0'; |
||
24 | const DEFAULT_LISTEN_PORT = 9333; |
||
25 | |||
26 | /** |
||
27 | * @var string the database path |
||
28 | */ |
||
29 | private $_databasePath; |
||
30 | |||
31 | /** |
||
32 | * @var string the log file path |
||
33 | */ |
||
34 | private $_logPath; |
||
35 | |||
36 | /** |
||
37 | * @var Instance[] the instances |
||
38 | */ |
||
39 | private $_instances; |
||
40 | |||
41 | /** |
||
42 | * @var float the status update interval (in seconds) |
||
43 | */ |
||
44 | private $_updateInterval = self::DEFAULT_UPDATE_INTERVAL; |
||
45 | |||
46 | /** |
||
47 | * @var string the address to listen on |
||
48 | */ |
||
49 | private $_listenAddress = self::DEFAULT_LISTEN_ADDRESS; |
||
50 | |||
51 | /** |
||
52 | * @var int the port to listen on |
||
53 | */ |
||
54 | private $_listenPort = self::DEFAULT_LISTEN_PORT; |
||
55 | |||
56 | |||
57 | /** |
||
58 | * @param string $databasePath |
||
59 | * @param Instance[] $_instances |
||
60 | */ |
||
61 | public function __construct($databasePath, array $_instances) |
||
66 | |||
67 | |||
68 | /** |
||
69 | * @return string |
||
70 | */ |
||
71 | public function getDatabasePath() |
||
75 | |||
76 | |||
77 | /** |
||
78 | * @return string |
||
79 | */ |
||
80 | public function getLogPath() |
||
84 | |||
85 | |||
86 | /** |
||
87 | * @param string $logPath |
||
88 | */ |
||
89 | public function setLogPath($logPath) |
||
93 | |||
94 | |||
95 | /** |
||
96 | * @return Instance[] |
||
97 | */ |
||
98 | public function getInstances() |
||
102 | |||
103 | |||
104 | /** |
||
105 | * @return float |
||
106 | */ |
||
107 | public function getUpdateInterval() |
||
111 | |||
112 | |||
113 | /** |
||
114 | * @param $updateInterval |
||
115 | * |
||
116 | * @throws \RuntimeException |
||
117 | */ |
||
118 | public function setUpdateInterval($updateInterval) |
||
125 | |||
126 | |||
127 | /** |
||
128 | * @return string |
||
129 | */ |
||
130 | public function getListenAddress() |
||
134 | |||
135 | |||
136 | /** |
||
137 | * @param string $listenAddress |
||
138 | */ |
||
139 | public function setListenAddress($listenAddress) |
||
143 | |||
144 | |||
145 | /** |
||
146 | * @return int |
||
147 | */ |
||
148 | public function getListenPort() |
||
152 | |||
153 | |||
154 | /** |
||
155 | * @param int $listenPort |
||
156 | * |
||
157 | * @throws \RuntimeException |
||
158 | */ |
||
159 | public function setListenPort($listenPort) |
||
166 | |||
167 | |||
168 | /** |
||
169 | * @param string $section |
||
170 | * @param array $values |
||
171 | * |
||
172 | * @return Instance |
||
173 | */ |
||
174 | public static function parseInstance($section, $values) |
||
192 | |||
193 | |||
194 | /** |
||
195 | * Returns the determined section type based on the specified section name |
||
196 | * |
||
197 | * @param string $section |
||
198 | * |
||
199 | * @return string |
||
200 | * @throws InvalidConfigurationException if the section type could not be determined |
||
201 | */ |
||
202 | public static function getSectionType($section) |
||
209 | |||
210 | } |
||
211 |