@@ -25,34 +25,34 @@ |
||
25 | 25 | */ |
26 | 26 | class ConvertHelper_StorageSizeEnum_Size |
27 | 27 | { |
28 | - /** |
|
29 | - * @var string |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var string |
|
30 | + */ |
|
31 | 31 | protected $name; |
32 | 32 | |
33 | - /** |
|
34 | - * @var int |
|
35 | - */ |
|
33 | + /** |
|
34 | + * @var int |
|
35 | + */ |
|
36 | 36 | protected $base; |
37 | 37 | |
38 | - /** |
|
39 | - * @var int |
|
40 | - */ |
|
38 | + /** |
|
39 | + * @var int |
|
40 | + */ |
|
41 | 41 | protected $exponent; |
42 | 42 | |
43 | - /** |
|
44 | - * @var string |
|
45 | - */ |
|
43 | + /** |
|
44 | + * @var string |
|
45 | + */ |
|
46 | 46 | protected $singular; |
47 | 47 | |
48 | - /** |
|
49 | - * @var string |
|
50 | - */ |
|
48 | + /** |
|
49 | + * @var string |
|
50 | + */ |
|
51 | 51 | protected $plural; |
52 | 52 | |
53 | - /** |
|
54 | - * @var string |
|
55 | - */ |
|
53 | + /** |
|
54 | + * @var string |
|
55 | + */ |
|
56 | 56 | protected $suffix; |
57 | 57 | |
58 | 58 | public function __construct(string $name, int $base, int $exponent, string $suffix, string $singular, string $plural) |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | |
32 | 32 | const VALIDATION_ERROR_NEGATIVE_VALUE = 43803; |
33 | 33 | |
34 | - /** |
|
35 | - * @var string |
|
36 | - */ |
|
34 | + /** |
|
35 | + * @var string |
|
36 | + */ |
|
37 | 37 | protected $sizeString; |
38 | 38 | |
39 | 39 | /** |
@@ -41,41 +41,41 @@ discard block |
||
41 | 41 | */ |
42 | 42 | protected $sizeDefinition; |
43 | 43 | |
44 | - /** |
|
45 | - * @var integer |
|
46 | - */ |
|
44 | + /** |
|
45 | + * @var integer |
|
46 | + */ |
|
47 | 47 | protected $bytes = 0; |
48 | 48 | |
49 | - /** |
|
50 | - * @var bool |
|
51 | - */ |
|
49 | + /** |
|
50 | + * @var bool |
|
51 | + */ |
|
52 | 52 | protected $valid = true; |
53 | 53 | |
54 | - /** |
|
55 | - * @var string |
|
56 | - */ |
|
54 | + /** |
|
55 | + * @var string |
|
56 | + */ |
|
57 | 57 | protected $units = null; |
58 | 58 | |
59 | - /** |
|
60 | - * @var string |
|
61 | - */ |
|
59 | + /** |
|
60 | + * @var string |
|
61 | + */ |
|
62 | 62 | protected $number = ''; |
63 | 63 | |
64 | - /** |
|
65 | - * @var string |
|
66 | - */ |
|
64 | + /** |
|
65 | + * @var string |
|
66 | + */ |
|
67 | 67 | protected $errorMessage = ''; |
68 | 68 | |
69 | - /** |
|
70 | - * @var int |
|
71 | - */ |
|
69 | + /** |
|
70 | + * @var int |
|
71 | + */ |
|
72 | 72 | protected $errorCode = 0; |
73 | 73 | |
74 | - /** |
|
75 | - * Create a new instance for the specified size string. |
|
76 | - * |
|
77 | - * @param string $sizeString A size notation in the format "50 MB", or a number of bytes without units. Spaces are ignored, so "50MB" = "50 MB" = " 50 MB ". Floating point values are accepted, both with dot and comma notation ("50.5" = "50,5"). To use Base 2 values, ose appropriate units, e.g. "50 MiB", "1.5 GiB". The units are case insensitive, so "50 MB" = "50 mb". |
|
78 | - */ |
|
74 | + /** |
|
75 | + * Create a new instance for the specified size string. |
|
76 | + * |
|
77 | + * @param string $sizeString A size notation in the format "50 MB", or a number of bytes without units. Spaces are ignored, so "50MB" = "50 MB" = " 50 MB ". Floating point values are accepted, both with dot and comma notation ("50.5" = "50,5"). To use Base 2 values, ose appropriate units, e.g. "50 MiB", "1.5 GiB". The units are case insensitive, so "50 MB" = "50 mb". |
|
78 | + */ |
|
79 | 79 | public function __construct(string $sizeString) |
80 | 80 | { |
81 | 81 | $this->sizeString = $this->cleanString($sizeString); |
@@ -83,31 +83,31 @@ discard block |
||
83 | 83 | $this->convert(); |
84 | 84 | } |
85 | 85 | |
86 | - /** |
|
87 | - * Gets the amount of bytes contained in the size notation. |
|
88 | - * @return int |
|
89 | - */ |
|
86 | + /** |
|
87 | + * Gets the amount of bytes contained in the size notation. |
|
88 | + * @return int |
|
89 | + */ |
|
90 | 90 | public function toBytes() : int |
91 | 91 | { |
92 | 92 | return $this->bytes; |
93 | 93 | } |
94 | 94 | |
95 | - /** |
|
96 | - * Converts the size notation to a human readable string, e.g. "50 MB". |
|
97 | - * |
|
98 | - * @param int $precision |
|
99 | - * @return string |
|
100 | - * @see ConvertHelper::bytes2readable() |
|
101 | - */ |
|
95 | + /** |
|
96 | + * Converts the size notation to a human readable string, e.g. "50 MB". |
|
97 | + * |
|
98 | + * @param int $precision |
|
99 | + * @return string |
|
100 | + * @see ConvertHelper::bytes2readable() |
|
101 | + */ |
|
102 | 102 | public function toString(int $precision=1) : string |
103 | 103 | { |
104 | 104 | return ConvertHelper::bytes2readable($this->bytes, $precision, $this->getBase()); |
105 | 105 | } |
106 | 106 | |
107 | - /** |
|
108 | - * Retrieves the detected number's base. |
|
109 | - * @return int The base number (1000 for Base 10, or 1024 for Base 2), or 0 if it is not valid. |
|
110 | - */ |
|
107 | + /** |
|
108 | + * Retrieves the detected number's base. |
|
109 | + * @return int The base number (1000 for Base 10, or 1024 for Base 2), or 0 if it is not valid. |
|
110 | + */ |
|
111 | 111 | public function getBase() : int |
112 | 112 | { |
113 | 113 | if($this->isValid()) { |
@@ -117,13 +117,13 @@ discard block |
||
117 | 117 | return 0; |
118 | 118 | } |
119 | 119 | |
120 | - /** |
|
121 | - * Retrieves the detected storage size instance, if |
|
122 | - * the size string is valid. |
|
123 | - * |
|
124 | - * @return ConvertHelper_StorageSizeEnum_Size|NULL |
|
125 | - * @see ConvertHelper_StorageSizeEnum_Size |
|
126 | - */ |
|
120 | + /** |
|
121 | + * Retrieves the detected storage size instance, if |
|
122 | + * the size string is valid. |
|
123 | + * |
|
124 | + * @return ConvertHelper_StorageSizeEnum_Size|NULL |
|
125 | + * @see ConvertHelper_StorageSizeEnum_Size |
|
126 | + */ |
|
127 | 127 | public function getSizeDefinition() : ?ConvertHelper_StorageSizeEnum_Size |
128 | 128 | { |
129 | 129 | if($this->isValid()) { |
@@ -133,27 +133,27 @@ discard block |
||
133 | 133 | return null; |
134 | 134 | } |
135 | 135 | |
136 | - /** |
|
137 | - * Checks whether the size notation was valid and could be parsed |
|
138 | - * into a meaningful byte value. If this returns `false`, it is |
|
139 | - * possible to use the `getErrorXXX` methods to retrieve information |
|
140 | - * on what went wrong. |
|
141 | - * |
|
142 | - * @return bool |
|
143 | - * @see ConvertHelper_SizeNotation::getErrorMessage() |
|
144 | - * @see ConvertHelper_SizeNotation::getErrorCode() |
|
145 | - */ |
|
136 | + /** |
|
137 | + * Checks whether the size notation was valid and could be parsed |
|
138 | + * into a meaningful byte value. If this returns `false`, it is |
|
139 | + * possible to use the `getErrorXXX` methods to retrieve information |
|
140 | + * on what went wrong. |
|
141 | + * |
|
142 | + * @return bool |
|
143 | + * @see ConvertHelper_SizeNotation::getErrorMessage() |
|
144 | + * @see ConvertHelper_SizeNotation::getErrorCode() |
|
145 | + */ |
|
146 | 146 | public function isValid() : bool |
147 | 147 | { |
148 | 148 | return $this->valid; |
149 | 149 | } |
150 | 150 | |
151 | - /** |
|
152 | - * Retrieves the error message if the size notation validation failed. |
|
153 | - * |
|
154 | - * @return string |
|
155 | - * @see ConvertHelper_SizeNotation::getErrorCode() |
|
156 | - */ |
|
151 | + /** |
|
152 | + * Retrieves the error message if the size notation validation failed. |
|
153 | + * |
|
154 | + * @return string |
|
155 | + * @see ConvertHelper_SizeNotation::getErrorCode() |
|
156 | + */ |
|
157 | 157 | public function getErrorMessage() : string |
158 | 158 | { |
159 | 159 | return $this->errorMessage; |
@@ -200,12 +200,12 @@ discard block |
||
200 | 200 | ); |
201 | 201 | } |
202 | 202 | |
203 | - /** |
|
204 | - * Detects the units and the number in the size notation string. |
|
205 | - * Populates the `units` and `number` properties. |
|
206 | - * |
|
207 | - * @return bool Whether the string could be parsed successfully. |
|
208 | - */ |
|
203 | + /** |
|
204 | + * Detects the units and the number in the size notation string. |
|
205 | + * Populates the `units` and `number` properties. |
|
206 | + * |
|
207 | + * @return bool Whether the string could be parsed successfully. |
|
208 | + */ |
|
209 | 209 | protected function detectParts() : bool |
210 | 210 | { |
211 | 211 | $units = ConvertHelper_StorageSizeEnum::getSizeNames(); |
@@ -241,16 +241,16 @@ discard block |
||
241 | 241 | return true; |
242 | 242 | } |
243 | 243 | |
244 | - /** |
|
245 | - * If the validation fails, this is used to store the reason for retrieval later. |
|
246 | - * |
|
247 | - * @param string $message |
|
248 | - * @param int $code |
|
249 | - * |
|
250 | - * @see ConvertHelper_SizeNotation::isValid() |
|
251 | - * @see ConvertHelper_SizeNotation::getErrorMessage() |
|
252 | - * @see ConvertHelper_SizeNotation::getErrorCode() |
|
253 | - */ |
|
244 | + /** |
|
245 | + * If the validation fails, this is used to store the reason for retrieval later. |
|
246 | + * |
|
247 | + * @param string $message |
|
248 | + * @param int $code |
|
249 | + * |
|
250 | + * @see ConvertHelper_SizeNotation::isValid() |
|
251 | + * @see ConvertHelper_SizeNotation::getErrorMessage() |
|
252 | + * @see ConvertHelper_SizeNotation::getErrorCode() |
|
253 | + */ |
|
254 | 254 | protected function setError(string $message, int $code) : void |
255 | 255 | { |
256 | 256 | $this->valid = false; |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | $this->errorCode = $code; |
259 | 259 | } |
260 | 260 | |
261 | - /** |
|
262 | - * Retrieves the error code, if the size notation validation failed. |
|
263 | - * |
|
264 | - * @return int |
|
265 | - * @see ConvertHelper_SizeNotation::getErrorMessage() |
|
266 | - */ |
|
261 | + /** |
|
262 | + * Retrieves the error code, if the size notation validation failed. |
|
263 | + * |
|
264 | + * @return int |
|
265 | + * @see ConvertHelper_SizeNotation::getErrorMessage() |
|
266 | + */ |
|
267 | 267 | public function getErrorCode() : int |
268 | 268 | { |
269 | 269 | return $this->errorCode; |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | */ |
40 | 40 | protected static $instance; |
41 | 41 | |
42 | - /** |
|
43 | - * @var string |
|
44 | - */ |
|
42 | + /** |
|
43 | + * @var string |
|
44 | + */ |
|
45 | 45 | protected $baseURL = ''; |
46 | 46 | |
47 | 47 | public function __construct() |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | $this->init(); |
52 | 52 | } |
53 | 53 | |
54 | - /** |
|
55 | - * Can be extended in a subclass, to avoid |
|
56 | - * redefining the constructor. |
|
57 | - */ |
|
54 | + /** |
|
55 | + * Can be extended in a subclass, to avoid |
|
56 | + * redefining the constructor. |
|
57 | + */ |
|
58 | 58 | protected function init() |
59 | 59 | { |
60 | 60 | |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | return $this->buildURL($params, $dispatcher); |
125 | 125 | } |
126 | 126 | |
127 | - /** |
|
128 | - * Retrieves the name of the current dispatcher script / page. |
|
129 | - * This is made to be extended and implemented in a subclass. |
|
130 | - * |
|
131 | - * @return string |
|
132 | - */ |
|
127 | + /** |
|
128 | + * Retrieves the name of the current dispatcher script / page. |
|
129 | + * This is made to be extended and implemented in a subclass. |
|
130 | + * |
|
131 | + * @return string |
|
132 | + */ |
|
133 | 133 | public function getDispatcher() : string |
134 | 134 | { |
135 | 135 | return ''; |
@@ -198,10 +198,10 @@ discard block |
||
198 | 198 | return $url; |
199 | 199 | } |
200 | 200 | |
201 | - /** |
|
202 | - * Retrieves the base URL of the application. |
|
203 | - * @return string |
|
204 | - */ |
|
201 | + /** |
|
202 | + * Retrieves the base URL of the application. |
|
203 | + * @return string |
|
204 | + */ |
|
205 | 205 | public function getBaseURL() : string |
206 | 206 | { |
207 | 207 | return $this->baseURL; |
@@ -231,13 +231,13 @@ discard block |
||
231 | 231 | return $this->knownParams[$name]; |
232 | 232 | } |
233 | 233 | |
234 | - /** |
|
235 | - * Retrieves a previously registered parameter instance. |
|
236 | - * |
|
237 | - * @param string $name |
|
238 | - * @throws Request_Exception |
|
239 | - * @return Request_Param |
|
240 | - */ |
|
234 | + /** |
|
235 | + * Retrieves a previously registered parameter instance. |
|
236 | + * |
|
237 | + * @param string $name |
|
238 | + * @throws Request_Exception |
|
239 | + * @return Request_Param |
|
240 | + */ |
|
241 | 241 | public function getRegisteredParam(string $name) : Request_Param |
242 | 242 | { |
243 | 243 | if(isset($this->knownParams[$name])) { |
@@ -254,48 +254,48 @@ discard block |
||
254 | 254 | ); |
255 | 255 | } |
256 | 256 | |
257 | - /** |
|
258 | - * Checks whether a parameter with the specified name |
|
259 | - * has been registered. |
|
260 | - * |
|
261 | - * @param string $name |
|
262 | - * @return bool |
|
263 | - */ |
|
257 | + /** |
|
258 | + * Checks whether a parameter with the specified name |
|
259 | + * has been registered. |
|
260 | + * |
|
261 | + * @param string $name |
|
262 | + * @return bool |
|
263 | + */ |
|
264 | 264 | public function hasRegisteredParam(string $name) : bool |
265 | 265 | { |
266 | 266 | return isset($this->knownParams[$name]); |
267 | 267 | } |
268 | 268 | |
269 | - /** |
|
270 | - * Retrieves an indexed array with accept mime types |
|
271 | - * that the client sent, in the order of preference |
|
272 | - * the client specified. |
|
273 | - * |
|
274 | - * Example: |
|
275 | - * |
|
276 | - * array( |
|
277 | - * 'text/html', |
|
278 | - * 'application/xhtml+xml', |
|
279 | - * 'image/webp' |
|
280 | - * ... |
|
281 | - * ) |
|
282 | - * |
|
283 | - * @return array |
|
284 | - * @see Request::parseAcceptHeaders() |
|
285 | - */ |
|
269 | + /** |
|
270 | + * Retrieves an indexed array with accept mime types |
|
271 | + * that the client sent, in the order of preference |
|
272 | + * the client specified. |
|
273 | + * |
|
274 | + * Example: |
|
275 | + * |
|
276 | + * array( |
|
277 | + * 'text/html', |
|
278 | + * 'application/xhtml+xml', |
|
279 | + * 'image/webp' |
|
280 | + * ... |
|
281 | + * ) |
|
282 | + * |
|
283 | + * @return array |
|
284 | + * @see Request::parseAcceptHeaders() |
|
285 | + */ |
|
286 | 286 | public static function getAcceptHeaders() : array |
287 | 287 | { |
288 | 288 | return self::parseAcceptHeaders()->getMimeStrings(); |
289 | 289 | } |
290 | 290 | |
291 | - /** |
|
292 | - * Returns an instance of the accept headers parser, |
|
293 | - * to access information on the browser's accepted |
|
294 | - * mime types. |
|
295 | - * |
|
296 | - * @return Request_AcceptHeaders |
|
297 | - * @see Request::getAcceptHeaders() |
|
298 | - */ |
|
291 | + /** |
|
292 | + * Returns an instance of the accept headers parser, |
|
293 | + * to access information on the browser's accepted |
|
294 | + * mime types. |
|
295 | + * |
|
296 | + * @return Request_AcceptHeaders |
|
297 | + * @see Request::getAcceptHeaders() |
|
298 | + */ |
|
299 | 299 | public static function parseAcceptHeaders() : Request_AcceptHeaders |
300 | 300 | { |
301 | 301 | static $accept; |
@@ -343,14 +343,14 @@ discard block |
||
343 | 343 | return false; |
344 | 344 | } |
345 | 345 | |
346 | - /** |
|
347 | - * Removes a single parameter from the request. |
|
348 | - * If the parameter has been registered, also |
|
349 | - * removes the registration info. |
|
350 | - * |
|
351 | - * @param string $name |
|
352 | - * @return Request |
|
353 | - */ |
|
346 | + /** |
|
347 | + * Removes a single parameter from the request. |
|
348 | + * If the parameter has been registered, also |
|
349 | + * removes the registration info. |
|
350 | + * |
|
351 | + * @param string $name |
|
352 | + * @return Request |
|
353 | + */ |
|
354 | 354 | public function removeParam(string $name) : Request |
355 | 355 | { |
356 | 356 | if(isset($_REQUEST[$name])) { |
@@ -364,12 +364,12 @@ discard block |
||
364 | 364 | return $this; |
365 | 365 | } |
366 | 366 | |
367 | - /** |
|
368 | - * Removes several parameters from the request. |
|
369 | - * |
|
370 | - * @param string[] $names |
|
371 | - * @return Request |
|
372 | - */ |
|
367 | + /** |
|
368 | + * Removes several parameters from the request. |
|
369 | + * |
|
370 | + * @param string[] $names |
|
371 | + * @return Request |
|
372 | + */ |
|
373 | 373 | public function removeParams(array $names) : Request |
374 | 374 | { |
375 | 375 | foreach($names as $name) { |
@@ -434,18 +434,18 @@ discard block |
||
434 | 434 | return $val; |
435 | 435 | } |
436 | 436 | |
437 | - /** |
|
438 | - * Treats the request parameter as a JSON string, and |
|
439 | - * if it exists and contains valid JSON, returns the |
|
440 | - * decoded JSON value as an array (default). |
|
441 | - * |
|
442 | - * @param string $name |
|
443 | - * @param bool $assoc |
|
444 | - * @return array|object |
|
445 | - * |
|
446 | - * @see Request::getJSONAssoc() |
|
447 | - * @see Request::getJSONObject() |
|
448 | - */ |
|
437 | + /** |
|
438 | + * Treats the request parameter as a JSON string, and |
|
439 | + * if it exists and contains valid JSON, returns the |
|
440 | + * decoded JSON value as an array (default). |
|
441 | + * |
|
442 | + * @param string $name |
|
443 | + * @param bool $assoc |
|
444 | + * @return array|object |
|
445 | + * |
|
446 | + * @see Request::getJSONAssoc() |
|
447 | + * @see Request::getJSONObject() |
|
448 | + */ |
|
449 | 449 | public function getJSON(string $name, bool $assoc=true) |
450 | 450 | { |
451 | 451 | $value = $this->getParam($name); |
@@ -470,13 +470,13 @@ discard block |
||
470 | 470 | return new \stdClass(); |
471 | 471 | } |
472 | 472 | |
473 | - /** |
|
474 | - * Like {@link Request::getJSON()}, but omitting the second |
|
475 | - * parameter. Use this for more readable code. |
|
476 | - * |
|
477 | - * @param string $name |
|
478 | - * @return array |
|
479 | - */ |
|
473 | + /** |
|
474 | + * Like {@link Request::getJSON()}, but omitting the second |
|
475 | + * parameter. Use this for more readable code. |
|
476 | + * |
|
477 | + * @param string $name |
|
478 | + * @return array |
|
479 | + */ |
|
480 | 480 | public function getJSONAssoc(string $name) : array |
481 | 481 | { |
482 | 482 | $result = $this->getJSON($name); |
@@ -487,13 +487,13 @@ discard block |
||
487 | 487 | return array(); |
488 | 488 | } |
489 | 489 | |
490 | - /** |
|
491 | - * Like {@link Request::getJSON()}, but omitting the second |
|
492 | - * parameter. Use this for more readable code. |
|
493 | - * |
|
494 | - * @param string $name |
|
495 | - * @return object |
|
496 | - */ |
|
490 | + /** |
|
491 | + * Like {@link Request::getJSON()}, but omitting the second |
|
492 | + * parameter. Use this for more readable code. |
|
493 | + * |
|
494 | + * @param string $name |
|
495 | + * @return object |
|
496 | + */ |
|
497 | 497 | public function getJSONObject(string $name) : object |
498 | 498 | { |
499 | 499 | $result = $this->getJSON($name, false); |
@@ -504,12 +504,12 @@ discard block |
||
504 | 504 | return new \stdClass(); |
505 | 505 | } |
506 | 506 | |
507 | - /** |
|
508 | - * Sends a JSON response with the correct headers. |
|
509 | - * |
|
510 | - * @param array|string $data |
|
511 | - * @param bool $exit Whether to exit the script afterwards. |
|
512 | - */ |
|
507 | + /** |
|
508 | + * Sends a JSON response with the correct headers. |
|
509 | + * |
|
510 | + * @param array|string $data |
|
511 | + * @param bool $exit Whether to exit the script afterwards. |
|
512 | + */ |
|
513 | 513 | public static function sendJSON($data, bool $exit=true) |
514 | 514 | { |
515 | 515 | $payload = $data; |
@@ -529,12 +529,12 @@ discard block |
||
529 | 529 | } |
530 | 530 | } |
531 | 531 | |
532 | - /** |
|
533 | - * Sends HTML to the browser with the correct headers. |
|
534 | - * |
|
535 | - * @param string $html |
|
536 | - * @param bool $exit Whether to exit the script afterwards. |
|
537 | - */ |
|
532 | + /** |
|
533 | + * Sends HTML to the browser with the correct headers. |
|
534 | + * |
|
535 | + * @param string $html |
|
536 | + * @param bool $exit Whether to exit the script afterwards. |
|
537 | + */ |
|
538 | 538 | public static function sendHTML(string $html, bool $exit=true) |
539 | 539 | { |
540 | 540 | header('Cache-Control: no-cache, must-revalidate'); |
@@ -549,16 +549,16 @@ discard block |
||
549 | 549 | } |
550 | 550 | } |
551 | 551 | |
552 | - /** |
|
553 | - * Creates a new instance of the URL comparer, which can check |
|
554 | - * whether the specified URLs match, regardless of the order in |
|
555 | - * which the query parameters are, if any. |
|
556 | - * |
|
557 | - * @param string $sourceURL |
|
558 | - * @param string $targetURL |
|
559 | - * @param array $limitParams Whether to limit the comparison to these specific parameter names (if present) |
|
560 | - * @return Request_URLComparer |
|
561 | - */ |
|
552 | + /** |
|
553 | + * Creates a new instance of the URL comparer, which can check |
|
554 | + * whether the specified URLs match, regardless of the order in |
|
555 | + * which the query parameters are, if any. |
|
556 | + * |
|
557 | + * @param string $sourceURL |
|
558 | + * @param string $targetURL |
|
559 | + * @param array $limitParams Whether to limit the comparison to these specific parameter names (if present) |
|
560 | + * @return Request_URLComparer |
|
561 | + */ |
|
562 | 562 | public function createURLComparer(string $sourceURL, string $targetURL, array $limitParams=array()) : Request_URLComparer |
563 | 563 | { |
564 | 564 | $comparer = new Request_URLComparer($this, $sourceURL, $targetURL); |
@@ -567,10 +567,10 @@ discard block |
||
567 | 567 | return $comparer; |
568 | 568 | } |
569 | 569 | |
570 | - /** |
|
571 | - * Retrieves the full URL that was used to access the current page. |
|
572 | - * @return string |
|
573 | - */ |
|
570 | + /** |
|
571 | + * Retrieves the full URL that was used to access the current page. |
|
572 | + * @return string |
|
573 | + */ |
|
574 | 574 | public function getCurrentURL() : string |
575 | 575 | { |
576 | 576 | return $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
@@ -28,20 +28,20 @@ discard block |
||
28 | 28 | $this->parse(); |
29 | 29 | } |
30 | 30 | |
31 | - /** |
|
32 | - * Retrieves an indexed array with accept mime types |
|
33 | - * that the client sent, in the order of preference |
|
34 | - * the client specified. |
|
35 | - * |
|
36 | - * Example: |
|
37 | - * |
|
38 | - * array( |
|
39 | - * 'text/html', |
|
40 | - * 'application/xhtml+xml', |
|
41 | - * 'image/webp' |
|
42 | - * ... |
|
43 | - * ) |
|
44 | - */ |
|
31 | + /** |
|
32 | + * Retrieves an indexed array with accept mime types |
|
33 | + * that the client sent, in the order of preference |
|
34 | + * the client specified. |
|
35 | + * |
|
36 | + * Example: |
|
37 | + * |
|
38 | + * array( |
|
39 | + * 'text/html', |
|
40 | + * 'application/xhtml+xml', |
|
41 | + * 'image/webp' |
|
42 | + * ... |
|
43 | + * ) |
|
44 | + */ |
|
45 | 45 | public function getMimeStrings() : array |
46 | 46 | { |
47 | 47 | $result = array(); |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | return $result; |
55 | 55 | } |
56 | 56 | |
57 | - /** |
|
58 | - * Checks that an accept header string exists, and tries to parse it. |
|
59 | - */ |
|
57 | + /** |
|
58 | + * Checks that an accept header string exists, and tries to parse it. |
|
59 | + */ |
|
60 | 60 | protected function parse() : void |
61 | 61 | { |
62 | 62 | // we may be in a CLI environment where the headers |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | $this->headers = $this->parseHeader($_SERVER['HTTP_ACCEPT']); |
69 | 69 | } |
70 | 70 | |
71 | - /** |
|
72 | - * Splits the accept header string and parses the mime types. |
|
73 | - * |
|
74 | - * @param string $acceptHeader |
|
75 | - */ |
|
71 | + /** |
|
72 | + * Splits the accept header string and parses the mime types. |
|
73 | + * |
|
74 | + * @param string $acceptHeader |
|
75 | + */ |
|
76 | 76 | protected function parseHeader(string $acceptHeader) : array |
77 | 77 | { |
78 | 78 | $tokens = preg_split('/\s*,\s*/', $acceptHeader); |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | return $accept; |
90 | 90 | } |
91 | 91 | |
92 | - /** |
|
93 | - * Parses a single mime type entry. |
|
94 | - * |
|
95 | - * @param int $i The position in the accept string |
|
96 | - * @param string $mime The mime type |
|
97 | - * @return array |
|
98 | - */ |
|
92 | + /** |
|
93 | + * Parses a single mime type entry. |
|
94 | + * |
|
95 | + * @param int $i The position in the accept string |
|
96 | + * @param string $mime The mime type |
|
97 | + * @return array |
|
98 | + */ |
|
99 | 99 | protected function parseEntry(int $i, string $mime) : array |
100 | 100 | { |
101 | 101 | $entry = array( |
@@ -125,14 +125,14 @@ discard block |
||
125 | 125 | return $entry; |
126 | 126 | } |
127 | 127 | |
128 | - /** |
|
129 | - * Sorts the mime types collection, first by quality |
|
130 | - * and then by position in the list. |
|
131 | - * |
|
132 | - * @param array $a |
|
133 | - * @param array $b |
|
134 | - * @return number |
|
135 | - */ |
|
128 | + /** |
|
129 | + * Sorts the mime types collection, first by quality |
|
130 | + * and then by position in the list. |
|
131 | + * |
|
132 | + * @param array $a |
|
133 | + * @param array $b |
|
134 | + * @return number |
|
135 | + */ |
|
136 | 136 | protected function sortMimeTypes(array $a, array $b) |
137 | 137 | { |
138 | 138 | /* first tier: highest q factor wins */ |
@@ -22,9 +22,9 @@ |
||
22 | 22 | { |
23 | 23 | use Traits_Optionable; |
24 | 24 | |
25 | - /** |
|
26 | - * @var Request_Param |
|
27 | - */ |
|
25 | + /** |
|
26 | + * @var Request_Param |
|
27 | + */ |
|
28 | 28 | protected $param; |
29 | 29 | |
30 | 30 | protected $value; |
@@ -6,9 +6,9 @@ |
||
6 | 6 | |
7 | 7 | abstract class VariableInfo_Renderer_String extends VariableInfo_Renderer |
8 | 8 | { |
9 | - /** |
|
10 | - * @var mixed |
|
11 | - */ |
|
9 | + /** |
|
10 | + * @var mixed |
|
11 | + */ |
|
12 | 12 | protected $value; |
13 | 13 | |
14 | 14 | protected function init() |
@@ -6,19 +6,19 @@ discard block |
||
6 | 6 | |
7 | 7 | abstract class VariableInfo_Renderer |
8 | 8 | { |
9 | - /** |
|
10 | - * @var mixed |
|
11 | - */ |
|
9 | + /** |
|
10 | + * @var mixed |
|
11 | + */ |
|
12 | 12 | protected $value; |
13 | 13 | |
14 | - /** |
|
15 | - * @var VariableInfo |
|
16 | - */ |
|
14 | + /** |
|
15 | + * @var VariableInfo |
|
16 | + */ |
|
17 | 17 | protected $info; |
18 | 18 | |
19 | - /** |
|
20 | - * @var string |
|
21 | - */ |
|
19 | + /** |
|
20 | + * @var string |
|
21 | + */ |
|
22 | 22 | protected $type; |
23 | 23 | |
24 | 24 | public function __construct(VariableInfo $info) |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | |
32 | 32 | abstract protected function init(); |
33 | 33 | |
34 | - /** |
|
35 | - * Renders the value to the target format. |
|
36 | - * |
|
37 | - * @return mixed |
|
38 | - */ |
|
34 | + /** |
|
35 | + * Renders the value to the target format. |
|
36 | + * |
|
37 | + * @return mixed |
|
38 | + */ |
|
39 | 39 | public function render() |
40 | 40 | { |
41 | 41 | return $this->_render(); |
@@ -19,25 +19,25 @@ discard block |
||
19 | 19 | const TYPE_UNKNOWN = 'unknown type'; |
20 | 20 | const TYPE_CALLABLE = 'callable'; |
21 | 21 | |
22 | - /** |
|
23 | - * @var string |
|
24 | - */ |
|
22 | + /** |
|
23 | + * @var string |
|
24 | + */ |
|
25 | 25 | protected $string; |
26 | 26 | |
27 | - /** |
|
28 | - * @var mixed |
|
29 | - */ |
|
27 | + /** |
|
28 | + * @var mixed |
|
29 | + */ |
|
30 | 30 | protected $value; |
31 | 31 | |
32 | - /** |
|
33 | - * @var string |
|
34 | - */ |
|
32 | + /** |
|
33 | + * @var string |
|
34 | + */ |
|
35 | 35 | protected $type; |
36 | 36 | |
37 | - /** |
|
38 | - * @param mixed $value |
|
39 | - * @param array|null $serialized |
|
40 | - */ |
|
37 | + /** |
|
38 | + * @param mixed $value |
|
39 | + * @param array|null $serialized |
|
40 | + */ |
|
41 | 41 | public function __construct($value, $serialized=null) |
42 | 42 | { |
43 | 43 | if(is_array($serialized)) |
@@ -50,26 +50,26 @@ discard block |
||
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | - /** |
|
54 | - * Creates a new variable info instance from a PHP variable |
|
55 | - * of any type. |
|
56 | - * |
|
57 | - * @param mixed $variable |
|
58 | - * @return VariableInfo |
|
59 | - */ |
|
53 | + /** |
|
54 | + * Creates a new variable info instance from a PHP variable |
|
55 | + * of any type. |
|
56 | + * |
|
57 | + * @param mixed $variable |
|
58 | + * @return VariableInfo |
|
59 | + */ |
|
60 | 60 | public static function fromVariable($variable) : VariableInfo |
61 | 61 | { |
62 | 62 | return new VariableInfo($variable); |
63 | 63 | } |
64 | 64 | |
65 | - /** |
|
66 | - * Restores a variable info instance using a previously serialized |
|
67 | - * array using the serialize() method. |
|
68 | - * |
|
69 | - * @param array $serialized |
|
70 | - * @return VariableInfo |
|
71 | - * @see VariableInfo::serialize() |
|
72 | - */ |
|
65 | + /** |
|
66 | + * Restores a variable info instance using a previously serialized |
|
67 | + * array using the serialize() method. |
|
68 | + * |
|
69 | + * @param array $serialized |
|
70 | + * @return VariableInfo |
|
71 | + * @see VariableInfo::serialize() |
|
72 | + */ |
|
73 | 73 | public static function fromSerialized(array $serialized) : VariableInfo |
74 | 74 | { |
75 | 75 | return new VariableInfo(null, $serialized); |
@@ -100,12 +100,12 @@ discard block |
||
100 | 100 | return $this->value; |
101 | 101 | } |
102 | 102 | |
103 | - /** |
|
104 | - * The variable type - this is the same string that |
|
105 | - * is returned by the PHP function `gettype`. |
|
106 | - * |
|
107 | - * @return string |
|
108 | - */ |
|
103 | + /** |
|
104 | + * The variable type - this is the same string that |
|
105 | + * is returned by the PHP function `gettype`. |
|
106 | + * |
|
107 | + * @return string |
|
108 | + */ |
|
109 | 109 | public function getType() : string |
110 | 110 | { |
111 | 111 | return $this->type; |
@@ -119,13 +119,13 @@ discard block |
||
119 | 119 | ); |
120 | 120 | } |
121 | 121 | |
122 | - /** |
|
123 | - * Whether to prepend the variable type before the value, |
|
124 | - * like the var_dump function. Example: <code>string "Some text"</code>. |
|
125 | - * |
|
126 | - * @param bool $enable |
|
127 | - * @return VariableInfo |
|
128 | - */ |
|
122 | + /** |
|
123 | + * Whether to prepend the variable type before the value, |
|
124 | + * like the var_dump function. Example: <code>string "Some text"</code>. |
|
125 | + * |
|
126 | + * @param bool $enable |
|
127 | + * @return VariableInfo |
|
128 | + */ |
|
129 | 129 | public function enableType(bool $enable=true) : VariableInfo |
130 | 130 | { |
131 | 131 | return $this->setOption('prepend-type', $enable); |
@@ -21,25 +21,25 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class XMLHelper_Converter_Decorator implements \JsonSerializable |
23 | 23 | { |
24 | - /** |
|
25 | - * @var \SimpleXMLElement |
|
26 | - */ |
|
24 | + /** |
|
25 | + * @var \SimpleXMLElement |
|
26 | + */ |
|
27 | 27 | private $subject; |
28 | 28 | |
29 | 29 | const DEF_DEPTH = 512; |
30 | 30 | |
31 | - /** |
|
32 | - * @var array |
|
33 | - */ |
|
31 | + /** |
|
32 | + * @var array |
|
33 | + */ |
|
34 | 34 | private $options = array( |
35 | 35 | '@attributes' => true, |
36 | 36 | '@text' => true, |
37 | 37 | 'depth' => self::DEF_DEPTH |
38 | 38 | ); |
39 | 39 | |
40 | - /** |
|
41 | - * @var array|string|null |
|
42 | - */ |
|
40 | + /** |
|
41 | + * @var array|string|null |
|
42 | + */ |
|
43 | 43 | protected $result = array(); |
44 | 44 | |
45 | 45 | public function __construct(\SimpleXMLElement $element) |
@@ -47,36 +47,36 @@ discard block |
||
47 | 47 | $this->subject = $element; |
48 | 48 | } |
49 | 49 | |
50 | - /** |
|
51 | - * Whether to use the `@attributes` key to store element attributes. |
|
52 | - * |
|
53 | - * @param bool $bool |
|
54 | - * @return XMLHelper_Converter_Decorator |
|
55 | - */ |
|
50 | + /** |
|
51 | + * Whether to use the `@attributes` key to store element attributes. |
|
52 | + * |
|
53 | + * @param bool $bool |
|
54 | + * @return XMLHelper_Converter_Decorator |
|
55 | + */ |
|
56 | 56 | public function useAttributes(bool $bool) : XMLHelper_Converter_Decorator |
57 | 57 | { |
58 | 58 | $this->options['@attributes'] = (bool)$bool; |
59 | 59 | return $this; |
60 | 60 | } |
61 | 61 | |
62 | - /** |
|
63 | - * Whether to use the `@text` key to store the node text. |
|
64 | - * |
|
65 | - * @param bool $bool |
|
66 | - * @return XMLHelper_Converter_Decorator |
|
67 | - */ |
|
62 | + /** |
|
63 | + * Whether to use the `@text` key to store the node text. |
|
64 | + * |
|
65 | + * @param bool $bool |
|
66 | + * @return XMLHelper_Converter_Decorator |
|
67 | + */ |
|
68 | 68 | public function useText(bool $bool) : XMLHelper_Converter_Decorator |
69 | 69 | { |
70 | 70 | $this->options['@text'] = (bool)$bool; |
71 | 71 | return $this; |
72 | 72 | } |
73 | 73 | |
74 | - /** |
|
75 | - * Set the maximum depth to parse in the document. |
|
76 | - * |
|
77 | - * @param int $depth |
|
78 | - * @return XMLHelper_Converter_Decorator |
|
79 | - */ |
|
74 | + /** |
|
75 | + * Set the maximum depth to parse in the document. |
|
76 | + * |
|
77 | + * @param int $depth |
|
78 | + * @return XMLHelper_Converter_Decorator |
|
79 | + */ |
|
80 | 80 | public function setDepth(int $depth) : XMLHelper_Converter_Decorator |
81 | 81 | { |
82 | 82 | $this->options['depth'] = (int)max(0, $depth); |