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 | * Confirms if the server instance has valid parameters. |
||
61 | * |
||
62 | * @return bool true if all parameters are initialized, false otherwise |
||
63 | */ |
||
64 | 2 | public function isValid() |
|
73 | |||
74 | /** |
||
75 | * Getter for the prefix. |
||
76 | * |
||
77 | * @return string the filesystem path where the web server is installed |
||
78 | */ |
||
79 | 2 | public function getPrefix() |
|
83 | |||
84 | /** |
||
85 | * Sets the prefix of a server isntance. |
||
86 | * |
||
87 | * @throws ServerException if the prefix is invalid |
||
88 | * |
||
89 | * @param string $prefix the filesystem path where the web server is installed |
||
90 | */ |
||
91 | 11 | public function setPrefix($prefix) |
|
114 | |||
115 | /** |
||
116 | * Gets the regexp that will match the starting block directives. |
||
117 | * |
||
118 | * @return string the regexp that will match the starting block directives |
||
119 | */ |
||
120 | 1 | public function getStartMultiLine() |
|
124 | |||
125 | /** |
||
126 | * Sets the regexp that will match the starting block directives. |
||
127 | * |
||
128 | * @param string $startMultiLine the regexp that will match the starting block directives |
||
129 | */ |
||
130 | 6 | public function setStartMultiLine($startMultiLine) |
|
141 | |||
142 | /** |
||
143 | * Gets the regexp that will match the ending block directives. |
||
144 | * |
||
145 | * @return string the regexp that will match the ending block directives |
||
146 | */ |
||
147 | 1 | public function getEndMultiLine() |
|
151 | |||
152 | /** |
||
153 | * Sets the regexp that will match the ending block directives. |
||
154 | * |
||
155 | * @param string $endMultiLine the regexp that will match the ending block directives |
||
156 | */ |
||
157 | 3 | public function setEndMultiLine($endMultiLine) |
|
168 | |||
169 | /** |
||
170 | * Gets the regexp that will match the simple directives. |
||
171 | * |
||
172 | * @return string the regexp that will match the simple directives |
||
173 | */ |
||
174 | 1 | public function getSimpleDirective() |
|
178 | |||
179 | /** |
||
180 | * Sets the regexp that will match the simple directives. |
||
181 | * |
||
182 | * @param string $simpleDirective the regexp that will match the simple directives |
||
183 | */ |
||
184 | 6 | public function setSimpleDirective($simpleDirective) |
|
195 | |||
196 | /** |
||
197 | * Checks if the string matches some criterias. |
||
198 | * |
||
199 | * @param string $string the string to check |
||
200 | * @param string $message1 message if not a string |
||
201 | * @param string $message2 message if not a regexp |
||
202 | * @param bool $subpattern confirms the presence of subpatterns "key" and "value" |
||
203 | * |
||
204 | * @throws ServerException if the string is invalid |
||
205 | * |
||
206 | * @return string the string |
||
207 | */ |
||
208 | 15 | private function checkString($string, $message1, $message2, $subpattern = true) |
|
222 | |||
223 | /** |
||
224 | * Confirms if a matcher is a valid reguler expression. |
||
225 | * |
||
226 | * A directive matcher MUST contain a key and a value named subpattern. |
||
227 | * |
||
228 | * @param string $matcher the matcher to validate |
||
229 | * @param bool $subpattern confirms the presence of subpatterns "key" and "value" |
||
230 | * |
||
231 | * @return bool true if the matcher is valid, false otherwise |
||
232 | */ |
||
233 | 12 | private function isValidRegex($matcher, $subpattern = true) |
|
245 | } |
||
246 |