@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | ) |
| 70 | 70 | ); |
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * @var array |
|
| 74 | - */ |
|
| 72 | + /** |
|
| 73 | + * @var array |
|
| 74 | + */ |
|
| 75 | 75 | protected $selected = array(); |
| 76 | 76 | |
| 77 | 77 | public function convert(string $string) : string |
@@ -81,16 +81,16 @@ discard block |
||
| 81 | 81 | return str_replace(array_keys($chars), array_values($chars), $string); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * Selects a character set to replace. Can be called |
|
| 86 | - * several times to add additional sets to the collection. |
|
| 87 | - * |
|
| 88 | - * @param string $type See the <code>CHAR_XXX</code> constants. |
|
| 89 | - * @return ConvertHelper_HiddenConverter |
|
| 90 | - * |
|
| 91 | - * @see ConvertHelper_HiddenConverter::CHARS_CONTROL |
|
| 92 | - * @see ConvertHelper_HiddenConverter::CHARS_WHITESPACE |
|
| 93 | - */ |
|
| 84 | + /** |
|
| 85 | + * Selects a character set to replace. Can be called |
|
| 86 | + * several times to add additional sets to the collection. |
|
| 87 | + * |
|
| 88 | + * @param string $type See the <code>CHAR_XXX</code> constants. |
|
| 89 | + * @return ConvertHelper_HiddenConverter |
|
| 90 | + * |
|
| 91 | + * @see ConvertHelper_HiddenConverter::CHARS_CONTROL |
|
| 92 | + * @see ConvertHelper_HiddenConverter::CHARS_WHITESPACE |
|
| 93 | + */ |
|
| 94 | 94 | public function selectCharacters(string $type) : ConvertHelper_HiddenConverter |
| 95 | 95 | { |
| 96 | 96 | if(!in_array($type, $this->selected)) { |
@@ -100,11 +100,11 @@ discard block |
||
| 100 | 100 | return $this; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * Resolves the list of characters to make visible. |
|
| 105 | - * |
|
| 106 | - * @return array |
|
| 107 | - */ |
|
| 103 | + /** |
|
| 104 | + * Resolves the list of characters to make visible. |
|
| 105 | + * |
|
| 106 | + * @return array |
|
| 107 | + */ |
|
| 108 | 108 | protected function resolveSelection() : array |
| 109 | 109 | { |
| 110 | 110 | $selected = $this->selected; |
@@ -27,14 +27,14 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | protected $param; |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @var mixed |
|
| 32 | - */ |
|
| 30 | + /** |
|
| 31 | + * @var mixed |
|
| 32 | + */ |
|
| 33 | 33 | protected $value; |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var bool |
|
| 37 | - */ |
|
| 35 | + /** |
|
| 36 | + * @var bool |
|
| 37 | + */ |
|
| 38 | 38 | protected $isSubvalue = false; |
| 39 | 39 | |
| 40 | 40 | public function __construct(Request_Param $param, bool $subval) |
@@ -114,18 +114,18 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - /** |
|
| 118 | - * Adds a callback as a validation method. The callback gets the |
|
| 119 | - * value to validate as first parameter, and any additional |
|
| 120 | - * parameters passed here get appended to that. |
|
| 121 | - * |
|
| 122 | - * The callback must return boolean true or false depending on |
|
| 123 | - * whether the value is valid. |
|
| 124 | - * |
|
| 125 | - * @param callable $callback |
|
| 126 | - * @param array $args |
|
| 127 | - * @return Request_Param |
|
| 128 | - */ |
|
| 117 | + /** |
|
| 118 | + * Adds a callback as a validation method. The callback gets the |
|
| 119 | + * value to validate as first parameter, and any additional |
|
| 120 | + * parameters passed here get appended to that. |
|
| 121 | + * |
|
| 122 | + * The callback must return boolean true or false depending on |
|
| 123 | + * whether the value is valid. |
|
| 124 | + * |
|
| 125 | + * @param callable $callback |
|
| 126 | + * @param array $args |
|
| 127 | + * @return Request_Param |
|
| 128 | + */ |
|
| 129 | 129 | public function setCallback($callback, array $args=array()) : Request_Param |
| 130 | 130 | { |
| 131 | 131 | if(!is_callable($callback)) { |
@@ -189,12 +189,12 @@ discard block |
||
| 189 | 189 | return $value; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - /** |
|
| 193 | - * Runs the value through all validations that were added. |
|
| 194 | - * |
|
| 195 | - * @param mixed $value |
|
| 196 | - * @return mixed |
|
| 197 | - */ |
|
| 192 | + /** |
|
| 193 | + * Runs the value through all validations that were added. |
|
| 194 | + * |
|
| 195 | + * @param mixed $value |
|
| 196 | + * @return mixed |
|
| 197 | + */ |
|
| 198 | 198 | protected function applyValidations($value, bool $subval=false) |
| 199 | 199 | { |
| 200 | 200 | // go through all enqueued validations in turn, each time |
@@ -207,17 +207,17 @@ discard block |
||
| 207 | 207 | return $value; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - /** |
|
| 211 | - * Validates the specified value using the validation type. Returns |
|
| 212 | - * the validated value. |
|
| 213 | - * |
|
| 214 | - * @param mixed $value |
|
| 215 | - * @param string $type |
|
| 216 | - * @param array $params |
|
| 217 | - * @param bool $subval Whether this is a subvalue in a list |
|
| 218 | - * @throws Request_Exception |
|
| 219 | - * @return mixed |
|
| 220 | - */ |
|
| 210 | + /** |
|
| 211 | + * Validates the specified value using the validation type. Returns |
|
| 212 | + * the validated value. |
|
| 213 | + * |
|
| 214 | + * @param mixed $value |
|
| 215 | + * @param string $type |
|
| 216 | + * @param array $params |
|
| 217 | + * @param bool $subval Whether this is a subvalue in a list |
|
| 218 | + * @throws Request_Exception |
|
| 219 | + * @return mixed |
|
| 220 | + */ |
|
| 221 | 221 | protected function validateType($value, string $type, array $params, bool $subval) |
| 222 | 222 | { |
| 223 | 223 | $class = '\AppUtils\Request_Param_Validator_'.ucfirst($type); |
@@ -286,13 +286,13 @@ discard block |
||
| 286 | 286 | |
| 287 | 287 | protected $valueType = self::VALUE_TYPE_STRING; |
| 288 | 288 | |
| 289 | - /** |
|
| 290 | - * Sets the variable to contain a comma-separated list of integer IDs. |
|
| 291 | - * Example: <code>145,248,4556</code>. A single ID is also allowed, e.g. |
|
| 292 | - * <code>145</code>. |
|
| 293 | - * |
|
| 294 | - * @return Request_Param |
|
| 295 | - */ |
|
| 289 | + /** |
|
| 290 | + * Sets the variable to contain a comma-separated list of integer IDs. |
|
| 291 | + * Example: <code>145,248,4556</code>. A single ID is also allowed, e.g. |
|
| 292 | + * <code>145</code>. |
|
| 293 | + * |
|
| 294 | + * @return Request_Param |
|
| 295 | + */ |
|
| 296 | 296 | public function setIDList() |
| 297 | 297 | { |
| 298 | 298 | $this->valueType = self::VALUE_TYPE_LIST; |
@@ -302,13 +302,13 @@ discard block |
||
| 302 | 302 | return $this; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - /** |
|
| 306 | - * Sets the variable to be an alias, as defined by the |
|
| 307 | - * {@link RegexHelper::REGEX_ALIAS} regular expression. |
|
| 308 | - * |
|
| 309 | - * @return Request_Param |
|
| 310 | - * @see RegexHelper::REGEX_ALIAS |
|
| 311 | - */ |
|
| 305 | + /** |
|
| 306 | + * Sets the variable to be an alias, as defined by the |
|
| 307 | + * {@link RegexHelper::REGEX_ALIAS} regular expression. |
|
| 308 | + * |
|
| 309 | + * @return Request_Param |
|
| 310 | + * @see RegexHelper::REGEX_ALIAS |
|
| 311 | + */ |
|
| 312 | 312 | public function setAlias() |
| 313 | 313 | { |
| 314 | 314 | return $this->setRegex(RegexHelper::REGEX_ALIAS); |
@@ -349,12 +349,12 @@ discard block |
||
| 349 | 349 | return $this->setValidation(self::VALIDATION_TYPE_ALPHA); |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - /** |
|
| 353 | - * Sets the parameter value as a string containing lowercase |
|
| 354 | - * and/or uppercase letters, as well as numbers. |
|
| 355 | - * |
|
| 356 | - * @return Request_Param |
|
| 357 | - */ |
|
| 352 | + /** |
|
| 353 | + * Sets the parameter value as a string containing lowercase |
|
| 354 | + * and/or uppercase letters, as well as numbers. |
|
| 355 | + * |
|
| 356 | + * @return Request_Param |
|
| 357 | + */ |
|
| 358 | 358 | public function setAlnum() |
| 359 | 359 | { |
| 360 | 360 | return $this->setValidation(self::VALIDATION_TYPE_ALNUM); |
@@ -387,17 +387,17 @@ discard block |
||
| 387 | 387 | ); |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - /** |
|
| 391 | - * Only available for array values: the parameter must be |
|
| 392 | - * an array value, and the array may only contain values |
|
| 393 | - * specified in the values array. |
|
| 394 | - * |
|
| 395 | - * Submitted values that are not in the allowed list of |
|
| 396 | - * values are stripped from the value. |
|
| 397 | - * |
|
| 398 | - * @param array $values List of allowed values |
|
| 399 | - * @return \AppUtils\Request_Param |
|
| 400 | - */ |
|
| 390 | + /** |
|
| 391 | + * Only available for array values: the parameter must be |
|
| 392 | + * an array value, and the array may only contain values |
|
| 393 | + * specified in the values array. |
|
| 394 | + * |
|
| 395 | + * Submitted values that are not in the allowed list of |
|
| 396 | + * values are stripped from the value. |
|
| 397 | + * |
|
| 398 | + * @param array $values List of allowed values |
|
| 399 | + * @return \AppUtils\Request_Param |
|
| 400 | + */ |
|
| 401 | 401 | public function setValuesList(array $values) |
| 402 | 402 | { |
| 403 | 403 | $this->setArray(); |
@@ -410,11 +410,11 @@ discard block |
||
| 410 | 410 | ); |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - /** |
|
| 414 | - * Whether the parameter is a list of values. |
|
| 415 | - * |
|
| 416 | - * @return bool |
|
| 417 | - */ |
|
| 413 | + /** |
|
| 414 | + * Whether the parameter is a list of values. |
|
| 415 | + * |
|
| 416 | + * @return bool |
|
| 417 | + */ |
|
| 418 | 418 | public function isList() : bool |
| 419 | 419 | { |
| 420 | 420 | return $this->valueType === self::VALUE_TYPE_LIST; |
@@ -425,53 +425,53 @@ discard block |
||
| 425 | 425 | return $this->setValidation(self::VALIDATION_TYPE_ARRAY); |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | - /** |
|
| 429 | - * Specifies that a JSON-encoded string is expected. |
|
| 430 | - * |
|
| 431 | - * NOTE: Numbers or quoted strings are technically valid |
|
| 432 | - * JSON, but are not accepted, because it is assumed |
|
| 433 | - * at least an array or object are expected. |
|
| 434 | - * |
|
| 435 | - * @return \AppUtils\Request_Param |
|
| 436 | - */ |
|
| 428 | + /** |
|
| 429 | + * Specifies that a JSON-encoded string is expected. |
|
| 430 | + * |
|
| 431 | + * NOTE: Numbers or quoted strings are technically valid |
|
| 432 | + * JSON, but are not accepted, because it is assumed |
|
| 433 | + * at least an array or object are expected. |
|
| 434 | + * |
|
| 435 | + * @return \AppUtils\Request_Param |
|
| 436 | + */ |
|
| 437 | 437 | public function setJSON() : Request_Param |
| 438 | 438 | { |
| 439 | 439 | return $this->setValidation(self::VALIDATION_TYPE_JSON, array('arrays' => true)); |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - /** |
|
| 443 | - * Like {@link Request_Param::setJSON()}, but accepts |
|
| 444 | - * only JSON objects. Arrays will not be accepted. |
|
| 445 | - * |
|
| 446 | - * @return \AppUtils\Request_Param |
|
| 447 | - */ |
|
| 442 | + /** |
|
| 443 | + * Like {@link Request_Param::setJSON()}, but accepts |
|
| 444 | + * only JSON objects. Arrays will not be accepted. |
|
| 445 | + * |
|
| 446 | + * @return \AppUtils\Request_Param |
|
| 447 | + */ |
|
| 448 | 448 | public function setJSONObject() : Request_Param |
| 449 | 449 | { |
| 450 | 450 | return $this->setValidation(self::VALIDATION_TYPE_JSON, array('arrays' => false)); |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | - /** |
|
| 454 | - * The parameter is a string boolean representation. This means |
|
| 455 | - * it can be any of the following: "yes", "true", "no", "false". |
|
| 456 | - * The value is automatically converted to a boolean when retrieving |
|
| 457 | - * the parameter. |
|
| 458 | - * |
|
| 459 | - * @return Request_Param |
|
| 460 | - */ |
|
| 453 | + /** |
|
| 454 | + * The parameter is a string boolean representation. This means |
|
| 455 | + * it can be any of the following: "yes", "true", "no", "false". |
|
| 456 | + * The value is automatically converted to a boolean when retrieving |
|
| 457 | + * the parameter. |
|
| 458 | + * |
|
| 459 | + * @return Request_Param |
|
| 460 | + */ |
|
| 461 | 461 | public function setBoolean() : Request_Param |
| 462 | 462 | { |
| 463 | 463 | return $this->addClassFilter('Boolean'); |
| 464 | 464 | } |
| 465 | 465 | |
| 466 | - /** |
|
| 467 | - * Validates the request parameter as an MD5 string, |
|
| 468 | - * so that only values resembling md5 values are accepted. |
|
| 469 | - * |
|
| 470 | - * NOTE: This can only guarantee the format, not whether |
|
| 471 | - * it is an actual valid hash of something. |
|
| 472 | - * |
|
| 473 | - * @return \AppUtils\Request_Param |
|
| 474 | - */ |
|
| 466 | + /** |
|
| 467 | + * Validates the request parameter as an MD5 string, |
|
| 468 | + * so that only values resembling md5 values are accepted. |
|
| 469 | + * |
|
| 470 | + * NOTE: This can only guarantee the format, not whether |
|
| 471 | + * it is an actual valid hash of something. |
|
| 472 | + * |
|
| 473 | + * @return \AppUtils\Request_Param |
|
| 474 | + */ |
|
| 475 | 475 | public function setMD5() : Request_Param |
| 476 | 476 | { |
| 477 | 477 | return $this->setRegex(RegexHelper::REGEX_MD5); |
@@ -513,14 +513,14 @@ discard block |
||
| 513 | 513 | return $this; |
| 514 | 514 | } |
| 515 | 515 | |
| 516 | - /** |
|
| 517 | - * Retrieves the value of the request parameter, |
|
| 518 | - * applying all filters (if any) and validation |
|
| 519 | - * (if any). |
|
| 520 | - * |
|
| 521 | - * @param mixed $default |
|
| 522 | - * @return mixed |
|
| 523 | - */ |
|
| 516 | + /** |
|
| 517 | + * Retrieves the value of the request parameter, |
|
| 518 | + * applying all filters (if any) and validation |
|
| 519 | + * (if any). |
|
| 520 | + * |
|
| 521 | + * @param mixed $default |
|
| 522 | + * @return mixed |
|
| 523 | + */ |
|
| 524 | 524 | public function get($default=null) |
| 525 | 525 | { |
| 526 | 526 | $value = $this->request->getParam($this->paramName); |
@@ -531,14 +531,14 @@ discard block |
||
| 531 | 531 | return $this->validate($default); |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | - /** |
|
| 535 | - * Filters the specified value by going through all available |
|
| 536 | - * filters, if any. If none have been set, the value is simply |
|
| 537 | - * passed through. |
|
| 538 | - * |
|
| 539 | - * @param mixed $value |
|
| 540 | - * @return mixed |
|
| 541 | - */ |
|
| 534 | + /** |
|
| 535 | + * Filters the specified value by going through all available |
|
| 536 | + * filters, if any. If none have been set, the value is simply |
|
| 537 | + * passed through. |
|
| 538 | + * |
|
| 539 | + * @param mixed $value |
|
| 540 | + * @return mixed |
|
| 541 | + */ |
|
| 542 | 542 | protected function filter($value) |
| 543 | 543 | { |
| 544 | 544 | $total = count($this->filters); |
@@ -608,12 +608,12 @@ discard block |
||
| 608 | 608 | return $this; |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | - /** |
|
| 612 | - * Adds a filter that trims whitespace from the request |
|
| 613 | - * parameter using the PHP <code>trim</code> function. |
|
| 614 | - * |
|
| 615 | - * @return \AppUtils\Request_Param |
|
| 616 | - */ |
|
| 611 | + /** |
|
| 612 | + * Adds a filter that trims whitespace from the request |
|
| 613 | + * parameter using the PHP <code>trim</code> function. |
|
| 614 | + * |
|
| 615 | + * @return \AppUtils\Request_Param |
|
| 616 | + */ |
|
| 617 | 617 | public function addFilterTrim() : Request_Param |
| 618 | 618 | { |
| 619 | 619 | // to guarantee we only work with strings |
@@ -622,13 +622,13 @@ discard block |
||
| 622 | 622 | return $this->addCallbackFilter('trim'); |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | - /** |
|
| 626 | - * Converts the value to a string, even if it is not |
|
| 627 | - * a string value. Complex types like arrays and objects |
|
| 628 | - * are converted to an empty string. |
|
| 629 | - * |
|
| 630 | - * @return \AppUtils\Request_Param |
|
| 631 | - */ |
|
| 625 | + /** |
|
| 626 | + * Converts the value to a string, even if it is not |
|
| 627 | + * a string value. Complex types like arrays and objects |
|
| 628 | + * are converted to an empty string. |
|
| 629 | + * |
|
| 630 | + * @return \AppUtils\Request_Param |
|
| 631 | + */ |
|
| 632 | 632 | public function addStringFilter() : Request_Param |
| 633 | 633 | { |
| 634 | 634 | return $this->addClassFilter('String'); |
@@ -678,12 +678,12 @@ discard block |
||
| 678 | 678 | return $this->addCallbackFilter('strip_tags', array($allowedTags)); |
| 679 | 679 | } |
| 680 | 680 | |
| 681 | - /** |
|
| 682 | - * Adds a filter that strips all whitespace from the |
|
| 683 | - * request parameter, from spaces to tabs and newlines. |
|
| 684 | - * |
|
| 685 | - * @return \AppUtils\Request_Param |
|
| 686 | - */ |
|
| 681 | + /** |
|
| 682 | + * Adds a filter that strips all whitespace from the |
|
| 683 | + * request parameter, from spaces to tabs and newlines. |
|
| 684 | + * |
|
| 685 | + * @return \AppUtils\Request_Param |
|
| 686 | + */ |
|
| 687 | 687 | public function addStripWhitespaceFilter() : Request_Param |
| 688 | 688 | { |
| 689 | 689 | // to ensure we only work with strings. |
@@ -692,14 +692,14 @@ discard block |
||
| 692 | 692 | return $this->addClassFilter('StripWhitespace'); |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | - /** |
|
| 696 | - * Adds a filter that transforms comma separated values |
|
| 697 | - * into an array of values. |
|
| 698 | - * |
|
| 699 | - * @param bool $trimEntries Trim whitespace from each entry? |
|
| 700 | - * @param bool $stripEmptyEntries Remove empty entries from the array? |
|
| 701 | - * @return \AppUtils\Request_Param |
|
| 702 | - */ |
|
| 695 | + /** |
|
| 696 | + * Adds a filter that transforms comma separated values |
|
| 697 | + * into an array of values. |
|
| 698 | + * |
|
| 699 | + * @param bool $trimEntries Trim whitespace from each entry? |
|
| 700 | + * @param bool $stripEmptyEntries Remove empty entries from the array? |
|
| 701 | + * @return \AppUtils\Request_Param |
|
| 702 | + */ |
|
| 703 | 703 | public function addCommaSeparatedFilter(bool $trimEntries=true, bool $stripEmptyEntries=true) : Request_Param |
| 704 | 704 | { |
| 705 | 705 | $this->setArray(); |
@@ -724,12 +724,12 @@ discard block |
||
| 724 | 724 | ); |
| 725 | 725 | } |
| 726 | 726 | |
| 727 | - /** |
|
| 728 | - * Adds a filter that encodes all HTML special characters |
|
| 729 | - * using the PHP <code>htmlspecialchars</code> function. |
|
| 730 | - * |
|
| 731 | - * @return \AppUtils\Request_Param |
|
| 732 | - */ |
|
| 727 | + /** |
|
| 728 | + * Adds a filter that encodes all HTML special characters |
|
| 729 | + * using the PHP <code>htmlspecialchars</code> function. |
|
| 730 | + * |
|
| 731 | + * @return \AppUtils\Request_Param |
|
| 732 | + */ |
|
| 733 | 733 | public function addHTMLSpecialcharsFilter() : Request_Param |
| 734 | 734 | { |
| 735 | 735 | return $this->addCallbackFilter('htmlspecialchars', array(ENT_QUOTES, 'UTF-8')); |
@@ -742,14 +742,14 @@ discard block |
||
| 742 | 742 | |
| 743 | 743 | protected $required = false; |
| 744 | 744 | |
| 745 | - /** |
|
| 746 | - * Marks this request parameter as required. To use this feature, |
|
| 747 | - * you have to call the request's {@link Request::validate()} |
|
| 748 | - * method. |
|
| 749 | - * |
|
| 750 | - * @return Request_Param |
|
| 751 | - * @see Request::validate() |
|
| 752 | - */ |
|
| 745 | + /** |
|
| 746 | + * Marks this request parameter as required. To use this feature, |
|
| 747 | + * you have to call the request's {@link Request::validate()} |
|
| 748 | + * method. |
|
| 749 | + * |
|
| 750 | + * @return Request_Param |
|
| 751 | + * @see Request::validate() |
|
| 752 | + */ |
|
| 753 | 753 | public function makeRequired() : Request_Param |
| 754 | 754 | { |
| 755 | 755 | $this->required = true; |
@@ -19,34 +19,34 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | class RequestHelper_Boundaries_Boundary |
| 21 | 21 | { |
| 22 | - /** |
|
| 23 | - * @var string |
|
| 24 | - */ |
|
| 22 | + /** |
|
| 23 | + * @var string |
|
| 24 | + */ |
|
| 25 | 25 | protected $content; |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @var array |
|
| 29 | - */ |
|
| 27 | + /** |
|
| 28 | + * @var array |
|
| 29 | + */ |
|
| 30 | 30 | protected $dispositionParams = array(); |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @var string |
|
| 34 | - */ |
|
| 32 | + /** |
|
| 33 | + * @var string |
|
| 34 | + */ |
|
| 35 | 35 | protected $contentType = ''; |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @var string |
|
| 39 | - */ |
|
| 37 | + /** |
|
| 38 | + * @var string |
|
| 39 | + */ |
|
| 40 | 40 | protected $contentEncoding = ''; |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @var RequestHelper_Boundaries |
|
| 44 | - */ |
|
| 42 | + /** |
|
| 43 | + * @var RequestHelper_Boundaries |
|
| 44 | + */ |
|
| 45 | 45 | protected $boundaries; |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @var string |
|
| 49 | - */ |
|
| 47 | + /** |
|
| 48 | + * @var string |
|
| 49 | + */ |
|
| 50 | 50 | protected $transferEncoding = ''; |
| 51 | 51 | |
| 52 | 52 | public function __construct(RequestHelper_Boundaries $boundaries, string $content) |
@@ -60,46 +60,46 @@ discard block |
||
| 60 | 60 | return strlen($this->content); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Sets the name of the request parameter. |
|
| 65 | - * |
|
| 66 | - * @param string $name |
|
| 67 | - * @return RequestHelper_Boundaries_Boundary |
|
| 68 | - */ |
|
| 63 | + /** |
|
| 64 | + * Sets the name of the request parameter. |
|
| 65 | + * |
|
| 66 | + * @param string $name |
|
| 67 | + * @return RequestHelper_Boundaries_Boundary |
|
| 68 | + */ |
|
| 69 | 69 | public function setName(string $name) : RequestHelper_Boundaries_Boundary |
| 70 | 70 | { |
| 71 | 71 | return $this->setDispositionParam('name', $name); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Sets the filename to use for the content, if applicable. |
|
| 76 | - * |
|
| 77 | - * @param string $fileName |
|
| 78 | - * @return RequestHelper_Boundaries_Boundary |
|
| 79 | - */ |
|
| 74 | + /** |
|
| 75 | + * Sets the filename to use for the content, if applicable. |
|
| 76 | + * |
|
| 77 | + * @param string $fileName |
|
| 78 | + * @return RequestHelper_Boundaries_Boundary |
|
| 79 | + */ |
|
| 80 | 80 | public function setFileName(string $fileName) : RequestHelper_Boundaries_Boundary |
| 81 | 81 | { |
| 82 | 82 | return $this->setDispositionParam('filename', $fileName); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Sets the content type to use for the content. |
|
| 87 | - * |
|
| 88 | - * @param string $contentType |
|
| 89 | - * @return RequestHelper_Boundaries_Boundary |
|
| 90 | - */ |
|
| 85 | + /** |
|
| 86 | + * Sets the content type to use for the content. |
|
| 87 | + * |
|
| 88 | + * @param string $contentType |
|
| 89 | + * @return RequestHelper_Boundaries_Boundary |
|
| 90 | + */ |
|
| 91 | 91 | public function setContentType(string $contentType) : RequestHelper_Boundaries_Boundary |
| 92 | 92 | { |
| 93 | 93 | $this->contentType = $contentType; |
| 94 | 94 | return $this; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * Sets the encoding to specify for the content. |
|
| 99 | - * |
|
| 100 | - * @param string $encoding An encoding string, e.g. "UTF-8", "ASCII" |
|
| 101 | - * @return RequestHelper_Boundaries_Boundary |
|
| 102 | - */ |
|
| 97 | + /** |
|
| 98 | + * Sets the encoding to specify for the content. |
|
| 99 | + * |
|
| 100 | + * @param string $encoding An encoding string, e.g. "UTF-8", "ASCII" |
|
| 101 | + * @return RequestHelper_Boundaries_Boundary |
|
| 102 | + */ |
|
| 103 | 103 | public function setContentEncoding(string $encoding) : RequestHelper_Boundaries_Boundary |
| 104 | 104 | { |
| 105 | 105 | $this->contentEncoding = $encoding; |
@@ -119,11 +119,11 @@ discard block |
||
| 119 | 119 | return $this; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - /** |
|
| 123 | - * Renders the mime boundary text. |
|
| 124 | - * |
|
| 125 | - * @return string |
|
| 126 | - */ |
|
| 122 | + /** |
|
| 123 | + * Renders the mime boundary text. |
|
| 124 | + * |
|
| 125 | + * @return string |
|
| 126 | + */ |
|
| 127 | 127 | public function render() |
| 128 | 128 | { |
| 129 | 129 | $eol = $this->boundaries->getEOL(); |
@@ -20,9 +20,9 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | class URLInfo_Highlighter |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @var URLInfo |
|
| 25 | - */ |
|
| 23 | + /** |
|
| 24 | + * @var URLInfo |
|
| 25 | + */ |
|
| 26 | 26 | protected $info; |
| 27 | 27 | |
| 28 | 28 | public function __construct(URLInfo $info) |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | ); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - /** |
|
| 162 | - * Fetches all parameters in the URL, regardless of |
|
| 163 | - * whether parameter exclusion is enabled, so they |
|
| 164 | - * can be highlighted is need be. |
|
| 165 | - * |
|
| 166 | - * @return array |
|
| 167 | - */ |
|
| 161 | + /** |
|
| 162 | + * Fetches all parameters in the URL, regardless of |
|
| 163 | + * whether parameter exclusion is enabled, so they |
|
| 164 | + * can be highlighted is need be. |
|
| 165 | + * |
|
| 166 | + * @return array |
|
| 167 | + */ |
|
| 168 | 168 | protected function resolveParams() : array |
| 169 | 169 | { |
| 170 | 170 | $previous = $this->info->isParamExclusionEnabled(); |
@@ -38,24 +38,24 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | class NumberInfo |
| 40 | 40 | { |
| 41 | - /** |
|
| 42 | - * @var mixed |
|
| 43 | - */ |
|
| 41 | + /** |
|
| 42 | + * @var mixed |
|
| 43 | + */ |
|
| 44 | 44 | protected $rawValue; |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @var array |
|
| 48 | - */ |
|
| 46 | + /** |
|
| 47 | + * @var array |
|
| 48 | + */ |
|
| 49 | 49 | protected $info; |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @var bool |
|
| 53 | - */ |
|
| 51 | + /** |
|
| 52 | + * @var bool |
|
| 53 | + */ |
|
| 54 | 54 | protected $empty = false; |
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @var array |
|
| 58 | - */ |
|
| 56 | + /** |
|
| 57 | + * @var array |
|
| 58 | + */ |
|
| 59 | 59 | protected $knownUnits = array( |
| 60 | 60 | '%' => true, |
| 61 | 61 | 'rem' => true, |
@@ -95,21 +95,21 @@ discard block |
||
| 95 | 95 | return $this; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * Retrieves the raw, internal information array resulting |
|
| 100 | - * from the parsing of the number. |
|
| 101 | - * |
|
| 102 | - * @return array |
|
| 103 | - */ |
|
| 98 | + /** |
|
| 99 | + * Retrieves the raw, internal information array resulting |
|
| 100 | + * from the parsing of the number. |
|
| 101 | + * |
|
| 102 | + * @return array |
|
| 103 | + */ |
|
| 104 | 104 | public function getRawInfo() : array |
| 105 | 105 | { |
| 106 | 106 | return $this->info; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Whether the number was empty (null or empty string). |
|
| 111 | - * @return boolean |
|
| 112 | - */ |
|
| 109 | + /** |
|
| 110 | + * Whether the number was empty (null or empty string). |
|
| 111 | + * @return boolean |
|
| 112 | + */ |
|
| 113 | 113 | public function isEmpty() : bool |
| 114 | 114 | { |
| 115 | 115 | return $this->empty; |
@@ -532,12 +532,12 @@ discard block |
||
| 532 | 532 | return $cache[$key]; |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | - /** |
|
| 536 | - * Parses a string number notation with units included, e.g. 14px, 50%... |
|
| 537 | - * |
|
| 538 | - * @param string $test |
|
| 539 | - * @return array |
|
| 540 | - */ |
|
| 535 | + /** |
|
| 536 | + * Parses a string number notation with units included, e.g. 14px, 50%... |
|
| 537 | + * |
|
| 538 | + * @param string $test |
|
| 539 | + * @return array |
|
| 540 | + */ |
|
| 541 | 541 | private function parseStringValue(string $test) : array |
| 542 | 542 | { |
| 543 | 543 | $number = null; |
@@ -588,13 +588,13 @@ discard block |
||
| 588 | 588 | return $this->filterInfo($result); |
| 589 | 589 | } |
| 590 | 590 | |
| 591 | - /** |
|
| 592 | - * Attempts to determine what kind of units are specified |
|
| 593 | - * in the string. Returns NULL if none could be matched. |
|
| 594 | - * |
|
| 595 | - * @param string $value |
|
| 596 | - * @return array|NULL |
|
| 597 | - */ |
|
| 591 | + /** |
|
| 592 | + * Attempts to determine what kind of units are specified |
|
| 593 | + * in the string. Returns NULL if none could be matched. |
|
| 594 | + * |
|
| 595 | + * @param string $value |
|
| 596 | + * @return array|NULL |
|
| 597 | + */ |
|
| 598 | 598 | private function findUnits(string $value) : ?array |
| 599 | 599 | { |
| 600 | 600 | $vlength = strlen($value); |
@@ -622,12 +622,12 @@ discard block |
||
| 622 | 622 | return null; |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | - /** |
|
| 626 | - * Creates the cache key for the specified value. |
|
| 627 | - * |
|
| 628 | - * @param mixed $value |
|
| 629 | - * @return string |
|
| 630 | - */ |
|
| 625 | + /** |
|
| 626 | + * Creates the cache key for the specified value. |
|
| 627 | + * |
|
| 628 | + * @param mixed $value |
|
| 629 | + * @return string |
|
| 630 | + */ |
|
| 631 | 631 | private function createValueKey($value) : string |
| 632 | 632 | { |
| 633 | 633 | if(!is_string($value) && !is_numeric($value)) |
@@ -640,59 +640,59 @@ discard block |
||
| 640 | 640 | |
| 641 | 641 | protected $postProcess = false; |
| 642 | 642 | |
| 643 | - /** |
|
| 644 | - * Called if explicitly enabled: allows filtering the |
|
| 645 | - * number after the detection process has completed. |
|
| 646 | - * |
|
| 647 | - * @param string|NULL $number The adjusted number |
|
| 648 | - * @param string $originalString The original value before it was parsed |
|
| 649 | - * @return mixed |
|
| 650 | - */ |
|
| 643 | + /** |
|
| 644 | + * Called if explicitly enabled: allows filtering the |
|
| 645 | + * number after the detection process has completed. |
|
| 646 | + * |
|
| 647 | + * @param string|NULL $number The adjusted number |
|
| 648 | + * @param string $originalString The original value before it was parsed |
|
| 649 | + * @return mixed |
|
| 650 | + */ |
|
| 651 | 651 | protected function postProcess(?string $number, /** @scrutinizer ignore-unused */ string $originalString) |
| 652 | 652 | { |
| 653 | 653 | return $number; |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | - /** |
|
| 657 | - * Filters the value before it is parsed, but only if it is a string. |
|
| 658 | - * |
|
| 659 | - * NOTE: This may be overwritten in a subclass, to allow custom filtering |
|
| 660 | - * the the values. An example of a use case would be a preprocessor for |
|
| 661 | - * variables in a templating system. |
|
| 662 | - * |
|
| 663 | - * @param string $trimmedString The trimmed value. |
|
| 664 | - * @param array $cache The internal values cache array. |
|
| 665 | - * @param string $originalValue The original value that the NumberInfo was created for. |
|
| 666 | - * @return string |
|
| 667 | - * |
|
| 668 | - * @see NumberInfo::enablePostProcess() |
|
| 669 | - */ |
|
| 656 | + /** |
|
| 657 | + * Filters the value before it is parsed, but only if it is a string. |
|
| 658 | + * |
|
| 659 | + * NOTE: This may be overwritten in a subclass, to allow custom filtering |
|
| 660 | + * the the values. An example of a use case would be a preprocessor for |
|
| 661 | + * variables in a templating system. |
|
| 662 | + * |
|
| 663 | + * @param string $trimmedString The trimmed value. |
|
| 664 | + * @param array $cache The internal values cache array. |
|
| 665 | + * @param string $originalValue The original value that the NumberInfo was created for. |
|
| 666 | + * @return string |
|
| 667 | + * |
|
| 668 | + * @see NumberInfo::enablePostProcess() |
|
| 669 | + */ |
|
| 670 | 670 | protected function preProcess(string $trimmedString, /** @scrutinizer ignore-unused */ array &$cache, /** @scrutinizer ignore-unused */ string $originalValue) : string |
| 671 | 671 | { |
| 672 | 672 | return str_replace(',', '.', $trimmedString); |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | - /** |
|
| 676 | - * Enables the post processing so the postProcess method gets called. |
|
| 677 | - * This should be called in the {@link NumberInfo::preProcess()} |
|
| 678 | - * method as needed. |
|
| 679 | - * |
|
| 680 | - * @return NumberInfo |
|
| 681 | - * @see NumberInfo::postProcess() |
|
| 682 | - */ |
|
| 675 | + /** |
|
| 676 | + * Enables the post processing so the postProcess method gets called. |
|
| 677 | + * This should be called in the {@link NumberInfo::preProcess()} |
|
| 678 | + * method as needed. |
|
| 679 | + * |
|
| 680 | + * @return NumberInfo |
|
| 681 | + * @see NumberInfo::postProcess() |
|
| 682 | + */ |
|
| 683 | 683 | protected function enablePostProcess() : NumberInfo |
| 684 | 684 | { |
| 685 | 685 | $this->postProcess = true; |
| 686 | 686 | return $this; |
| 687 | 687 | } |
| 688 | 688 | |
| 689 | - /** |
|
| 690 | - * Filters the number info array to adjust the units |
|
| 691 | - * and number according to the required rules. |
|
| 692 | - * |
|
| 693 | - * @param array $info |
|
| 694 | - * @return array |
|
| 695 | - */ |
|
| 689 | + /** |
|
| 690 | + * Filters the number info array to adjust the units |
|
| 691 | + * and number according to the required rules. |
|
| 692 | + * |
|
| 693 | + * @param array $info |
|
| 694 | + * @return array |
|
| 695 | + */ |
|
| 696 | 696 | protected function filterInfo(array $info) : array |
| 697 | 697 | { |
| 698 | 698 | $useUnits = 'px'; |
@@ -27,16 +27,16 @@ |
||
| 27 | 27 | |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * We parse the query string ourselves, because the PHP implementation |
|
| 32 | - * of parse_str has limitations that do not apply to query strings. This |
|
| 33 | - * is due to the fact that parse_str has to create PHP-compatible variable |
|
| 34 | - * names from the parameters. URL parameters simply allow way more things |
|
| 35 | - * than PHP variable names. |
|
| 36 | - * |
|
| 37 | - * @param string $queryString |
|
| 38 | - * @return array |
|
| 39 | - */ |
|
| 30 | + /** |
|
| 31 | + * We parse the query string ourselves, because the PHP implementation |
|
| 32 | + * of parse_str has limitations that do not apply to query strings. This |
|
| 33 | + * is due to the fact that parse_str has to create PHP-compatible variable |
|
| 34 | + * names from the parameters. URL parameters simply allow way more things |
|
| 35 | + * than PHP variable names. |
|
| 36 | + * |
|
| 37 | + * @param string $queryString |
|
| 38 | + * @return array |
|
| 39 | + */ |
|
| 40 | 40 | public function parse(string $queryString) : array |
| 41 | 41 | { |
| 42 | 42 | // allow HTML entities notation |
@@ -23,24 +23,24 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | class URLInfo_Parser |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * @var string |
|
| 28 | - */ |
|
| 26 | + /** |
|
| 27 | + * @var string |
|
| 28 | + */ |
|
| 29 | 29 | protected $url; |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var bool |
|
| 33 | - */ |
|
| 31 | + /** |
|
| 32 | + * @var bool |
|
| 33 | + */ |
|
| 34 | 34 | protected $isValid = false; |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var array |
|
| 38 | - */ |
|
| 36 | + /** |
|
| 37 | + * @var array |
|
| 38 | + */ |
|
| 39 | 39 | protected $info; |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var array|NULL |
|
| 43 | - */ |
|
| 41 | + /** |
|
| 42 | + * @var array|NULL |
|
| 43 | + */ |
|
| 44 | 44 | protected $error; |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -56,25 +56,25 @@ discard block |
||
| 56 | 56 | 'file' |
| 57 | 57 | ); |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Stores a list of all unicode characters in the URL |
|
| 61 | - * that have been filtered out before parsing it with |
|
| 62 | - * parse_url. |
|
| 63 | - * |
|
| 64 | - * @var string[]string |
|
| 65 | - */ |
|
| 59 | + /** |
|
| 60 | + * Stores a list of all unicode characters in the URL |
|
| 61 | + * that have been filtered out before parsing it with |
|
| 62 | + * parse_url. |
|
| 63 | + * |
|
| 64 | + * @var string[]string |
|
| 65 | + */ |
|
| 66 | 66 | protected $unicodeChars = array(); |
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @var bool |
|
| 70 | - */ |
|
| 68 | + /** |
|
| 69 | + * @var bool |
|
| 70 | + */ |
|
| 71 | 71 | protected $encodeUTF = false; |
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * |
|
| 75 | - * @param string $url The target URL. |
|
| 76 | - * @param bool $encodeUTF Whether to URL encode any plain text unicode characters. |
|
| 77 | - */ |
|
| 73 | + /** |
|
| 74 | + * |
|
| 75 | + * @param string $url The target URL. |
|
| 76 | + * @param bool $encodeUTF Whether to URL encode any plain text unicode characters. |
|
| 77 | + */ |
|
| 78 | 78 | public function __construct(string $url, bool $encodeUTF) |
| 79 | 79 | { |
| 80 | 80 | $this->url = $url; |
@@ -87,12 +87,12 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * Retrieves the array as parsed by PHP's parse_url, |
|
| 92 | - * filtered and adjusted as necessary. |
|
| 93 | - * |
|
| 94 | - * @return array |
|
| 95 | - */ |
|
| 90 | + /** |
|
| 91 | + * Retrieves the array as parsed by PHP's parse_url, |
|
| 92 | + * filtered and adjusted as necessary. |
|
| 93 | + * |
|
| 94 | + * @return array |
|
| 95 | + */ |
|
| 96 | 96 | public function getInfo() : array |
| 97 | 97 | { |
| 98 | 98 | return $this->info; |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - /** |
|
| 118 | - * Finds any non-url encoded unicode characters in |
|
| 119 | - * the URL, and encodes them before the URL is |
|
| 120 | - * passed to parse_url. |
|
| 121 | - */ |
|
| 117 | + /** |
|
| 118 | + * Finds any non-url encoded unicode characters in |
|
| 119 | + * the URL, and encodes them before the URL is |
|
| 120 | + * passed to parse_url. |
|
| 121 | + */ |
|
| 122 | 122 | protected function filterUnicodeChars() : void |
| 123 | 123 | { |
| 124 | 124 | $chars = \AppUtils\ConvertHelper::string2array($this->url); |
@@ -236,11 +236,11 @@ discard block |
||
| 236 | 236 | return false; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - /** |
|
| 240 | - * Goes through all information in the parse_url result |
|
| 241 | - * array, and attempts to fix any user errors in formatting |
|
| 242 | - * that can be recovered from, mostly regarding stray spaces. |
|
| 243 | - */ |
|
| 239 | + /** |
|
| 240 | + * Goes through all information in the parse_url result |
|
| 241 | + * array, and attempts to fix any user errors in formatting |
|
| 242 | + * that can be recovered from, mostly regarding stray spaces. |
|
| 243 | + */ |
|
| 244 | 244 | protected function filterParsed() |
| 245 | 245 | { |
| 246 | 246 | $this->info['params'] = array(); |
@@ -269,13 +269,13 @@ discard block |
||
| 269 | 269 | } |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - /** |
|
| 273 | - * Recursively goes through the array, and converts all previously |
|
| 274 | - * URL encoded characters with their unicode character counterparts. |
|
| 275 | - * |
|
| 276 | - * @param array $subject |
|
| 277 | - * @return array |
|
| 278 | - */ |
|
| 272 | + /** |
|
| 273 | + * Recursively goes through the array, and converts all previously |
|
| 274 | + * URL encoded characters with their unicode character counterparts. |
|
| 275 | + * |
|
| 276 | + * @param array $subject |
|
| 277 | + * @return array |
|
| 278 | + */ |
|
| 279 | 279 | protected function restoreUnicodeChars(array $subject) : array |
| 280 | 280 | { |
| 281 | 281 | $result = array(); |
@@ -299,13 +299,13 @@ discard block |
||
| 299 | 299 | return $result; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - /** |
|
| 303 | - * Replaces all URL encoded unicode characters |
|
| 304 | - * in the string with the unicode character. |
|
| 305 | - * |
|
| 306 | - * @param string $string |
|
| 307 | - * @return string |
|
| 308 | - */ |
|
| 302 | + /** |
|
| 303 | + * Replaces all URL encoded unicode characters |
|
| 304 | + * in the string with the unicode character. |
|
| 305 | + * |
|
| 306 | + * @param string $string |
|
| 307 | + * @return string |
|
| 308 | + */ |
|
| 309 | 309 | protected function restoreUnicodeChar(string $string) : string |
| 310 | 310 | { |
| 311 | 311 | if(strstr($string, '%')) |
@@ -363,21 +363,21 @@ discard block |
||
| 363 | 363 | ); |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - /** |
|
| 367 | - * Checks whether the URL that was parsed is valid. |
|
| 368 | - * @return bool |
|
| 369 | - */ |
|
| 366 | + /** |
|
| 367 | + * Checks whether the URL that was parsed is valid. |
|
| 368 | + * @return bool |
|
| 369 | + */ |
|
| 370 | 370 | public function isValid() : bool |
| 371 | 371 | { |
| 372 | 372 | return $this->isValid; |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | - /** |
|
| 376 | - * If the validation failed, retrieves the validation |
|
| 377 | - * error message. |
|
| 378 | - * |
|
| 379 | - * @return string |
|
| 380 | - */ |
|
| 375 | + /** |
|
| 376 | + * If the validation failed, retrieves the validation |
|
| 377 | + * error message. |
|
| 378 | + * |
|
| 379 | + * @return string |
|
| 380 | + */ |
|
| 381 | 381 | public function getErrorMessage() : string |
| 382 | 382 | { |
| 383 | 383 | if(isset($this->error)) { |
@@ -387,12 +387,12 @@ discard block |
||
| 387 | 387 | return ''; |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | - /** |
|
| 391 | - * If the validation failed, retrieves the validation |
|
| 392 | - * error code. |
|
| 393 | - * |
|
| 394 | - * @return int |
|
| 395 | - */ |
|
| 390 | + /** |
|
| 391 | + * If the validation failed, retrieves the validation |
|
| 392 | + * error code. |
|
| 393 | + * |
|
| 394 | + * @return int |
|
| 395 | + */ |
|
| 396 | 396 | public function getErrorCode() : int |
| 397 | 397 | { |
| 398 | 398 | if(isset($this->error)) { |
@@ -22,9 +22,9 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | const ERROR_MALFORMATTED_STRING = 53801; |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var string[] |
|
| 27 | - */ |
|
| 25 | + /** |
|
| 26 | + * @var string[] |
|
| 27 | + */ |
|
| 28 | 28 | protected static $controlChars = array( |
| 29 | 29 | '0000-0008', // control chars |
| 30 | 30 | '000E-000F', // control chars |
@@ -32,19 +32,19 @@ discard block |
||
| 32 | 32 | '2000-200F', // non-breaking space and co |
| 33 | 33 | ); |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var string|NULL |
|
| 37 | - */ |
|
| 35 | + /** |
|
| 36 | + * @var string|NULL |
|
| 37 | + */ |
|
| 38 | 38 | protected static $controlCharsRegex; |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @var string[] |
|
| 42 | - */ |
|
| 40 | + /** |
|
| 41 | + * @var string[] |
|
| 42 | + */ |
|
| 43 | 43 | protected static $hexAlphabet = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @var string[]|NULL |
|
| 47 | - */ |
|
| 45 | + /** |
|
| 46 | + * @var string[]|NULL |
|
| 47 | + */ |
|
| 48 | 48 | protected static $charsAsHex; |
| 49 | 49 | |
| 50 | 50 | public function __construct() |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Retrieves the HEX character codes for all control |
|
| 72 | - * characters that the {@link stripControlCharacters()} |
|
| 73 | - * method will remove. |
|
| 74 | - * |
|
| 75 | - * @return string[] |
|
| 76 | - */ |
|
| 70 | + /** |
|
| 71 | + * Retrieves the HEX character codes for all control |
|
| 72 | + * characters that the {@link stripControlCharacters()} |
|
| 73 | + * method will remove. |
|
| 74 | + * |
|
| 75 | + * @return string[] |
|
| 76 | + */ |
|
| 77 | 77 | public function getCharsAsHex() : array |
| 78 | 78 | { |
| 79 | 79 | if (isset(self::$charsAsHex)) |
@@ -120,13 +120,13 @@ discard block |
||
| 120 | 120 | return $stack; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * Retrieves an array of all control characters that |
|
| 125 | - * the {@link stripControlCharacters()} method will |
|
| 126 | - * remove, as the actual UTF-8 characters. |
|
| 127 | - * |
|
| 128 | - * @return string[] |
|
| 129 | - */ |
|
| 123 | + /** |
|
| 124 | + * Retrieves an array of all control characters that |
|
| 125 | + * the {@link stripControlCharacters()} method will |
|
| 126 | + * remove, as the actual UTF-8 characters. |
|
| 127 | + * |
|
| 128 | + * @return string[] |
|
| 129 | + */ |
|
| 130 | 130 | public function getCharsAsUTF8() : array |
| 131 | 131 | { |
| 132 | 132 | $chars = $this->getCharsAsHex(); |
@@ -139,12 +139,12 @@ discard block |
||
| 139 | 139 | return $result; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - /** |
|
| 143 | - * Retrieves all control characters as JSON encoded |
|
| 144 | - * characters, e.g. "\u200b". |
|
| 145 | - * |
|
| 146 | - * @return string[] |
|
| 147 | - */ |
|
| 142 | + /** |
|
| 143 | + * Retrieves all control characters as JSON encoded |
|
| 144 | + * characters, e.g. "\u200b". |
|
| 145 | + * |
|
| 146 | + * @return string[] |
|
| 147 | + */ |
|
| 148 | 148 | public function getCharsAsJSON() : array |
| 149 | 149 | { |
| 150 | 150 | $chars = $this->getCharsAsHex(); |
@@ -157,17 +157,17 @@ discard block |
||
| 157 | 157 | return $result; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - /** |
|
| 161 | - * Removes all control characters from the specified string |
|
| 162 | - * that can cause problems in some cases, like creating |
|
| 163 | - * valid XML documents. This includes invisible non-breaking |
|
| 164 | - * spaces. |
|
| 165 | - * |
|
| 166 | - * @param string $string |
|
| 167 | - * @return string |
|
| 168 | - * @see https://stackoverflow.com/a/8171868/2298192 |
|
| 169 | - * @see https://unicode-table.com/en |
|
| 170 | - */ |
|
| 160 | + /** |
|
| 161 | + * Removes all control characters from the specified string |
|
| 162 | + * that can cause problems in some cases, like creating |
|
| 163 | + * valid XML documents. This includes invisible non-breaking |
|
| 164 | + * spaces. |
|
| 165 | + * |
|
| 166 | + * @param string $string |
|
| 167 | + * @return string |
|
| 168 | + * @see https://stackoverflow.com/a/8171868/2298192 |
|
| 169 | + * @see https://unicode-table.com/en |
|
| 170 | + */ |
|
| 171 | 171 | public function stripControlCharacters(string $string) : string |
| 172 | 172 | { |
| 173 | 173 | if(empty($string)) |