|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Jalle19\StatusManager\Configuration; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Class Configuration |
|
7
|
|
|
* @package Jalle19\StatusManager\Configuration |
|
8
|
|
|
* @copyright Copyright © Sam Stenvall 2015- |
|
9
|
|
|
* @license https://www.gnu.org/licenses/gpl.html The GNU General Public License v2.0 |
|
10
|
|
|
*/ |
|
11
|
|
|
class Configuration |
|
12
|
|
|
{ |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @var string the database path |
|
16
|
|
|
*/ |
|
17
|
|
|
private $_databasePath; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @var string the log file path |
|
21
|
|
|
*/ |
|
22
|
|
|
private $_logPath; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var Instance[] the instances |
|
26
|
|
|
*/ |
|
27
|
|
|
private $_instances; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var string the access token used by clients |
|
31
|
|
|
*/ |
|
32
|
|
|
private $_accessToken; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var float the status update interval (in seconds) |
|
36
|
|
|
*/ |
|
37
|
|
|
private $_updateInterval; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var string the address to listen on |
|
41
|
|
|
*/ |
|
42
|
|
|
private $_listenAddress; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var int the port to listen on |
|
46
|
|
|
*/ |
|
47
|
|
|
private $_listenPort; |
|
48
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @return string |
|
52
|
|
|
*/ |
|
53
|
1 |
|
public function getDatabasePath() |
|
54
|
|
|
{ |
|
55
|
1 |
|
return $this->_databasePath; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @param string $databasePath |
|
61
|
|
|
*/ |
|
62
|
1 |
|
public function setDatabasePath($databasePath) |
|
63
|
|
|
{ |
|
64
|
1 |
|
$this->_databasePath = $databasePath; |
|
65
|
|
|
|
|
66
|
1 |
|
return $this; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @return string |
|
72
|
|
|
*/ |
|
73
|
1 |
|
public function getLogPath() |
|
74
|
|
|
{ |
|
75
|
1 |
|
return $this->_logPath; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @param string $logPath |
|
81
|
|
|
*/ |
|
82
|
1 |
|
public function setLogPath($logPath) |
|
83
|
|
|
{ |
|
84
|
1 |
|
$this->_logPath = $logPath; |
|
85
|
|
|
|
|
86
|
1 |
|
return $this; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @return Instance[] |
|
92
|
|
|
*/ |
|
93
|
3 |
|
public function getInstances() |
|
94
|
|
|
{ |
|
95
|
3 |
|
return $this->_instances; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* @param Instance[] $instances |
|
101
|
|
|
*/ |
|
102
|
1 |
|
public function setInstances(array $instances) |
|
103
|
|
|
{ |
|
104
|
1 |
|
$this->_instances = $instances; |
|
105
|
|
|
|
|
106
|
1 |
|
return $this; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @return string |
|
112
|
|
|
*/ |
|
113
|
1 |
|
public function getAccessToken() |
|
114
|
|
|
{ |
|
115
|
1 |
|
return $this->_accessToken; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @param string $accessToken |
|
121
|
|
|
*/ |
|
122
|
1 |
|
public function setAccessToken($accessToken) |
|
123
|
|
|
{ |
|
124
|
1 |
|
$this->_accessToken = $accessToken; |
|
125
|
|
|
|
|
126
|
1 |
|
return $this; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @param string $name |
|
132
|
|
|
* |
|
133
|
|
|
* @return Instance|null |
|
134
|
|
|
*/ |
|
135
|
1 |
|
public function getInstanceByName($name) |
|
136
|
|
|
{ |
|
137
|
1 |
|
foreach ($this->_instances as $instance) |
|
138
|
1 |
|
if ($instance->getName() === $name) |
|
139
|
1 |
|
return $instance; |
|
140
|
|
|
|
|
141
|
1 |
|
return null; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* @return float |
|
147
|
|
|
*/ |
|
148
|
1 |
|
public function getUpdateInterval() |
|
149
|
|
|
{ |
|
150
|
1 |
|
return $this->_updateInterval; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* @param $updateInterval |
|
156
|
|
|
* |
|
157
|
|
|
* @throws \RuntimeException |
|
158
|
|
|
*/ |
|
159
|
1 |
|
public function setUpdateInterval($updateInterval) |
|
160
|
|
|
{ |
|
161
|
1 |
|
$this->_updateInterval = $updateInterval; |
|
162
|
|
|
|
|
163
|
1 |
|
return $this; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* @return string |
|
169
|
|
|
*/ |
|
170
|
1 |
|
public function getListenAddress() |
|
171
|
|
|
{ |
|
172
|
1 |
|
return $this->_listenAddress; |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* @param string $listenAddress |
|
178
|
|
|
*/ |
|
179
|
1 |
|
public function setListenAddress($listenAddress) |
|
180
|
|
|
{ |
|
181
|
1 |
|
$this->_listenAddress = $listenAddress; |
|
182
|
|
|
|
|
183
|
1 |
|
return $this; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
|
|
187
|
|
|
/** |
|
188
|
|
|
* @return int |
|
189
|
|
|
*/ |
|
190
|
1 |
|
public function getListenPort() |
|
191
|
|
|
{ |
|
192
|
1 |
|
return $this->_listenPort; |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
|
|
|
|
196
|
|
|
/** |
|
197
|
|
|
* @param int $listenPort |
|
198
|
|
|
* |
|
199
|
|
|
* @throws \RuntimeException |
|
200
|
|
|
*/ |
|
201
|
1 |
|
public function setListenPort($listenPort) |
|
202
|
|
|
{ |
|
203
|
1 |
|
$this->_listenPort = $listenPort; |
|
204
|
|
|
|
|
205
|
1 |
|
return $this; |
|
206
|
|
|
} |
|
207
|
|
|
|
|
208
|
|
|
} |
|
209
|
|
|
|