1 | <?php |
||
11 | class Configuration |
||
12 | { |
||
13 | |||
14 | const SECTION_TYPE_INSTANCE = 'instance'; |
||
15 | |||
16 | const OPTION_UPDATE_INTERVAL = 'updateInterval'; |
||
17 | const OPTION_LISTEN_ADDRESS = 'listenAddress'; |
||
18 | const OPTION_LISTEN_PORT = 'listenPort'; |
||
19 | |||
20 | const DEFAULT_UPDATE_INTERVAL = 2; |
||
21 | const DEFAULT_LISTEN_ADDRESS = '0.0.0.0'; |
||
22 | const DEFAULT_LISTEN_PORT = 9333; |
||
23 | |||
24 | /** |
||
25 | * @var string the database path |
||
26 | */ |
||
27 | private $_databasePath; |
||
28 | |||
29 | /** |
||
30 | * @var string the log file path |
||
31 | */ |
||
32 | private $_logPath; |
||
33 | |||
34 | /** |
||
35 | * @var Instance[] the instances |
||
36 | */ |
||
37 | private $_instances; |
||
38 | |||
39 | /** |
||
40 | * @var string the access token used by clients |
||
41 | */ |
||
42 | private $_accessToken; |
||
43 | |||
44 | /** |
||
45 | * @var float the status update interval (in seconds) |
||
46 | */ |
||
47 | private $_updateInterval = self::DEFAULT_UPDATE_INTERVAL; |
||
48 | |||
49 | /** |
||
50 | * @var string the address to listen on |
||
51 | */ |
||
52 | private $_listenAddress = self::DEFAULT_LISTEN_ADDRESS; |
||
53 | |||
54 | /** |
||
55 | * @var int the port to listen on |
||
56 | */ |
||
57 | private $_listenPort = self::DEFAULT_LISTEN_PORT; |
||
58 | |||
59 | |||
60 | /** |
||
61 | * @param string $databasePath |
||
62 | * @param Instance[] $_instances |
||
63 | * @param string $accessToken |
||
64 | */ |
||
65 | public function __construct($databasePath, array $_instances, $accessToken) |
||
71 | |||
72 | |||
73 | /** |
||
74 | * @return string |
||
75 | */ |
||
76 | public function getDatabasePath() |
||
80 | |||
81 | |||
82 | /** |
||
83 | * @return string |
||
84 | */ |
||
85 | public function getLogPath() |
||
89 | |||
90 | |||
91 | /** |
||
92 | * @param string $logPath |
||
93 | */ |
||
94 | public function setLogPath($logPath) |
||
98 | |||
99 | |||
100 | /** |
||
101 | * @return Instance[] |
||
102 | */ |
||
103 | 2 | public function getInstances() |
|
107 | |||
108 | |||
109 | /** |
||
110 | * @return string |
||
111 | */ |
||
112 | public function getAccessToken() |
||
116 | |||
117 | |||
118 | /** |
||
119 | * @param string $name |
||
120 | * |
||
121 | * @return Instance|null |
||
122 | */ |
||
123 | public function getInstanceByName($name) |
||
131 | |||
132 | |||
133 | /** |
||
134 | * @return float |
||
135 | */ |
||
136 | public function getUpdateInterval() |
||
140 | |||
141 | |||
142 | /** |
||
143 | * @param $updateInterval |
||
144 | * |
||
145 | * @throws \RuntimeException |
||
146 | */ |
||
147 | public function setUpdateInterval($updateInterval) |
||
154 | |||
155 | |||
156 | /** |
||
157 | * @return string |
||
158 | */ |
||
159 | public function getListenAddress() |
||
163 | |||
164 | |||
165 | /** |
||
166 | * @param string $listenAddress |
||
167 | */ |
||
168 | public function setListenAddress($listenAddress) |
||
172 | |||
173 | |||
174 | /** |
||
175 | * @return int |
||
176 | */ |
||
177 | public function getListenPort() |
||
181 | |||
182 | |||
183 | /** |
||
184 | * @param int $listenPort |
||
185 | * |
||
186 | * @throws \RuntimeException |
||
187 | */ |
||
188 | public function setListenPort($listenPort) |
||
195 | |||
196 | } |
||
197 |