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 float the status update interval (in seconds) |
||
41 | */ |
||
42 | private $_updateInterval = self::DEFAULT_UPDATE_INTERVAL; |
||
43 | |||
44 | /** |
||
45 | * @var string the address to listen on |
||
46 | */ |
||
47 | private $_listenAddress = self::DEFAULT_LISTEN_ADDRESS; |
||
48 | |||
49 | /** |
||
50 | * @var int the port to listen on |
||
51 | */ |
||
52 | private $_listenPort = self::DEFAULT_LISTEN_PORT; |
||
53 | |||
54 | |||
55 | /** |
||
56 | * @param string $databasePath |
||
57 | * @param Instance[] $_instances |
||
58 | */ |
||
59 | public function __construct($databasePath, array $_instances) |
||
64 | |||
65 | |||
66 | /** |
||
67 | * @return string |
||
68 | */ |
||
69 | public function getDatabasePath() |
||
73 | |||
74 | |||
75 | /** |
||
76 | * @return string |
||
77 | */ |
||
78 | public function getLogPath() |
||
82 | |||
83 | |||
84 | /** |
||
85 | * @param string $logPath |
||
86 | */ |
||
87 | public function setLogPath($logPath) |
||
91 | |||
92 | |||
93 | /** |
||
94 | * @return Instance[] |
||
95 | */ |
||
96 | public function getInstances() |
||
100 | |||
101 | |||
102 | /** |
||
103 | * @param string $name |
||
104 | * |
||
105 | * @return Instance|null |
||
106 | */ |
||
107 | public function getInstanceByName($name) |
||
115 | |||
116 | |||
117 | /** |
||
118 | * @return float |
||
119 | */ |
||
120 | public function getUpdateInterval() |
||
124 | |||
125 | |||
126 | /** |
||
127 | * @param $updateInterval |
||
128 | * |
||
129 | * @throws \RuntimeException |
||
130 | */ |
||
131 | public function setUpdateInterval($updateInterval) |
||
138 | |||
139 | |||
140 | /** |
||
141 | * @return string |
||
142 | */ |
||
143 | public function getListenAddress() |
||
147 | |||
148 | |||
149 | /** |
||
150 | * @param string $listenAddress |
||
151 | */ |
||
152 | public function setListenAddress($listenAddress) |
||
156 | |||
157 | |||
158 | /** |
||
159 | * @return int |
||
160 | */ |
||
161 | public function getListenPort() |
||
165 | |||
166 | |||
167 | /** |
||
168 | * @param int $listenPort |
||
169 | * |
||
170 | * @throws \RuntimeException |
||
171 | */ |
||
172 | public function setListenPort($listenPort) |
||
179 | |||
180 | } |
||
181 |