1 | <?php |
||
23 | class Server implements ServerInterface |
||
24 | { |
||
25 | /** |
||
26 | * The filesystem path where the web server is installed. |
||
27 | * |
||
28 | * It has to be an absolute path. |
||
29 | * |
||
30 | * Apache httpd server does not accept a relative prefix path at compilation. |
||
31 | * Nginx does, but this is a very risky practice... |
||
32 | * So relative prefix path in nginx configuration will not be considered |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | private $prefix = ''; |
||
37 | |||
38 | /** |
||
39 | * The string to match as a starting multi-line directive. |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | private $startMultiLine = ''; |
||
44 | |||
45 | /** |
||
46 | * The string to match as an ending multi-line directive. |
||
47 | * |
||
48 | * @var string |
||
49 | */ |
||
50 | private $endMultiLine = ''; |
||
51 | |||
52 | /** |
||
53 | * The string to match a simple directive. |
||
54 | * |
||
55 | * @var string |
||
56 | */ |
||
57 | private $simpleDirective = ''; |
||
58 | |||
59 | /** |
||
60 | * binaries that can be used to control the webserver. |
||
61 | * |
||
62 | * @var array |
||
63 | */ |
||
64 | private $binaries = []; |
||
65 | |||
66 | /** |
||
67 | * the parameter string to use to detect version and config file. |
||
68 | * |
||
69 | * @var string |
||
70 | */ |
||
71 | private $detectionParameter = ''; |
||
72 | |||
73 | /** |
||
74 | * The ordered list of methods to apply before convertion. |
||
75 | * |
||
76 | * @var array |
||
77 | */ |
||
78 | private $beforeMethods = []; |
||
79 | |||
80 | /** |
||
81 | * The ordered list of methods to apply after convertion. |
||
82 | * |
||
83 | * @var array |
||
84 | */ |
||
85 | private $afterMethods = []; |
||
86 | |||
87 | /** |
||
88 | * Confirms if the server instance has valid parameters. |
||
89 | * |
||
90 | * @return bool true if all parameters are initialized, false otherwise |
||
91 | */ |
||
92 | 2 | public function isValid() |
|
101 | |||
102 | /** |
||
103 | * Getter for the prefix. |
||
104 | * |
||
105 | * @return string the filesystem path where the web server is installed |
||
106 | */ |
||
107 | 2 | public function getPrefix() |
|
111 | |||
112 | /** |
||
113 | * Sets the prefix of a server isntance. |
||
114 | * |
||
115 | * @throws ServerException if the prefix is invalid |
||
116 | * |
||
117 | * @param string $prefix the filesystem path where the web server is installed |
||
118 | */ |
||
119 | 11 | public function setPrefix($prefix) |
|
142 | |||
143 | /** |
||
144 | * Gets the regexp that will match the starting block directives. |
||
145 | * |
||
146 | * @return string the regexp that will match the starting block directives |
||
147 | */ |
||
148 | 8 | public function getStartMultiLine() |
|
152 | |||
153 | /** |
||
154 | * Sets the regexp that will match the starting block directives. |
||
155 | * |
||
156 | * @param string $startMultiLine the regexp that will match the starting block directives |
||
157 | */ |
||
158 | 13 | public function setStartMultiLine($startMultiLine) |
|
169 | |||
170 | /** |
||
171 | * Gets the regexp that will match the ending block directives. |
||
172 | * |
||
173 | * @return string the regexp that will match the ending block directives |
||
174 | */ |
||
175 | 8 | public function getEndMultiLine() |
|
179 | |||
180 | /** |
||
181 | * Sets the regexp that will match the ending block directives. |
||
182 | * |
||
183 | * @param string $endMultiLine the regexp that will match the ending block directives |
||
184 | */ |
||
185 | 10 | public function setEndMultiLine($endMultiLine) |
|
196 | |||
197 | /** |
||
198 | * Gets the regexp that will match the simple directives. |
||
199 | * |
||
200 | * @return string the regexp that will match the simple directives |
||
201 | */ |
||
202 | 8 | public function getSimpleDirective() |
|
206 | |||
207 | /** |
||
208 | * Sets the regexp that will match the simple directives. |
||
209 | * |
||
210 | * @param string $simpleDirective the regexp that will match the simple directives |
||
211 | */ |
||
212 | 13 | public function setSimpleDirective($simpleDirective) |
|
223 | |||
224 | /** |
||
225 | * Checks if the string matches some criterias. |
||
226 | * |
||
227 | * @param string $string the string to check |
||
228 | * @param string $message1 message if not a string |
||
229 | * @param string $message2 message if not a regexp |
||
230 | * @param bool $subpattern confirms the presence of subpatterns "key" and "value" |
||
231 | * |
||
232 | * @throws ServerException if the string is invalid |
||
233 | * |
||
234 | * @return string the string |
||
235 | */ |
||
236 | 22 | private function checkString($string, $message1, $message2, $subpattern = true) |
|
250 | |||
251 | /** |
||
252 | * Confirms if a matcher is a valid reguler expression. |
||
253 | * |
||
254 | * A directive matcher MUST contain a key and a value named subpattern. |
||
255 | * |
||
256 | * @param string $matcher the matcher to validate |
||
257 | * @param bool $subpattern confirms the presence of subpatterns "key" and "value" |
||
258 | * |
||
259 | * @return bool true if the matcher is valid, false otherwise |
||
260 | */ |
||
261 | 19 | private function isValidRegex($matcher, $subpattern = true) |
|
273 | |||
274 | /** |
||
275 | * Gets the list of binaries that can be run to analyze. |
||
276 | * |
||
277 | * @return array the list of binaries that can be run |
||
278 | */ |
||
279 | 1 | public function getBinaries() |
|
280 | { |
||
281 | 1 | return $this->binaries; |
|
282 | } |
||
283 | |||
284 | /** |
||
285 | * Sets the list of binaries that can be run to analyze. |
||
286 | * |
||
287 | * @param array $binaries list of controlers |
||
288 | */ |
||
289 | 8 | public function setBinaries(array $binaries) |
|
295 | |||
296 | /** |
||
297 | * Sets the parameter string to use to detect version and config file. |
||
298 | * |
||
299 | * @param string $parameter parameter string |
||
300 | */ |
||
301 | 7 | public function setDetectionParameter($parameter = '') |
|
307 | |||
308 | /** |
||
309 | * Gets the ordered list of methods to apply before the config file turns into an array. |
||
310 | * |
||
311 | * @return array the ordered list of methods to apply before convertion |
||
312 | */ |
||
313 | 11 | public function getBeforeMethods() |
|
317 | |||
318 | /** |
||
319 | * Sets the ordered list of methods to apply before the config file turns into an array. |
||
320 | * |
||
321 | * @param array $methods the ordered list of methods to apply before convertion |
||
322 | */ |
||
323 | 13 | public function setBeforeMethods(array $methods) |
|
329 | |||
330 | /** |
||
331 | * Gets the ordered list of methods to apply after the config file has turned into an array. |
||
332 | * |
||
333 | * @return array the ordered list of methods to apply after convertion |
||
334 | */ |
||
335 | 11 | public function getAfterMethods() |
|
339 | |||
340 | /** |
||
341 | * Sets the ordered list of methods to apply after the config file has turned into an array. |
||
342 | * |
||
343 | * @param array $methods the ordered list of methods to apply after convertion |
||
344 | */ |
||
345 | 13 | public function setAfterMethods(array $methods) |
|
351 | } |
||
352 |