@@ -424,16 +424,16 @@ discard block |
||
| 424 | 424 | return $bytes . ' ' . t('B'); |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - /** |
|
| 428 | - * Cuts a text to the specified length if it is longer than the |
|
| 429 | - * target length. Appends a text to signify it has been cut at |
|
| 430 | - * the end of the string. |
|
| 431 | - * |
|
| 432 | - * @param string $text |
|
| 433 | - * @param int $targetLength |
|
| 434 | - * @param string $append |
|
| 435 | - * @return string |
|
| 436 | - */ |
|
| 427 | + /** |
|
| 428 | + * Cuts a text to the specified length if it is longer than the |
|
| 429 | + * target length. Appends a text to signify it has been cut at |
|
| 430 | + * the end of the string. |
|
| 431 | + * |
|
| 432 | + * @param string $text |
|
| 433 | + * @param int $targetLength |
|
| 434 | + * @param string $append |
|
| 435 | + * @return string |
|
| 436 | + */ |
|
| 437 | 437 | public static function text_cut(string $text, int $targetLength, string $append = '...') : string |
| 438 | 438 | { |
| 439 | 439 | $length = mb_strlen($text); |
@@ -503,27 +503,27 @@ discard block |
||
| 503 | 503 | return self::$booleanStrings[$string]; |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | - /** |
|
| 507 | - * Whether the specified string is a boolean string or boolean value. |
|
| 508 | - * Alias for {@link ConvertHelper::isBoolean()}. |
|
| 509 | - * |
|
| 510 | - * @param mixed $string |
|
| 511 | - * @return bool |
|
| 512 | - * @deprecated |
|
| 513 | - * @see ConvertHelper::isBoolean() |
|
| 514 | - */ |
|
| 506 | + /** |
|
| 507 | + * Whether the specified string is a boolean string or boolean value. |
|
| 508 | + * Alias for {@link ConvertHelper::isBoolean()}. |
|
| 509 | + * |
|
| 510 | + * @param mixed $string |
|
| 511 | + * @return bool |
|
| 512 | + * @deprecated |
|
| 513 | + * @see ConvertHelper::isBoolean() |
|
| 514 | + */ |
|
| 515 | 515 | public static function isBooleanString($string) : bool |
| 516 | 516 | { |
| 517 | 517 | return self::isBoolean($string); |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | - /** |
|
| 521 | - * Alias for the {@\AppUtils\XMLHelper::string2xml()} method. |
|
| 522 | - * |
|
| 523 | - * @param string $text |
|
| 524 | - * @return string |
|
| 525 | - * @deprecated |
|
| 526 | - */ |
|
| 520 | + /** |
|
| 521 | + * Alias for the {@\AppUtils\XMLHelper::string2xml()} method. |
|
| 522 | + * |
|
| 523 | + * @param string $text |
|
| 524 | + * @return string |
|
| 525 | + * @deprecated |
|
| 526 | + */ |
|
| 527 | 527 | public static function text_makeXMLCompliant($text) |
| 528 | 528 | { |
| 529 | 529 | return XMLHelper::string2xml($text); |
@@ -625,13 +625,13 @@ discard block |
||
| 625 | 625 | return $translit->convert($string); |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | - /** |
|
| 629 | - * Retrieves the HEX character codes for all control |
|
| 630 | - * characters that the {@link stripControlCharacters()} |
|
| 631 | - * method will remove. |
|
| 632 | - * |
|
| 633 | - * @return string[] |
|
| 634 | - */ |
|
| 628 | + /** |
|
| 629 | + * Retrieves the HEX character codes for all control |
|
| 630 | + * characters that the {@link stripControlCharacters()} |
|
| 631 | + * method will remove. |
|
| 632 | + * |
|
| 633 | + * @return string[] |
|
| 634 | + */ |
|
| 635 | 635 | public static function getControlCharactersAsHex() |
| 636 | 636 | { |
| 637 | 637 | $hexAlphabet = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
@@ -667,13 +667,13 @@ discard block |
||
| 667 | 667 | return $stack; |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | - /** |
|
| 671 | - * Retrieves an array of all control characters that |
|
| 672 | - * the {@link stripControlCharacters()} method will |
|
| 673 | - * remove, as the actual UTF-8 characters. |
|
| 674 | - * |
|
| 675 | - * @return string[] |
|
| 676 | - */ |
|
| 670 | + /** |
|
| 671 | + * Retrieves an array of all control characters that |
|
| 672 | + * the {@link stripControlCharacters()} method will |
|
| 673 | + * remove, as the actual UTF-8 characters. |
|
| 674 | + * |
|
| 675 | + * @return string[] |
|
| 676 | + */ |
|
| 677 | 677 | public static function getControlCharactersAsUTF8() |
| 678 | 678 | { |
| 679 | 679 | $chars = self::getControlCharactersAsHex(); |
@@ -686,12 +686,12 @@ discard block |
||
| 686 | 686 | return $result; |
| 687 | 687 | } |
| 688 | 688 | |
| 689 | - /** |
|
| 690 | - * Retrieves all control characters as JSON encoded |
|
| 691 | - * characters, e.g. "\u200b". |
|
| 692 | - * |
|
| 693 | - * @return string[] |
|
| 694 | - */ |
|
| 689 | + /** |
|
| 690 | + * Retrieves all control characters as JSON encoded |
|
| 691 | + * characters, e.g. "\u200b". |
|
| 692 | + * |
|
| 693 | + * @return string[] |
|
| 694 | + */ |
|
| 695 | 695 | public static function getControlCharactersAsJSON() |
| 696 | 696 | { |
| 697 | 697 | $chars = self::getControlCharactersAsHex(); |
@@ -748,20 +748,20 @@ discard block |
||
| 748 | 748 | return preg_replace(self::$controlCharsRegex, '', $string); |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | - /** |
|
| 752 | - * Converts a unicode character to the PHPO notation. |
|
| 753 | - * |
|
| 754 | - * Example: |
|
| 755 | - * |
|
| 756 | - * <pre>unicodeChar2php('"\u0000"')</pre> |
|
| 757 | - * |
|
| 758 | - * Returns |
|
| 759 | - * |
|
| 760 | - * <pre>\x0</pre> |
|
| 761 | - * |
|
| 762 | - * @param string $unicodeChar |
|
| 763 | - * @return string |
|
| 764 | - */ |
|
| 751 | + /** |
|
| 752 | + * Converts a unicode character to the PHPO notation. |
|
| 753 | + * |
|
| 754 | + * Example: |
|
| 755 | + * |
|
| 756 | + * <pre>unicodeChar2php('"\u0000"')</pre> |
|
| 757 | + * |
|
| 758 | + * Returns |
|
| 759 | + * |
|
| 760 | + * <pre>\x0</pre> |
|
| 761 | + * |
|
| 762 | + * @param string $unicodeChar |
|
| 763 | + * @return string |
|
| 764 | + */ |
|
| 765 | 765 | public static function unicodeChar2php($unicodeChar) |
| 766 | 766 | { |
| 767 | 767 | $unicodeChar = json_decode($unicodeChar); |
@@ -884,25 +884,25 @@ discard block |
||
| 884 | 884 | return 'false'; |
| 885 | 885 | } |
| 886 | 886 | |
| 887 | - /** |
|
| 888 | - * Converts an associative array with attribute name > value pairs |
|
| 889 | - * to an attribute string that can be used in an HTML tag. Empty |
|
| 890 | - * attribute values are ignored. |
|
| 891 | - * |
|
| 892 | - * Example: |
|
| 893 | - * |
|
| 894 | - * array2attributeString(array( |
|
| 895 | - * 'id' => 45, |
|
| 896 | - * 'href' => 'http://www.mistralys.com' |
|
| 897 | - * )); |
|
| 898 | - * |
|
| 899 | - * Result: |
|
| 900 | - * |
|
| 901 | - * id="45" href="http://www.mistralys.com" |
|
| 902 | - * |
|
| 903 | - * @param array $array |
|
| 904 | - * @return string |
|
| 905 | - */ |
|
| 887 | + /** |
|
| 888 | + * Converts an associative array with attribute name > value pairs |
|
| 889 | + * to an attribute string that can be used in an HTML tag. Empty |
|
| 890 | + * attribute values are ignored. |
|
| 891 | + * |
|
| 892 | + * Example: |
|
| 893 | + * |
|
| 894 | + * array2attributeString(array( |
|
| 895 | + * 'id' => 45, |
|
| 896 | + * 'href' => 'http://www.mistralys.com' |
|
| 897 | + * )); |
|
| 898 | + * |
|
| 899 | + * Result: |
|
| 900 | + * |
|
| 901 | + * id="45" href="http://www.mistralys.com" |
|
| 902 | + * |
|
| 903 | + * @param array $array |
|
| 904 | + * @return string |
|
| 905 | + */ |
|
| 906 | 906 | public static function array2attributeString($array) |
| 907 | 907 | { |
| 908 | 908 | $tokens = array(); |
@@ -921,14 +921,14 @@ discard block |
||
| 921 | 921 | return ' '.implode(' ', $tokens); |
| 922 | 922 | } |
| 923 | 923 | |
| 924 | - /** |
|
| 925 | - * Converts a string so it can safely be used in a javascript |
|
| 926 | - * statement in an HTML tag: uses single quotes around the string |
|
| 927 | - * and encodes all special characters as needed. |
|
| 928 | - * |
|
| 929 | - * @param string $string |
|
| 930 | - * @return string |
|
| 931 | - */ |
|
| 924 | + /** |
|
| 925 | + * Converts a string so it can safely be used in a javascript |
|
| 926 | + * statement in an HTML tag: uses single quotes around the string |
|
| 927 | + * and encodes all special characters as needed. |
|
| 928 | + * |
|
| 929 | + * @param string $string |
|
| 930 | + * @return string |
|
| 931 | + */ |
|
| 932 | 932 | public static function string2attributeJS($string, $quoted=true) |
| 933 | 933 | { |
| 934 | 934 | $converted = addslashes(htmlspecialchars(strip_tags($string), ENT_QUOTES, 'UTF-8')); |
@@ -939,15 +939,15 @@ discard block |
||
| 939 | 939 | return $converted; |
| 940 | 940 | } |
| 941 | 941 | |
| 942 | - /** |
|
| 943 | - * Checks if the specified string is a boolean value, which |
|
| 944 | - * includes string representations of boolean values, like |
|
| 945 | - * <code>yes</code> or <code>no</code>, and <code>true</code> |
|
| 946 | - * or <code>false</code>. |
|
| 947 | - * |
|
| 948 | - * @param mixed $value |
|
| 949 | - * @return boolean |
|
| 950 | - */ |
|
| 942 | + /** |
|
| 943 | + * Checks if the specified string is a boolean value, which |
|
| 944 | + * includes string representations of boolean values, like |
|
| 945 | + * <code>yes</code> or <code>no</code>, and <code>true</code> |
|
| 946 | + * or <code>false</code>. |
|
| 947 | + * |
|
| 948 | + * @param mixed $value |
|
| 949 | + * @return boolean |
|
| 950 | + */ |
|
| 951 | 951 | public static function isBoolean($value) : bool |
| 952 | 952 | { |
| 953 | 953 | if(is_bool($value)) { |
@@ -961,12 +961,12 @@ discard block |
||
| 961 | 961 | return array_key_exists($value, self::$booleanStrings); |
| 962 | 962 | } |
| 963 | 963 | |
| 964 | - /** |
|
| 965 | - * Converts an associative array to an HTML style attribute value string. |
|
| 966 | - * |
|
| 967 | - * @param array $subject |
|
| 968 | - * @return string |
|
| 969 | - */ |
|
| 964 | + /** |
|
| 965 | + * Converts an associative array to an HTML style attribute value string. |
|
| 966 | + * |
|
| 967 | + * @param array $subject |
|
| 968 | + * @return string |
|
| 969 | + */ |
|
| 970 | 970 | public static function array2styleString(array $subject) : string |
| 971 | 971 | { |
| 972 | 972 | $tokens = array(); |
@@ -977,23 +977,23 @@ discard block |
||
| 977 | 977 | return implode(';', $tokens); |
| 978 | 978 | } |
| 979 | 979 | |
| 980 | - /** |
|
| 981 | - * Converts a DateTime object to a timestamp, which |
|
| 982 | - * is PHP 5.2 compatible. |
|
| 983 | - * |
|
| 984 | - * @param \DateTime $date |
|
| 985 | - * @return integer |
|
| 986 | - */ |
|
| 980 | + /** |
|
| 981 | + * Converts a DateTime object to a timestamp, which |
|
| 982 | + * is PHP 5.2 compatible. |
|
| 983 | + * |
|
| 984 | + * @param \DateTime $date |
|
| 985 | + * @return integer |
|
| 986 | + */ |
|
| 987 | 987 | public static function date2timestamp(\DateTime $date) : int |
| 988 | 988 | { |
| 989 | 989 | return (int)$date->format('U'); |
| 990 | 990 | } |
| 991 | 991 | |
| 992 | - /** |
|
| 993 | - * Converts a timestamp into a DateTime instance. |
|
| 994 | - * @param int $timestamp |
|
| 995 | - * @return \DateTime |
|
| 996 | - */ |
|
| 992 | + /** |
|
| 993 | + * Converts a timestamp into a DateTime instance. |
|
| 994 | + * @param int $timestamp |
|
| 995 | + * @return \DateTime |
|
| 996 | + */ |
|
| 997 | 997 | public static function timestamp2date(int $timestamp) : \DateTime |
| 998 | 998 | { |
| 999 | 999 | $date = new \DateTime(); |
@@ -1001,50 +1001,50 @@ discard block |
||
| 1001 | 1001 | return $date; |
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | - /** |
|
| 1005 | - * Strips an absolute path to a file within the application |
|
| 1006 | - * to make the path relative to the application root path. |
|
| 1007 | - * |
|
| 1008 | - * @param string $path |
|
| 1009 | - * @return string |
|
| 1010 | - * |
|
| 1011 | - * @see FileHelper::relativizePath() |
|
| 1012 | - * @see FileHelper::relativizePathByDepth() |
|
| 1013 | - */ |
|
| 1004 | + /** |
|
| 1005 | + * Strips an absolute path to a file within the application |
|
| 1006 | + * to make the path relative to the application root path. |
|
| 1007 | + * |
|
| 1008 | + * @param string $path |
|
| 1009 | + * @return string |
|
| 1010 | + * |
|
| 1011 | + * @see FileHelper::relativizePath() |
|
| 1012 | + * @see FileHelper::relativizePathByDepth() |
|
| 1013 | + */ |
|
| 1014 | 1014 | public static function fileRelativize(string $path) : string |
| 1015 | 1015 | { |
| 1016 | 1016 | return FileHelper::relativizePathByDepth($path); |
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | 1019 | /** |
| 1020 | - * Converts a PHP regex to a javascript RegExp object statement. |
|
| 1021 | - * |
|
| 1022 | - * NOTE: This is an alias for the JSHelper's `convertRegex` method. |
|
| 1023 | - * More details are available on its usage there. |
|
| 1024 | - * |
|
| 1025 | - * @param string $regex A PHP preg regex |
|
| 1026 | - * @param string $statementType The type of statement to return: Defaults to a statement to create a RegExp object. |
|
| 1027 | - * @return array|string Depending on the specified return type. |
|
| 1028 | - * |
|
| 1029 | - * @see JSHelper::buildRegexStatement() |
|
| 1030 | - */ |
|
| 1020 | + * Converts a PHP regex to a javascript RegExp object statement. |
|
| 1021 | + * |
|
| 1022 | + * NOTE: This is an alias for the JSHelper's `convertRegex` method. |
|
| 1023 | + * More details are available on its usage there. |
|
| 1024 | + * |
|
| 1025 | + * @param string $regex A PHP preg regex |
|
| 1026 | + * @param string $statementType The type of statement to return: Defaults to a statement to create a RegExp object. |
|
| 1027 | + * @return array|string Depending on the specified return type. |
|
| 1028 | + * |
|
| 1029 | + * @see JSHelper::buildRegexStatement() |
|
| 1030 | + */ |
|
| 1031 | 1031 | public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT) |
| 1032 | 1032 | { |
| 1033 | 1033 | return JSHelper::buildRegexStatement($regex, $statementType); |
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | - /** |
|
| 1037 | - * Converts the specified variable to JSON. Works just |
|
| 1038 | - * like the native `json_encode` method, except that it |
|
| 1039 | - * will trigger an exception on failure, which has the |
|
| 1040 | - * json error details included in its developer details. |
|
| 1041 | - * |
|
| 1042 | - * @param mixed $variable |
|
| 1043 | - * @param int|NULL $options JSON encode options. |
|
| 1044 | - * @param int|NULL $depth |
|
| 1045 | - * @throws ConvertHelper_Exception |
|
| 1046 | - * @return string |
|
| 1047 | - */ |
|
| 1036 | + /** |
|
| 1037 | + * Converts the specified variable to JSON. Works just |
|
| 1038 | + * like the native `json_encode` method, except that it |
|
| 1039 | + * will trigger an exception on failure, which has the |
|
| 1040 | + * json error details included in its developer details. |
|
| 1041 | + * |
|
| 1042 | + * @param mixed $variable |
|
| 1043 | + * @param int|NULL $options JSON encode options. |
|
| 1044 | + * @param int|NULL $depth |
|
| 1045 | + * @throws ConvertHelper_Exception |
|
| 1046 | + * @return string |
|
| 1047 | + */ |
|
| 1048 | 1048 | public static function var2json($variable, int $options=0, int $depth=512) : string |
| 1049 | 1049 | { |
| 1050 | 1050 | $result = json_encode($variable, $options, $depth); |
@@ -1065,12 +1065,12 @@ discard block |
||
| 1065 | 1065 | ); |
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 1068 | - /** |
|
| 1069 | - * Strips all known UTF byte order marks from the specified string. |
|
| 1070 | - * |
|
| 1071 | - * @param string $string |
|
| 1072 | - * @return string |
|
| 1073 | - */ |
|
| 1068 | + /** |
|
| 1069 | + * Strips all known UTF byte order marks from the specified string. |
|
| 1070 | + * |
|
| 1071 | + * @param string $string |
|
| 1072 | + * @return string |
|
| 1073 | + */ |
|
| 1074 | 1074 | public static function stripUTFBom($string) |
| 1075 | 1075 | { |
| 1076 | 1076 | $boms = FileHelper::getUTFBOMs(); |
@@ -1085,13 +1085,13 @@ discard block |
||
| 1085 | 1085 | return $string; |
| 1086 | 1086 | } |
| 1087 | 1087 | |
| 1088 | - /** |
|
| 1089 | - * Converts a string to valid utf8, regardless |
|
| 1090 | - * of the string's encoding(s). |
|
| 1091 | - * |
|
| 1092 | - * @param string $string |
|
| 1093 | - * @return string |
|
| 1094 | - */ |
|
| 1088 | + /** |
|
| 1089 | + * Converts a string to valid utf8, regardless |
|
| 1090 | + * of the string's encoding(s). |
|
| 1091 | + * |
|
| 1092 | + * @param string $string |
|
| 1093 | + * @return string |
|
| 1094 | + */ |
|
| 1095 | 1095 | public static function string2utf8($string) |
| 1096 | 1096 | { |
| 1097 | 1097 | if(!self::isStringASCII($string)) { |
@@ -1101,15 +1101,15 @@ discard block |
||
| 1101 | 1101 | return $string; |
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | - /** |
|
| 1105 | - * Checks whether the specified string is an ASCII |
|
| 1106 | - * string, without any special or UTF8 characters. |
|
| 1107 | - * Note: empty strings and NULL are considered ASCII. |
|
| 1108 | - * Any variable types other than strings are not. |
|
| 1109 | - * |
|
| 1110 | - * @param string $string |
|
| 1111 | - * @return boolean |
|
| 1112 | - */ |
|
| 1104 | + /** |
|
| 1105 | + * Checks whether the specified string is an ASCII |
|
| 1106 | + * string, without any special or UTF8 characters. |
|
| 1107 | + * Note: empty strings and NULL are considered ASCII. |
|
| 1108 | + * Any variable types other than strings are not. |
|
| 1109 | + * |
|
| 1110 | + * @param string $string |
|
| 1111 | + * @return boolean |
|
| 1112 | + */ |
|
| 1113 | 1113 | public static function isStringASCII($string) |
| 1114 | 1114 | { |
| 1115 | 1115 | if($string === '' || $string === NULL) { |
@@ -1134,22 +1134,22 @@ discard block |
||
| 1134 | 1134 | return $url; |
| 1135 | 1135 | } |
| 1136 | 1136 | |
| 1137 | - /** |
|
| 1138 | - * Calculates a percentage match of the source string with the target string. |
|
| 1139 | - * |
|
| 1140 | - * Options are: |
|
| 1141 | - * |
|
| 1142 | - * - maxLevenshtein, default: 10 |
|
| 1143 | - * Any levenshtein results above this value are ignored. |
|
| 1144 | - * |
|
| 1145 | - * - precision, default: 1 |
|
| 1146 | - * The precision of the percentage float value |
|
| 1147 | - * |
|
| 1148 | - * @param string $source |
|
| 1149 | - * @param string $target |
|
| 1150 | - * @param array $options |
|
| 1151 | - * @return float |
|
| 1152 | - */ |
|
| 1137 | + /** |
|
| 1138 | + * Calculates a percentage match of the source string with the target string. |
|
| 1139 | + * |
|
| 1140 | + * Options are: |
|
| 1141 | + * |
|
| 1142 | + * - maxLevenshtein, default: 10 |
|
| 1143 | + * Any levenshtein results above this value are ignored. |
|
| 1144 | + * |
|
| 1145 | + * - precision, default: 1 |
|
| 1146 | + * The precision of the percentage float value |
|
| 1147 | + * |
|
| 1148 | + * @param string $source |
|
| 1149 | + * @param string $target |
|
| 1150 | + * @param array $options |
|
| 1151 | + * @return float |
|
| 1152 | + */ |
|
| 1153 | 1153 | public static function matchString($source, $target, $options=array()) |
| 1154 | 1154 | { |
| 1155 | 1155 | $defaults = array( |
@@ -1233,60 +1233,60 @@ discard block |
||
| 1233 | 1233 | |
| 1234 | 1234 | const INTERVAL_SECONDS = 'seconds'; |
| 1235 | 1235 | |
| 1236 | - /** |
|
| 1237 | - * Converts an interval to its total amount of days. |
|
| 1238 | - * @param \DateInterval $interval |
|
| 1239 | - * @return int |
|
| 1240 | - */ |
|
| 1236 | + /** |
|
| 1237 | + * Converts an interval to its total amount of days. |
|
| 1238 | + * @param \DateInterval $interval |
|
| 1239 | + * @return int |
|
| 1240 | + */ |
|
| 1241 | 1241 | public static function interval2days(\DateInterval $interval) : int |
| 1242 | 1242 | { |
| 1243 | 1243 | return self::interval2total($interval, self::INTERVAL_DAYS); |
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | - /** |
|
| 1247 | - * Converts an interval to its total amount of hours. |
|
| 1248 | - * @param \DateInterval $interval |
|
| 1249 | - * @return int |
|
| 1250 | - */ |
|
| 1246 | + /** |
|
| 1247 | + * Converts an interval to its total amount of hours. |
|
| 1248 | + * @param \DateInterval $interval |
|
| 1249 | + * @return int |
|
| 1250 | + */ |
|
| 1251 | 1251 | public static function interval2hours(\DateInterval $interval) : int |
| 1252 | 1252 | { |
| 1253 | 1253 | return self::interval2total($interval, self::INTERVAL_HOURS); |
| 1254 | 1254 | } |
| 1255 | 1255 | |
| 1256 | - /** |
|
| 1257 | - * Converts an interval to its total amount of minutes. |
|
| 1258 | - * @param \DateInterval $interval |
|
| 1259 | - * @return int |
|
| 1260 | - */ |
|
| 1256 | + /** |
|
| 1257 | + * Converts an interval to its total amount of minutes. |
|
| 1258 | + * @param \DateInterval $interval |
|
| 1259 | + * @return int |
|
| 1260 | + */ |
|
| 1261 | 1261 | public static function interval2minutes(\DateInterval $interval) : int |
| 1262 | 1262 | { |
| 1263 | 1263 | return self::interval2total($interval, self::INTERVAL_MINUTES); |
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | - /** |
|
| 1267 | - * Converts an interval to its total amount of seconds. |
|
| 1268 | - * @param \DateInterval $interval |
|
| 1269 | - * @return int |
|
| 1270 | - */ |
|
| 1266 | + /** |
|
| 1267 | + * Converts an interval to its total amount of seconds. |
|
| 1268 | + * @param \DateInterval $interval |
|
| 1269 | + * @return int |
|
| 1270 | + */ |
|
| 1271 | 1271 | public static function interval2seconds(\DateInterval $interval) : int |
| 1272 | 1272 | { |
| 1273 | 1273 | return self::interval2total($interval, self::INTERVAL_SECONDS); |
| 1274 | 1274 | } |
| 1275 | 1275 | |
| 1276 | - /** |
|
| 1277 | - * Calculates the total amount of days / hours / minutes or seconds |
|
| 1278 | - * of a date interval object (depending in the specified units), and |
|
| 1279 | - * returns the total amount. |
|
| 1280 | - * |
|
| 1281 | - * @param \DateInterval $interval |
|
| 1282 | - * @param string $unit What total value to calculate. |
|
| 1283 | - * @return integer |
|
| 1284 | - * |
|
| 1285 | - * @see ConvertHelper::INTERVAL_SECONDS |
|
| 1286 | - * @see ConvertHelper::INTERVAL_MINUTES |
|
| 1287 | - * @see ConvertHelper::INTERVAL_HOURS |
|
| 1288 | - * @see ConvertHelper::INTERVAL_DAYS |
|
| 1289 | - */ |
|
| 1276 | + /** |
|
| 1277 | + * Calculates the total amount of days / hours / minutes or seconds |
|
| 1278 | + * of a date interval object (depending in the specified units), and |
|
| 1279 | + * returns the total amount. |
|
| 1280 | + * |
|
| 1281 | + * @param \DateInterval $interval |
|
| 1282 | + * @param string $unit What total value to calculate. |
|
| 1283 | + * @return integer |
|
| 1284 | + * |
|
| 1285 | + * @see ConvertHelper::INTERVAL_SECONDS |
|
| 1286 | + * @see ConvertHelper::INTERVAL_MINUTES |
|
| 1287 | + * @see ConvertHelper::INTERVAL_HOURS |
|
| 1288 | + * @see ConvertHelper::INTERVAL_DAYS |
|
| 1289 | + */ |
|
| 1290 | 1290 | public static function interval2total(\DateInterval $interval, $unit=self::INTERVAL_SECONDS) : int |
| 1291 | 1291 | { |
| 1292 | 1292 | $total = $interval->format('%a'); |
@@ -1326,13 +1326,13 @@ discard block |
||
| 1326 | 1326 | 'Sunday' |
| 1327 | 1327 | ); |
| 1328 | 1328 | |
| 1329 | - /** |
|
| 1330 | - * Converts a date to the corresponding day name. |
|
| 1331 | - * |
|
| 1332 | - * @param \DateTime $date |
|
| 1333 | - * @param string $short |
|
| 1334 | - * @return string|NULL |
|
| 1335 | - */ |
|
| 1329 | + /** |
|
| 1330 | + * Converts a date to the corresponding day name. |
|
| 1331 | + * |
|
| 1332 | + * @param \DateTime $date |
|
| 1333 | + * @param string $short |
|
| 1334 | + * @return string|NULL |
|
| 1335 | + */ |
|
| 1336 | 1336 | public static function date2dayName(\DateTime $date, $short=false) |
| 1337 | 1337 | { |
| 1338 | 1338 | $day = $date->format('l'); |
@@ -1347,21 +1347,21 @@ discard block |
||
| 1347 | 1347 | return null; |
| 1348 | 1348 | } |
| 1349 | 1349 | |
| 1350 | - /** |
|
| 1351 | - * Retrieves a list of english day names. |
|
| 1352 | - * @return string[] |
|
| 1353 | - */ |
|
| 1350 | + /** |
|
| 1351 | + * Retrieves a list of english day names. |
|
| 1352 | + * @return string[] |
|
| 1353 | + */ |
|
| 1354 | 1354 | public static function getDayNamesInvariant() |
| 1355 | 1355 | { |
| 1356 | 1356 | return self::$daysInvariant; |
| 1357 | 1357 | } |
| 1358 | 1358 | |
| 1359 | - /** |
|
| 1360 | - * Retrieves the day names list for the current locale. |
|
| 1361 | - * |
|
| 1362 | - * @param string $short |
|
| 1363 | - * @return string[] |
|
| 1364 | - */ |
|
| 1359 | + /** |
|
| 1360 | + * Retrieves the day names list for the current locale. |
|
| 1361 | + * |
|
| 1362 | + * @param string $short |
|
| 1363 | + * @return string[] |
|
| 1364 | + */ |
|
| 1365 | 1365 | public static function getDayNames($short=false) |
| 1366 | 1366 | { |
| 1367 | 1367 | if($short) { |
@@ -1421,16 +1421,16 @@ discard block |
||
| 1421 | 1421 | return $last; |
| 1422 | 1422 | } |
| 1423 | 1423 | |
| 1424 | - /** |
|
| 1425 | - * Splits a string into an array of all characters it is composed of. |
|
| 1426 | - * Unicode character safe. |
|
| 1427 | - * |
|
| 1428 | - * NOTE: Spaces and newlines (both \r and \n) are also considered single |
|
| 1429 | - * characters. |
|
| 1430 | - * |
|
| 1431 | - * @param string $string |
|
| 1432 | - * @return array |
|
| 1433 | - */ |
|
| 1424 | + /** |
|
| 1425 | + * Splits a string into an array of all characters it is composed of. |
|
| 1426 | + * Unicode character safe. |
|
| 1427 | + * |
|
| 1428 | + * NOTE: Spaces and newlines (both \r and \n) are also considered single |
|
| 1429 | + * characters. |
|
| 1430 | + * |
|
| 1431 | + * @param string $string |
|
| 1432 | + * @return array |
|
| 1433 | + */ |
|
| 1434 | 1434 | public static function string2array(string $string) : array |
| 1435 | 1435 | { |
| 1436 | 1436 | $result = preg_split('//u', $string, null, PREG_SPLIT_NO_EMPTY); |
@@ -1441,12 +1441,12 @@ discard block |
||
| 1441 | 1441 | return array(); |
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | - /** |
|
| 1445 | - * Checks whether the specified string contains HTML code. |
|
| 1446 | - * |
|
| 1447 | - * @param string $string |
|
| 1448 | - * @return boolean |
|
| 1449 | - */ |
|
| 1444 | + /** |
|
| 1445 | + * Checks whether the specified string contains HTML code. |
|
| 1446 | + * |
|
| 1447 | + * @param string $string |
|
| 1448 | + * @return boolean |
|
| 1449 | + */ |
|
| 1450 | 1450 | public static function isStringHTML(string $string) : bool |
| 1451 | 1451 | { |
| 1452 | 1452 | if(preg_match('%<[a-z/][\s\S]*>%siU', $string)) { |
@@ -1461,18 +1461,18 @@ discard block |
||
| 1461 | 1461 | return false; |
| 1462 | 1462 | } |
| 1463 | 1463 | |
| 1464 | - /** |
|
| 1465 | - * UTF8-safe wordwrap method: works like the regular wordwrap |
|
| 1466 | - * PHP function but compatible with UTF8. Otherwise the lengths |
|
| 1467 | - * are no calculated correctly. |
|
| 1468 | - * |
|
| 1469 | - * @param string $str |
|
| 1470 | - * @param int $width |
|
| 1471 | - * @param string $break |
|
| 1472 | - * @param bool $cut |
|
| 1473 | - * @return string |
|
| 1474 | - * @see https://stackoverflow.com/a/4988494/2298192 |
|
| 1475 | - */ |
|
| 1464 | + /** |
|
| 1465 | + * UTF8-safe wordwrap method: works like the regular wordwrap |
|
| 1466 | + * PHP function but compatible with UTF8. Otherwise the lengths |
|
| 1467 | + * are no calculated correctly. |
|
| 1468 | + * |
|
| 1469 | + * @param string $str |
|
| 1470 | + * @param int $width |
|
| 1471 | + * @param string $break |
|
| 1472 | + * @param bool $cut |
|
| 1473 | + * @return string |
|
| 1474 | + * @see https://stackoverflow.com/a/4988494/2298192 |
|
| 1475 | + */ |
|
| 1476 | 1476 | public static function wordwrap($str, $width = 75, $break = "\n", $cut = false) |
| 1477 | 1477 | { |
| 1478 | 1478 | $lines = explode($break, $str); |
@@ -1518,27 +1518,27 @@ discard block |
||
| 1518 | 1518 | return implode($break, $lines); |
| 1519 | 1519 | } |
| 1520 | 1520 | |
| 1521 | - /** |
|
| 1522 | - * Calculates the byte length of a string, taking into |
|
| 1523 | - * account any unicode characters. |
|
| 1524 | - * |
|
| 1525 | - * @param string $string |
|
| 1526 | - * @return int |
|
| 1527 | - * @see https://stackoverflow.com/a/9718273/2298192 |
|
| 1528 | - */ |
|
| 1521 | + /** |
|
| 1522 | + * Calculates the byte length of a string, taking into |
|
| 1523 | + * account any unicode characters. |
|
| 1524 | + * |
|
| 1525 | + * @param string $string |
|
| 1526 | + * @return int |
|
| 1527 | + * @see https://stackoverflow.com/a/9718273/2298192 |
|
| 1528 | + */ |
|
| 1529 | 1529 | public static function string2bytes($string) |
| 1530 | 1530 | { |
| 1531 | 1531 | return mb_strlen($string, '8bit'); |
| 1532 | 1532 | } |
| 1533 | 1533 | |
| 1534 | - /** |
|
| 1535 | - * Creates a short, 8-character long hash for the specified string. |
|
| 1536 | - * |
|
| 1537 | - * WARNING: Not cryptographically safe. |
|
| 1538 | - * |
|
| 1539 | - * @param string $string |
|
| 1540 | - * @return string |
|
| 1541 | - */ |
|
| 1534 | + /** |
|
| 1535 | + * Creates a short, 8-character long hash for the specified string. |
|
| 1536 | + * |
|
| 1537 | + * WARNING: Not cryptographically safe. |
|
| 1538 | + * |
|
| 1539 | + * @param string $string |
|
| 1540 | + * @return string |
|
| 1541 | + */ |
|
| 1542 | 1542 | public static function string2shortHash($string) |
| 1543 | 1543 | { |
| 1544 | 1544 | return hash('crc32', $string, false); |
@@ -1564,23 +1564,23 @@ discard block |
||
| 1564 | 1564 | return ConvertHelper_ThrowableInfo::fromThrowable($e); |
| 1565 | 1565 | } |
| 1566 | 1566 | |
| 1567 | - /** |
|
| 1568 | - * Parses the specified query string like the native |
|
| 1569 | - * function <code>parse_str</code>, without the key |
|
| 1570 | - * naming limitations. |
|
| 1571 | - * |
|
| 1572 | - * Using parse_str, dots or spaces in key names are |
|
| 1573 | - * replaced by underscores. This method keeps all names |
|
| 1574 | - * intact. |
|
| 1575 | - * |
|
| 1576 | - * It still uses the parse_str implementation as it |
|
| 1577 | - * is tested and tried, but fixes the parameter names |
|
| 1578 | - * after parsing, as needed. |
|
| 1579 | - * |
|
| 1580 | - * @param string $queryString |
|
| 1581 | - * @return array |
|
| 1582 | - * @see https://www.php.net/manual/en/function.parse-str.php |
|
| 1583 | - */ |
|
| 1567 | + /** |
|
| 1568 | + * Parses the specified query string like the native |
|
| 1569 | + * function <code>parse_str</code>, without the key |
|
| 1570 | + * naming limitations. |
|
| 1571 | + * |
|
| 1572 | + * Using parse_str, dots or spaces in key names are |
|
| 1573 | + * replaced by underscores. This method keeps all names |
|
| 1574 | + * intact. |
|
| 1575 | + * |
|
| 1576 | + * It still uses the parse_str implementation as it |
|
| 1577 | + * is tested and tried, but fixes the parameter names |
|
| 1578 | + * after parsing, as needed. |
|
| 1579 | + * |
|
| 1580 | + * @param string $queryString |
|
| 1581 | + * @return array |
|
| 1582 | + * @see https://www.php.net/manual/en/function.parse-str.php |
|
| 1583 | + */ |
|
| 1584 | 1584 | public static function parseQueryString(string $queryString) : array |
| 1585 | 1585 | { |
| 1586 | 1586 | // allow HTML entities notation |
@@ -1620,16 +1620,16 @@ discard block |
||
| 1620 | 1620 | $placeholders = array(); |
| 1621 | 1621 | foreach($paramNames as $paramName) |
| 1622 | 1622 | { |
| 1623 | - // create a unique placeholder name |
|
| 1624 | - $placeholder = '__PLACEHOLDER'.$counter.'__'; |
|
| 1623 | + // create a unique placeholder name |
|
| 1624 | + $placeholder = '__PLACEHOLDER'.$counter.'__'; |
|
| 1625 | 1625 | |
| 1626 | - // store the placeholder name to replace later |
|
| 1627 | - $table[$placeholder] = $paramName; |
|
| 1626 | + // store the placeholder name to replace later |
|
| 1627 | + $table[$placeholder] = $paramName; |
|
| 1628 | 1628 | |
| 1629 | - // add the placeholder to replace in the query string before parsing |
|
| 1630 | - $placeholders[$paramName.'='] = $placeholder.'='; |
|
| 1629 | + // add the placeholder to replace in the query string before parsing |
|
| 1630 | + $placeholders[$paramName.'='] = $placeholder.'='; |
|
| 1631 | 1631 | |
| 1632 | - $counter++; |
|
| 1632 | + $counter++; |
|
| 1633 | 1633 | } |
| 1634 | 1634 | |
| 1635 | 1635 | // next challenge: replacing the parameter names by placeholders |
@@ -1656,23 +1656,23 @@ discard block |
||
| 1656 | 1656 | |
| 1657 | 1657 | foreach($parsed as $name => $value) |
| 1658 | 1658 | { |
| 1659 | - $keep[$table[$name]] = $value; |
|
| 1659 | + $keep[$table[$name]] = $value; |
|
| 1660 | 1660 | } |
| 1661 | 1661 | |
| 1662 | 1662 | return $keep; |
| 1663 | 1663 | } |
| 1664 | 1664 | |
| 1665 | - /** |
|
| 1666 | - * Searches for needle in the specified string, and returns a list |
|
| 1667 | - * of all occurrences, including the matched string. The matched |
|
| 1668 | - * string is useful when doing a case insensitive search, as it |
|
| 1669 | - * shows the exact matched case of needle. |
|
| 1670 | - * |
|
| 1671 | - * @param string $needle |
|
| 1672 | - * @param string $haystack |
|
| 1673 | - * @param bool $caseInsensitive |
|
| 1674 | - * @return ConvertHelper_StringMatch[] |
|
| 1675 | - */ |
|
| 1665 | + /** |
|
| 1666 | + * Searches for needle in the specified string, and returns a list |
|
| 1667 | + * of all occurrences, including the matched string. The matched |
|
| 1668 | + * string is useful when doing a case insensitive search, as it |
|
| 1669 | + * shows the exact matched case of needle. |
|
| 1670 | + * |
|
| 1671 | + * @param string $needle |
|
| 1672 | + * @param string $haystack |
|
| 1673 | + * @param bool $caseInsensitive |
|
| 1674 | + * @return ConvertHelper_StringMatch[] |
|
| 1675 | + */ |
|
| 1676 | 1676 | public static function findString(string $needle, string $haystack, bool $caseInsensitive=false) |
| 1677 | 1677 | { |
| 1678 | 1678 | if($needle === '') { |
@@ -1698,14 +1698,14 @@ discard block |
||
| 1698 | 1698 | return $positions; |
| 1699 | 1699 | } |
| 1700 | 1700 | |
| 1701 | - /** |
|
| 1702 | - * Like explode, but trims all entries, and removes |
|
| 1703 | - * empty entries from the resulting array. |
|
| 1704 | - * |
|
| 1705 | - * @param string $delimiter |
|
| 1706 | - * @param string $string |
|
| 1707 | - * @return string[] |
|
| 1708 | - */ |
|
| 1701 | + /** |
|
| 1702 | + * Like explode, but trims all entries, and removes |
|
| 1703 | + * empty entries from the resulting array. |
|
| 1704 | + * |
|
| 1705 | + * @param string $delimiter |
|
| 1706 | + * @param string $string |
|
| 1707 | + * @return string[] |
|
| 1708 | + */ |
|
| 1709 | 1709 | public static function explodeTrim(string $delimiter, string $string) : array |
| 1710 | 1710 | { |
| 1711 | 1711 | if(empty($string) || empty($delimiter)) { |
@@ -1727,12 +1727,12 @@ discard block |
||
| 1727 | 1727 | |
| 1728 | 1728 | protected static $eolChars; |
| 1729 | 1729 | |
| 1730 | - /** |
|
| 1731 | - * Detects the most used end-of-line character in the subject string. |
|
| 1732 | - * |
|
| 1733 | - * @param string $str The string to check. |
|
| 1734 | - * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected. |
|
| 1735 | - */ |
|
| 1730 | + /** |
|
| 1731 | + * Detects the most used end-of-line character in the subject string. |
|
| 1732 | + * |
|
| 1733 | + * @param string $str The string to check. |
|
| 1734 | + * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected. |
|
| 1735 | + */ |
|
| 1736 | 1736 | public static function detectEOLCharacter(string $subjectString) : ?ConvertHelper_EOL |
| 1737 | 1737 | { |
| 1738 | 1738 | if(empty($subjectString)) { |
@@ -1744,27 +1744,27 @@ discard block |
||
| 1744 | 1744 | $cr = chr((int)hexdec('0d')); |
| 1745 | 1745 | $lf = chr((int)hexdec('0a')); |
| 1746 | 1746 | |
| 1747 | - self::$eolChars = array( |
|
| 1748 | - array( |
|
| 1749 | - 'char' => $cr.$lf, |
|
| 1750 | - 'type' => ConvertHelper_EOL::TYPE_CRLF, |
|
| 1751 | - 'description' => t('Carriage return followed by a line feed'), |
|
| 1752 | - ), |
|
| 1753 | - array( |
|
| 1754 | - 'char' => $lf.$cr, |
|
| 1755 | - 'type' => ConvertHelper_EOL::TYPE_LFCR, |
|
| 1756 | - 'description' => t('Line feed followed by a carriage return'), |
|
| 1757 | - ), |
|
| 1758 | - array( |
|
| 1759 | - 'char' => $lf, |
|
| 1760 | - 'type' => ConvertHelper_EOL::TYPE_LF, |
|
| 1761 | - 'description' => t('Line feed'), |
|
| 1762 | - ), |
|
| 1763 | - array( |
|
| 1764 | - 'char' => $cr, |
|
| 1765 | - 'type' => ConvertHelper_EOL::TYPE_CR, |
|
| 1766 | - 'description' => t('Carriage Return'), |
|
| 1767 | - ), |
|
| 1747 | + self::$eolChars = array( |
|
| 1748 | + array( |
|
| 1749 | + 'char' => $cr.$lf, |
|
| 1750 | + 'type' => ConvertHelper_EOL::TYPE_CRLF, |
|
| 1751 | + 'description' => t('Carriage return followed by a line feed'), |
|
| 1752 | + ), |
|
| 1753 | + array( |
|
| 1754 | + 'char' => $lf.$cr, |
|
| 1755 | + 'type' => ConvertHelper_EOL::TYPE_LFCR, |
|
| 1756 | + 'description' => t('Line feed followed by a carriage return'), |
|
| 1757 | + ), |
|
| 1758 | + array( |
|
| 1759 | + 'char' => $lf, |
|
| 1760 | + 'type' => ConvertHelper_EOL::TYPE_LF, |
|
| 1761 | + 'description' => t('Line feed'), |
|
| 1762 | + ), |
|
| 1763 | + array( |
|
| 1764 | + 'char' => $cr, |
|
| 1765 | + 'type' => ConvertHelper_EOL::TYPE_CR, |
|
| 1766 | + 'description' => t('Carriage Return'), |
|
| 1767 | + ), |
|
| 1768 | 1768 | ); |
| 1769 | 1769 | } |
| 1770 | 1770 | |
@@ -1792,13 +1792,13 @@ discard block |
||
| 1792 | 1792 | ); |
| 1793 | 1793 | } |
| 1794 | 1794 | |
| 1795 | - /** |
|
| 1796 | - * Removes the specified keys from the target array, |
|
| 1797 | - * if they exist. |
|
| 1798 | - * |
|
| 1799 | - * @param array $array |
|
| 1800 | - * @param array $keys |
|
| 1801 | - */ |
|
| 1795 | + /** |
|
| 1796 | + * Removes the specified keys from the target array, |
|
| 1797 | + * if they exist. |
|
| 1798 | + * |
|
| 1799 | + * @param array $array |
|
| 1800 | + * @param array $keys |
|
| 1801 | + */ |
|
| 1802 | 1802 | public static function arrayRemoveKeys(array &$array, array $keys) : void |
| 1803 | 1803 | { |
| 1804 | 1804 | foreach($keys as $key) |
@@ -1809,13 +1809,13 @@ discard block |
||
| 1809 | 1809 | } |
| 1810 | 1810 | } |
| 1811 | 1811 | |
| 1812 | - /** |
|
| 1813 | - * Checks if the specified variable is an integer or a string containing an integer. |
|
| 1814 | - * Accepts both positive and negative integers. |
|
| 1815 | - * |
|
| 1816 | - * @param mixed $value |
|
| 1817 | - * @return bool |
|
| 1818 | - */ |
|
| 1812 | + /** |
|
| 1813 | + * Checks if the specified variable is an integer or a string containing an integer. |
|
| 1814 | + * Accepts both positive and negative integers. |
|
| 1815 | + * |
|
| 1816 | + * @param mixed $value |
|
| 1817 | + * @return bool |
|
| 1818 | + */ |
|
| 1819 | 1819 | public static function isInteger($value) : bool |
| 1820 | 1820 | { |
| 1821 | 1821 | if(is_int($value)) { |
@@ -1835,12 +1835,12 @@ discard block |
||
| 1835 | 1835 | return false; |
| 1836 | 1836 | } |
| 1837 | 1837 | |
| 1838 | - /** |
|
| 1839 | - * Converts an amount of seconds to a DateInterval object. |
|
| 1840 | - * |
|
| 1841 | - * @param int $seconds |
|
| 1842 | - * @return \DateInterval |
|
| 1843 | - */ |
|
| 1838 | + /** |
|
| 1839 | + * Converts an amount of seconds to a DateInterval object. |
|
| 1840 | + * |
|
| 1841 | + * @param int $seconds |
|
| 1842 | + * @return \DateInterval |
|
| 1843 | + */ |
|
| 1844 | 1844 | public static function seconds2interval(int $seconds) : \DateInterval |
| 1845 | 1845 | { |
| 1846 | 1846 | // The DateInterval::format() method does not recalculate carry |
@@ -1492,8 +1492,7 @@ |
||
| 1492 | 1492 | if (mb_strlen($actual.$word) <= $width) |
| 1493 | 1493 | { |
| 1494 | 1494 | $actual .= $word.' '; |
| 1495 | - } |
|
| 1496 | - else |
|
| 1495 | + } else |
|
| 1497 | 1496 | { |
| 1498 | 1497 | if ($actual != '') { |
| 1499 | 1498 | $line .= rtrim($actual).$break; |
@@ -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; |
@@ -590,59 +590,59 @@ discard block |
||
| 590 | 590 | |
| 591 | 591 | protected $postProcess = false; |
| 592 | 592 | |
| 593 | - /** |
|
| 594 | - * Called if explicitly enabled: allows filtering the |
|
| 595 | - * number after the detection process has completed. |
|
| 596 | - * |
|
| 597 | - * @param string|NULL $number The adjusted number |
|
| 598 | - * @param string $originalString The original value before it was parsed |
|
| 599 | - * @return mixed |
|
| 600 | - */ |
|
| 593 | + /** |
|
| 594 | + * Called if explicitly enabled: allows filtering the |
|
| 595 | + * number after the detection process has completed. |
|
| 596 | + * |
|
| 597 | + * @param string|NULL $number The adjusted number |
|
| 598 | + * @param string $originalString The original value before it was parsed |
|
| 599 | + * @return mixed |
|
| 600 | + */ |
|
| 601 | 601 | protected function postProcess(?string $number, /** @scrutinizer ignore-unused */ string $originalString) |
| 602 | 602 | { |
| 603 | 603 | return $number; |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | - /** |
|
| 607 | - * Filters the value before it is parsed, but only if it is a string. |
|
| 608 | - * |
|
| 609 | - * NOTE: This may be overwritten in a subclass, to allow custom filtering |
|
| 610 | - * the the values. An example of a use case would be a preprocessor for |
|
| 611 | - * variables in a templating system. |
|
| 612 | - * |
|
| 613 | - * @param string $trimmedString The trimmed value. |
|
| 614 | - * @param array $cache The internal values cache array. |
|
| 615 | - * @param string $originalValue The original value that the NumberInfo was created for. |
|
| 616 | - * @return string |
|
| 617 | - * |
|
| 618 | - * @see NumberInfo::enablePostProcess() |
|
| 619 | - */ |
|
| 606 | + /** |
|
| 607 | + * Filters the value before it is parsed, but only if it is a string. |
|
| 608 | + * |
|
| 609 | + * NOTE: This may be overwritten in a subclass, to allow custom filtering |
|
| 610 | + * the the values. An example of a use case would be a preprocessor for |
|
| 611 | + * variables in a templating system. |
|
| 612 | + * |
|
| 613 | + * @param string $trimmedString The trimmed value. |
|
| 614 | + * @param array $cache The internal values cache array. |
|
| 615 | + * @param string $originalValue The original value that the NumberInfo was created for. |
|
| 616 | + * @return string |
|
| 617 | + * |
|
| 618 | + * @see NumberInfo::enablePostProcess() |
|
| 619 | + */ |
|
| 620 | 620 | protected function preProcess(string $trimmedString, /** @scrutinizer ignore-unused */ array &$cache, /** @scrutinizer ignore-unused */ string $originalValue) : string |
| 621 | 621 | { |
| 622 | 622 | return str_replace(',', '.', $trimmedString); |
| 623 | 623 | } |
| 624 | 624 | |
| 625 | - /** |
|
| 626 | - * Enables the post processing so the postProcess method gets called. |
|
| 627 | - * This should be called in the {@link NumberInfo::preProcess()} |
|
| 628 | - * method as needed. |
|
| 629 | - * |
|
| 630 | - * @return NumberInfo |
|
| 631 | - * @see NumberInfo::postProcess() |
|
| 632 | - */ |
|
| 625 | + /** |
|
| 626 | + * Enables the post processing so the postProcess method gets called. |
|
| 627 | + * This should be called in the {@link NumberInfo::preProcess()} |
|
| 628 | + * method as needed. |
|
| 629 | + * |
|
| 630 | + * @return NumberInfo |
|
| 631 | + * @see NumberInfo::postProcess() |
|
| 632 | + */ |
|
| 633 | 633 | private function enablePostProcess() : NumberInfo |
| 634 | 634 | { |
| 635 | 635 | $this->postProcess = true; |
| 636 | 636 | return $this; |
| 637 | 637 | } |
| 638 | 638 | |
| 639 | - /** |
|
| 640 | - * Filters the number info array to adjust the units |
|
| 641 | - * and number according to the required rules. |
|
| 642 | - * |
|
| 643 | - * @param array $info |
|
| 644 | - * @return array |
|
| 645 | - */ |
|
| 639 | + /** |
|
| 640 | + * Filters the number info array to adjust the units |
|
| 641 | + * and number according to the required rules. |
|
| 642 | + * |
|
| 643 | + * @param array $info |
|
| 644 | + * @return array |
|
| 645 | + */ |
|
| 646 | 646 | protected function filterInfo(array $info) : array |
| 647 | 647 | { |
| 648 | 648 | $useUnits = 'px'; |