1 | <?php |
||
21 | class Server implements ServerInterface |
||
22 | { |
||
23 | /** |
||
24 | * a Checker instance. |
||
25 | * |
||
26 | * @var \WebHelper\Parser\Parser\Checker |
||
27 | */ |
||
28 | private $checker; |
||
29 | |||
30 | /** |
||
31 | * The filesystem path where the web server is installed. |
||
32 | * |
||
33 | * It has to be an absolute path. |
||
34 | * |
||
35 | * Apache httpd server does not accept a relative prefix path at compilation. |
||
36 | * Nginx does, but this is a very risky practice... |
||
37 | * So relative prefix path in nginx configuration will not be considered |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | private $prefix = ''; |
||
42 | |||
43 | /** |
||
44 | * The string to match as a starting multi-line directive. |
||
45 | * |
||
46 | * @var string |
||
47 | */ |
||
48 | private $startMultiLine = ''; |
||
49 | |||
50 | /** |
||
51 | * The string to match as an ending multi-line directive. |
||
52 | * |
||
53 | * @var string |
||
54 | */ |
||
55 | private $endMultiLine = ''; |
||
56 | |||
57 | /** |
||
58 | * The string to match a simple directive. |
||
59 | * |
||
60 | * @var string |
||
61 | */ |
||
62 | private $simpleDirective = ''; |
||
63 | |||
64 | /** |
||
65 | * binaries that can be used to control the webserver. |
||
66 | * |
||
67 | * @var array |
||
68 | */ |
||
69 | private $binaries = []; |
||
70 | |||
71 | /** |
||
72 | * the parameter string to use to detect version and config file. |
||
73 | * |
||
74 | * @var string |
||
75 | */ |
||
76 | private $detectionParameter = ''; |
||
77 | |||
78 | /** |
||
79 | * The ordered list of methods to apply before convertion. |
||
80 | * |
||
81 | * @var array |
||
82 | */ |
||
83 | private $beforeMethods = []; |
||
84 | |||
85 | /** |
||
86 | * The ordered list of methods to apply after convertion. |
||
87 | * |
||
88 | * @var array |
||
89 | */ |
||
90 | private $afterMethods = []; |
||
91 | |||
92 | /** |
||
93 | * Sets the Checker instance. |
||
94 | * |
||
95 | * @param Checker $checker a Checker instance |
||
96 | */ |
||
97 | 29 | public function setChecker(Checker $checker) |
|
103 | |||
104 | /** |
||
105 | * Confirms if the server instance has valid parameters. |
||
106 | * |
||
107 | * @return bool true if all parameters are initialized, false otherwise |
||
108 | */ |
||
109 | 2 | public function isValid() |
|
118 | |||
119 | /** |
||
120 | * Getter for the prefix. |
||
121 | * |
||
122 | * @return string the filesystem path where the web server is installed |
||
123 | */ |
||
124 | 2 | public function getPrefix() |
|
128 | |||
129 | /** |
||
130 | * Sets the prefix of a server instance. |
||
131 | * |
||
132 | * @throws ServerException if the prefix is invalid |
||
133 | * |
||
134 | * @param string $prefix the filesystem path where the web server is installed |
||
135 | */ |
||
136 | 11 | public function setPrefix($prefix) |
|
153 | |||
154 | /** |
||
155 | * Gets the regexp that will match the starting block directives. |
||
156 | * |
||
157 | * @return string the regexp that will match the starting block directives |
||
158 | */ |
||
159 | 8 | public function getStartMultiLine() |
|
163 | |||
164 | /** |
||
165 | * Sets the regexp that will match the starting block directives. |
||
166 | * |
||
167 | * @param string $startMultiLine the regexp that will match the starting block directives |
||
168 | */ |
||
169 | 13 | public function setStartMultiLine($startMultiLine) |
|
182 | |||
183 | /** |
||
184 | * Gets the regexp that will match the ending block directives. |
||
185 | * |
||
186 | * @return string the regexp that will match the ending block directives |
||
187 | */ |
||
188 | 8 | public function getEndMultiLine() |
|
192 | |||
193 | /** |
||
194 | * Sets the regexp that will match the ending block directives. |
||
195 | * |
||
196 | * @param string $endMultiLine the regexp that will match the ending block directives |
||
197 | */ |
||
198 | 10 | public function setEndMultiLine($endMultiLine) |
|
218 | |||
219 | /** |
||
220 | * Gets the regexp that will match the simple directives. |
||
221 | * |
||
222 | * @return string the regexp that will match the simple directives |
||
223 | */ |
||
224 | 8 | public function getSimpleDirective() |
|
228 | |||
229 | /** |
||
230 | * Sets the regexp that will match the simple directives. |
||
231 | * |
||
232 | * @param string $simpleDirective the regexp that will match the simple directives |
||
233 | */ |
||
234 | 13 | public function setSimpleDirective($simpleDirective) |
|
247 | |||
248 | /** |
||
249 | * Confirms if a directive matcher is a valid regex. |
||
250 | * |
||
251 | * @param string $directive the directive matcher to check |
||
252 | * @param string $message1 message exception if the matcher is not a string |
||
253 | * @param string $message2 message exception if the matcher is not a valid regex |
||
254 | * |
||
255 | * @throws ServerException if the directive matcher is invalid |
||
256 | * |
||
257 | * @return bool true if the directive matcher is valid |
||
258 | */ |
||
259 | 19 | private function isValidDirective($directive, $message1, $message2) |
|
277 | |||
278 | /** |
||
279 | * Gets the list of binaries that can be run to analyze. |
||
280 | * |
||
281 | * @return array the list of binaries that can be run |
||
282 | */ |
||
283 | 1 | public function getBinaries() |
|
287 | |||
288 | /** |
||
289 | * Sets the list of binaries that can be run to analyze. |
||
290 | * |
||
291 | * @param array $binaries list of controlers |
||
292 | */ |
||
293 | 8 | public function setBinaries(array $binaries) |
|
299 | |||
300 | /** |
||
301 | * Sets the parameter string to use to detect version and config file. |
||
302 | * |
||
303 | * @param string $parameter parameter string |
||
304 | */ |
||
305 | 7 | public function setDetectionParameter($parameter = '') |
|
311 | |||
312 | /** |
||
313 | * Gets the ordered list of methods to apply before the config file turns into an array. |
||
314 | * |
||
315 | * @return array the ordered list of methods to apply before convertion |
||
316 | */ |
||
317 | 11 | public function getBeforeMethods() |
|
321 | |||
322 | /** |
||
323 | * Sets the ordered list of methods to apply before the config file turns into an array. |
||
324 | * |
||
325 | * @param array $methods the ordered list of methods to apply before convertion |
||
326 | */ |
||
327 | 13 | public function setBeforeMethods(array $methods) |
|
333 | |||
334 | /** |
||
335 | * Gets the ordered list of methods to apply after the config file has turned into an array. |
||
336 | * |
||
337 | * @return array the ordered list of methods to apply after convertion |
||
338 | */ |
||
339 | 11 | public function getAfterMethods() |
|
343 | |||
344 | /** |
||
345 | * Sets the ordered list of methods to apply after the config file has turned into an array. |
||
346 | * |
||
347 | * @param array $methods the ordered list of methods to apply after convertion |
||
348 | */ |
||
349 | 13 | public function setAfterMethods(array $methods) |
|
355 | } |
||
356 |