@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * @param int $tabSize The amount of spaces per tab. |
| 54 | 54 | * @return string |
| 55 | 55 | */ |
| 56 | - public static function tabs2spaces(string $string, int $tabSize=4) : string |
|
| 56 | + public static function tabs2spaces(string $string, int $tabSize = 4) : string |
|
| 57 | 57 | { |
| 58 | 58 | return str_replace("\t", str_repeat(' ', $tabSize), $string); |
| 59 | 59 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @param int $tabSize The amount of spaces per tab in the source string. |
| 66 | 66 | * @return string |
| 67 | 67 | */ |
| 68 | - public static function spaces2tabs(string $string, int $tabSize=4) : string |
|
| 68 | + public static function spaces2tabs(string $string, int $tabSize = 4) : string |
|
| 69 | 69 | { |
| 70 | 70 | return str_replace(str_repeat(' ', $tabSize), "\t", $string); |
| 71 | 71 | } |
@@ -125,10 +125,10 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | // specifically handle zero |
| 127 | 127 | if ($seconds <= 0) { |
| 128 | - return '0 ' . t('seconds'); |
|
| 128 | + return '0 '.t('seconds'); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if($seconds < 1) { |
|
| 131 | + if ($seconds < 1) { |
|
| 132 | 132 | return t('less than a second'); |
| 133 | 133 | } |
| 134 | 134 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | foreach ($units as $def) { |
| 137 | 137 | $quot = intval($seconds / $def['value']); |
| 138 | 138 | if ($quot) { |
| 139 | - $item = $quot . ' '; |
|
| 139 | + $item = $quot.' '; |
|
| 140 | 140 | if (abs($quot) > 1) { |
| 141 | 141 | $item .= $def['plural']; |
| 142 | 142 | } else { |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | return $last; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - return implode(', ', $tokens) . ' ' . t('and') . ' ' . $last; |
|
| 156 | + return implode(', ', $tokens).' '.t('and').' '.$last; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | { |
| 173 | 173 | $converter = new ConvertHelper_DurationConverter(); |
| 174 | 174 | |
| 175 | - if($datefrom instanceof \DateTime) |
|
| 175 | + if ($datefrom instanceof \DateTime) |
|
| 176 | 176 | { |
| 177 | 177 | $converter->setDateFrom($datefrom); |
| 178 | 178 | } |
@@ -181,11 +181,11 @@ discard block |
||
| 181 | 181 | $converter->setDateFrom(self::timestamp2date($datefrom)); |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - if($dateto instanceof \DateTime) |
|
| 184 | + if ($dateto instanceof \DateTime) |
|
| 185 | 185 | { |
| 186 | 186 | $converter->setDateTo($dateto); |
| 187 | 187 | } |
| 188 | - else if($dateto > 0) |
|
| 188 | + else if ($dateto > 0) |
|
| 189 | 189 | { |
| 190 | 190 | $converter->setDateTo(self::timestamp2date($dateto)); |
| 191 | 191 | } |
@@ -205,9 +205,9 @@ discard block |
||
| 205 | 205 | return $geshi->parse_code(); |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - public static function highlight_xml($xml, $formatSource=false) |
|
| 208 | + public static function highlight_xml($xml, $formatSource = false) |
|
| 209 | 209 | { |
| 210 | - if($formatSource) |
|
| 210 | + if ($formatSource) |
|
| 211 | 211 | { |
| 212 | 212 | $dom = new \DOMDocument(); |
| 213 | 213 | $dom->loadXML($xml); |
@@ -274,16 +274,16 @@ discard block |
||
| 274 | 274 | return $text; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - $text = trim(mb_substr($text, 0, $targetLength)) . $append; |
|
| 277 | + $text = trim(mb_substr($text, 0, $targetLength)).$append; |
|
| 278 | 278 | |
| 279 | 279 | return $text; |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - public static function var_dump($var, $html=true) : string |
|
| 282 | + public static function var_dump($var, $html = true) : string |
|
| 283 | 283 | { |
| 284 | 284 | $info = parseVariable($var); |
| 285 | 285 | |
| 286 | - if($html) { |
|
| 286 | + if ($html) { |
|
| 287 | 287 | return $info->toHTML(); |
| 288 | 288 | } |
| 289 | 289 | |
@@ -298,11 +298,11 @@ discard block |
||
| 298 | 298 | * @param bool $html Whether to style the dump as HTML. |
| 299 | 299 | * @return string |
| 300 | 300 | */ |
| 301 | - public static function print_r($var, bool $return=false, bool $html=true) : string |
|
| 301 | + public static function print_r($var, bool $return = false, bool $html = true) : string |
|
| 302 | 302 | { |
| 303 | 303 | $result = parseVariable($var)->enableType()->toString(); |
| 304 | 304 | |
| 305 | - if($html) |
|
| 305 | + if ($html) |
|
| 306 | 306 | { |
| 307 | 307 | $result = |
| 308 | 308 | '<pre style="background:#fff;color:#333;padding:16px;border:solid 1px #bbb;border-radius:4px">'. |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | '</pre>'; |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - if(!$return) |
|
| 313 | + if (!$return) |
|
| 314 | 314 | { |
| 315 | 315 | echo $result; |
| 316 | 316 | } |
@@ -338,17 +338,17 @@ discard block |
||
| 338 | 338 | */ |
| 339 | 339 | public static function string2bool($string) : bool |
| 340 | 340 | { |
| 341 | - if($string === '' || $string === null || !is_scalar($string)) |
|
| 341 | + if ($string === '' || $string === null || !is_scalar($string)) |
|
| 342 | 342 | { |
| 343 | 343 | return false; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - if(is_bool($string)) |
|
| 346 | + if (is_bool($string)) |
|
| 347 | 347 | { |
| 348 | 348 | return $string; |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - if(array_key_exists($string, self::$booleanStrings)) |
|
| 351 | + if (array_key_exists($string, self::$booleanStrings)) |
|
| 352 | 352 | { |
| 353 | 353 | return self::$booleanStrings[$string]; |
| 354 | 354 | } |
@@ -403,10 +403,10 @@ discard block |
||
| 403 | 403 | public static function date2listLabel(\DateTime $date, $includeTime = false, $shortMonth = false) |
| 404 | 404 | { |
| 405 | 405 | $today = new \DateTime(); |
| 406 | - if($date->format('d.m.Y') == $today->format('d.m.Y')) { |
|
| 406 | + if ($date->format('d.m.Y') == $today->format('d.m.Y')) { |
|
| 407 | 407 | $label = t('Today'); |
| 408 | 408 | } else { |
| 409 | - $label = $date->format('d') . '. ' . self::month2string((int)$date->format('m'), $shortMonth) . ' '; |
|
| 409 | + $label = $date->format('d').'. '.self::month2string((int)$date->format('m'), $shortMonth).' '; |
|
| 410 | 410 | if ($date->format('Y') != date('Y')) { |
| 411 | 411 | $label .= $date->format('Y'); |
| 412 | 412 | } |
@@ -566,12 +566,12 @@ discard block |
||
| 566 | 566 | $output = ''; |
| 567 | 567 | $split = str_split($unicodeChar); |
| 568 | 568 | |
| 569 | - foreach($split as $octet) |
|
| 569 | + foreach ($split as $octet) |
|
| 570 | 570 | { |
| 571 | 571 | $ordInt = ord($octet); |
| 572 | 572 | // Convert from int (base 10) to hex (base 16), for PHP \x syntax |
| 573 | 573 | $ordHex = base_convert((string)$ordInt, 10, 16); |
| 574 | - $output .= '\x' . $ordHex; |
|
| 574 | + $output .= '\x'.$ordHex; |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | return $output; |
@@ -604,19 +604,19 @@ discard block |
||
| 604 | 604 | |
| 605 | 605 | protected static function convertScalarForComparison($scalar) |
| 606 | 606 | { |
| 607 | - if($scalar === '' || is_null($scalar)) { |
|
| 607 | + if ($scalar === '' || is_null($scalar)) { |
|
| 608 | 608 | return null; |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | - if(is_bool($scalar)) { |
|
| 611 | + if (is_bool($scalar)) { |
|
| 612 | 612 | return self::bool2string($scalar); |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | - if(is_array($scalar)) { |
|
| 615 | + if (is_array($scalar)) { |
|
| 616 | 616 | $scalar = md5(serialize($scalar)); |
| 617 | 617 | } |
| 618 | 618 | |
| 619 | - if($scalar !== null && !is_scalar($scalar)) { |
|
| 619 | + if ($scalar !== null && !is_scalar($scalar)) { |
|
| 620 | 620 | throw new ConvertHelper_Exception( |
| 621 | 621 | 'Not a scalar value in comparison', |
| 622 | 622 | null, |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | public static function bool2string($boolean, bool $yesno = false) : string |
| 666 | 666 | { |
| 667 | 667 | // allow 'yes', 'true', 'no', 'false' string notations as well |
| 668 | - if(!is_bool($boolean)) { |
|
| 668 | + if (!is_bool($boolean)) { |
|
| 669 | 669 | $boolean = self::string2bool($boolean); |
| 670 | 670 | } |
| 671 | 671 | |
@@ -706,15 +706,15 @@ discard block |
||
| 706 | 706 | public static function array2attributeString($array) |
| 707 | 707 | { |
| 708 | 708 | $tokens = array(); |
| 709 | - foreach($array as $attr => $value) { |
|
| 710 | - if($value == '' || $value == null) { |
|
| 709 | + foreach ($array as $attr => $value) { |
|
| 710 | + if ($value == '' || $value == null) { |
|
| 711 | 711 | continue; |
| 712 | 712 | } |
| 713 | 713 | |
| 714 | 714 | $tokens[] = $attr.'="'.$value.'"'; |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | - if(empty($tokens)) { |
|
| 717 | + if (empty($tokens)) { |
|
| 718 | 718 | return ''; |
| 719 | 719 | } |
| 720 | 720 | |
@@ -729,10 +729,10 @@ discard block |
||
| 729 | 729 | * @param string $string |
| 730 | 730 | * @return string |
| 731 | 731 | */ |
| 732 | - public static function string2attributeJS($string, $quoted=true) |
|
| 732 | + public static function string2attributeJS($string, $quoted = true) |
|
| 733 | 733 | { |
| 734 | 734 | $converted = addslashes(htmlspecialchars(strip_tags($string), ENT_QUOTES, 'UTF-8')); |
| 735 | - if($quoted) { |
|
| 735 | + if ($quoted) { |
|
| 736 | 736 | $converted = "'".$converted."'"; |
| 737 | 737 | } |
| 738 | 738 | |
@@ -750,11 +750,11 @@ discard block |
||
| 750 | 750 | */ |
| 751 | 751 | public static function isBoolean($value) : bool |
| 752 | 752 | { |
| 753 | - if(is_bool($value)) { |
|
| 753 | + if (is_bool($value)) { |
|
| 754 | 754 | return true; |
| 755 | 755 | } |
| 756 | 756 | |
| 757 | - if(!is_scalar($value)) { |
|
| 757 | + if (!is_scalar($value)) { |
|
| 758 | 758 | return false; |
| 759 | 759 | } |
| 760 | 760 | |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | public static function array2styleString(array $subject) : string |
| 771 | 771 | { |
| 772 | 772 | $tokens = array(); |
| 773 | - foreach($subject as $name => $value) { |
|
| 773 | + foreach ($subject as $name => $value) { |
|
| 774 | 774 | $tokens[] = $name.':'.$value; |
| 775 | 775 | } |
| 776 | 776 | |
@@ -828,7 +828,7 @@ discard block |
||
| 828 | 828 | * |
| 829 | 829 | * @see JSHelper::buildRegexStatement() |
| 830 | 830 | */ |
| 831 | - public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT) |
|
| 831 | + public static function regex2js(string $regex, string $statementType = JSHelper::JS_REGEX_OBJECT) |
|
| 832 | 832 | { |
| 833 | 833 | return JSHelper::buildRegexStatement($regex, $statementType); |
| 834 | 834 | } |
@@ -845,11 +845,11 @@ discard block |
||
| 845 | 845 | * @throws ConvertHelper_Exception |
| 846 | 846 | * @return string |
| 847 | 847 | */ |
| 848 | - public static function var2json($variable, int $options=0, int $depth=512) : string |
|
| 848 | + public static function var2json($variable, int $options = 0, int $depth = 512) : string |
|
| 849 | 849 | { |
| 850 | 850 | $result = json_encode($variable, $options, $depth); |
| 851 | 851 | |
| 852 | - if($result !== false) { |
|
| 852 | + if ($result !== false) { |
|
| 853 | 853 | return $result; |
| 854 | 854 | } |
| 855 | 855 | |
@@ -874,10 +874,10 @@ discard block |
||
| 874 | 874 | public static function stripUTFBom($string) |
| 875 | 875 | { |
| 876 | 876 | $boms = FileHelper::getUTFBOMs(); |
| 877 | - foreach($boms as $bomChars) { |
|
| 877 | + foreach ($boms as $bomChars) { |
|
| 878 | 878 | $length = mb_strlen($bomChars); |
| 879 | 879 | $text = mb_substr($string, 0, $length); |
| 880 | - if($text==$bomChars) { |
|
| 880 | + if ($text == $bomChars) { |
|
| 881 | 881 | return mb_substr($string, $length); |
| 882 | 882 | } |
| 883 | 883 | } |
@@ -894,7 +894,7 @@ discard block |
||
| 894 | 894 | */ |
| 895 | 895 | public static function string2utf8($string) |
| 896 | 896 | { |
| 897 | - if(!self::isStringASCII($string)) { |
|
| 897 | + if (!self::isStringASCII($string)) { |
|
| 898 | 898 | return \ForceUTF8\Encoding::toUTF8($string); |
| 899 | 899 | } |
| 900 | 900 | |
@@ -912,11 +912,11 @@ discard block |
||
| 912 | 912 | */ |
| 913 | 913 | public static function isStringASCII($string) : bool |
| 914 | 914 | { |
| 915 | - if($string === '' || $string === NULL) { |
|
| 915 | + if ($string === '' || $string === NULL) { |
|
| 916 | 916 | return true; |
| 917 | 917 | } |
| 918 | 918 | |
| 919 | - if(!is_string($string)) { |
|
| 919 | + if (!is_string($string)) { |
|
| 920 | 920 | return false; |
| 921 | 921 | } |
| 922 | 922 | |
@@ -950,7 +950,7 @@ discard block |
||
| 950 | 950 | * @param array $options |
| 951 | 951 | * @return float |
| 952 | 952 | */ |
| 953 | - public static function matchString($source, $target, $options=array()) |
|
| 953 | + public static function matchString($source, $target, $options = array()) |
|
| 954 | 954 | { |
| 955 | 955 | $defaults = array( |
| 956 | 956 | 'maxLevenshtein' => 10, |
@@ -960,12 +960,12 @@ discard block |
||
| 960 | 960 | $options = array_merge($defaults, $options); |
| 961 | 961 | |
| 962 | 962 | // avoid doing this via levenshtein |
| 963 | - if($source == $target) { |
|
| 963 | + if ($source == $target) { |
|
| 964 | 964 | return 100; |
| 965 | 965 | } |
| 966 | 966 | |
| 967 | 967 | $diff = levenshtein($source, $target); |
| 968 | - if($diff > $options['maxLevenshtein']) { |
|
| 968 | + if ($diff > $options['maxLevenshtein']) { |
|
| 969 | 969 | return 0; |
| 970 | 970 | } |
| 971 | 971 | |
@@ -1049,24 +1049,24 @@ discard block |
||
| 1049 | 1049 | * @see ConvertHelper::INTERVAL_HOURS |
| 1050 | 1050 | * @see ConvertHelper::INTERVAL_DAYS |
| 1051 | 1051 | */ |
| 1052 | - public static function interval2total(\DateInterval $interval, $unit=self::INTERVAL_SECONDS) : int |
|
| 1052 | + public static function interval2total(\DateInterval $interval, $unit = self::INTERVAL_SECONDS) : int |
|
| 1053 | 1053 | { |
| 1054 | 1054 | $total = (int)$interval->format('%a'); |
| 1055 | 1055 | if ($unit == self::INTERVAL_DAYS) { |
| 1056 | 1056 | return $total; |
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | - $total = ($total * 24) + ((int)$interval->h ); |
|
| 1059 | + $total = ($total * 24) + ((int)$interval->h); |
|
| 1060 | 1060 | if ($unit == self::INTERVAL_HOURS) { |
| 1061 | 1061 | return $total; |
| 1062 | 1062 | } |
| 1063 | 1063 | |
| 1064 | - $total = ($total * 60) + ((int)$interval->i ); |
|
| 1064 | + $total = ($total * 60) + ((int)$interval->i); |
|
| 1065 | 1065 | if ($unit == self::INTERVAL_MINUTES) { |
| 1066 | 1066 | return $total; |
| 1067 | 1067 | } |
| 1068 | 1068 | |
| 1069 | - $total = ($total * 60) + ((int)$interval->s ); |
|
| 1069 | + $total = ($total * 60) + ((int)$interval->s); |
|
| 1070 | 1070 | if ($unit == self::INTERVAL_SECONDS) { |
| 1071 | 1071 | return $total; |
| 1072 | 1072 | } |
@@ -1095,13 +1095,13 @@ discard block |
||
| 1095 | 1095 | * @param bool $short |
| 1096 | 1096 | * @return string|NULL |
| 1097 | 1097 | */ |
| 1098 | - public static function date2dayName(\DateTime $date, bool $short=false) |
|
| 1098 | + public static function date2dayName(\DateTime $date, bool $short = false) |
|
| 1099 | 1099 | { |
| 1100 | 1100 | $day = $date->format('l'); |
| 1101 | 1101 | $invariant = self::getDayNamesInvariant(); |
| 1102 | 1102 | |
| 1103 | 1103 | $idx = array_search($day, $invariant); |
| 1104 | - if($idx !== false) { |
|
| 1104 | + if ($idx !== false) { |
|
| 1105 | 1105 | $localized = self::getDayNames($short); |
| 1106 | 1106 | return $localized[$idx]; |
| 1107 | 1107 | } |
@@ -1124,10 +1124,10 @@ discard block |
||
| 1124 | 1124 | * @param bool $short |
| 1125 | 1125 | * @return array |
| 1126 | 1126 | */ |
| 1127 | - public static function getDayNames(bool $short=false) : array |
|
| 1127 | + public static function getDayNames(bool $short = false) : array |
|
| 1128 | 1128 | { |
| 1129 | - if($short) { |
|
| 1130 | - if(!isset(self::$daysShort)) { |
|
| 1129 | + if ($short) { |
|
| 1130 | + if (!isset(self::$daysShort)) { |
|
| 1131 | 1131 | self::$daysShort = array( |
| 1132 | 1132 | t('Mon'), |
| 1133 | 1133 | t('Tue'), |
@@ -1142,7 +1142,7 @@ discard block |
||
| 1142 | 1142 | return self::$daysShort; |
| 1143 | 1143 | } |
| 1144 | 1144 | |
| 1145 | - if(!isset(self::$days)) { |
|
| 1145 | + if (!isset(self::$days)) { |
|
| 1146 | 1146 | self::$days = array( |
| 1147 | 1147 | t('Monday'), |
| 1148 | 1148 | t('Tuesday'), |
@@ -1167,17 +1167,17 @@ discard block |
||
| 1167 | 1167 | */ |
| 1168 | 1168 | public static function implodeWithAnd(array $list, $sep = ', ', $conjunction = null) |
| 1169 | 1169 | { |
| 1170 | - if(empty($list)) { |
|
| 1170 | + if (empty($list)) { |
|
| 1171 | 1171 | return ''; |
| 1172 | 1172 | } |
| 1173 | 1173 | |
| 1174 | - if(empty($conjunction)) { |
|
| 1174 | + if (empty($conjunction)) { |
|
| 1175 | 1175 | $conjunction = t('and'); |
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | 1178 | $last = array_pop($list); |
| 1179 | - if($list) { |
|
| 1180 | - return implode($sep, $list) . $conjunction . ' ' . $last; |
|
| 1179 | + if ($list) { |
|
| 1180 | + return implode($sep, $list).$conjunction.' '.$last; |
|
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | 1183 | return $last; |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | public static function string2array(string $string) : array |
| 1197 | 1197 | { |
| 1198 | 1198 | $result = preg_split('//u', $string, null, PREG_SPLIT_NO_EMPTY); |
| 1199 | - if($result !== false) { |
|
| 1199 | + if ($result !== false) { |
|
| 1200 | 1200 | return $result; |
| 1201 | 1201 | } |
| 1202 | 1202 | |
@@ -1211,12 +1211,12 @@ discard block |
||
| 1211 | 1211 | */ |
| 1212 | 1212 | public static function isStringHTML(string $string) : bool |
| 1213 | 1213 | { |
| 1214 | - if(preg_match('%<[a-z/][\s\S]*>%siU', $string)) { |
|
| 1214 | + if (preg_match('%<[a-z/][\s\S]*>%siU', $string)) { |
|
| 1215 | 1215 | return true; |
| 1216 | 1216 | } |
| 1217 | 1217 | |
| 1218 | 1218 | $decoded = html_entity_decode($string); |
| 1219 | - if($decoded !== $string) { |
|
| 1219 | + if ($decoded !== $string) { |
|
| 1220 | 1220 | return true; |
| 1221 | 1221 | } |
| 1222 | 1222 | |
@@ -1325,14 +1325,14 @@ discard block |
||
| 1325 | 1325 | * @param bool $caseInsensitive |
| 1326 | 1326 | * @return ConvertHelper_StringMatch[] |
| 1327 | 1327 | */ |
| 1328 | - public static function findString(string $needle, string $haystack, bool $caseInsensitive=false) |
|
| 1328 | + public static function findString(string $needle, string $haystack, bool $caseInsensitive = false) |
|
| 1329 | 1329 | { |
| 1330 | - if($needle === '') { |
|
| 1330 | + if ($needle === '') { |
|
| 1331 | 1331 | return array(); |
| 1332 | 1332 | } |
| 1333 | 1333 | |
| 1334 | 1334 | $function = 'mb_strpos'; |
| 1335 | - if($caseInsensitive) { |
|
| 1335 | + if ($caseInsensitive) { |
|
| 1336 | 1336 | $function = 'mb_stripos'; |
| 1337 | 1337 | } |
| 1338 | 1338 | |
@@ -1340,7 +1340,7 @@ discard block |
||
| 1340 | 1340 | $positions = array(); |
| 1341 | 1341 | $length = mb_strlen($needle); |
| 1342 | 1342 | |
| 1343 | - while( ($pos = $function($haystack, $needle, $pos)) !== false) |
|
| 1343 | + while (($pos = $function($haystack, $needle, $pos)) !== false) |
|
| 1344 | 1344 | { |
| 1345 | 1345 | $match = mb_substr($haystack, $pos, $length); |
| 1346 | 1346 | $positions[] = new ConvertHelper_StringMatch($pos, $match); |
@@ -1360,7 +1360,7 @@ discard block |
||
| 1360 | 1360 | */ |
| 1361 | 1361 | public static function explodeTrim(string $delimiter, string $string) : array |
| 1362 | 1362 | { |
| 1363 | - if(empty($string) || empty($delimiter)) { |
|
| 1363 | + if (empty($string) || empty($delimiter)) { |
|
| 1364 | 1364 | return array(); |
| 1365 | 1365 | } |
| 1366 | 1366 | |
@@ -1368,8 +1368,8 @@ discard block |
||
| 1368 | 1368 | $tokens = array_map('trim', $tokens); |
| 1369 | 1369 | |
| 1370 | 1370 | $keep = array(); |
| 1371 | - foreach($tokens as $token) { |
|
| 1372 | - if($token !== '') { |
|
| 1371 | + foreach ($tokens as $token) { |
|
| 1372 | + if ($token !== '') { |
|
| 1373 | 1373 | $keep[] = $token; |
| 1374 | 1374 | } |
| 1375 | 1375 | } |
@@ -1387,11 +1387,11 @@ discard block |
||
| 1387 | 1387 | */ |
| 1388 | 1388 | public static function detectEOLCharacter(string $subjectString) : ?ConvertHelper_EOL |
| 1389 | 1389 | { |
| 1390 | - if(empty($subjectString)) { |
|
| 1390 | + if (empty($subjectString)) { |
|
| 1391 | 1391 | return null; |
| 1392 | 1392 | } |
| 1393 | 1393 | |
| 1394 | - if(!isset(self::$eolChars)) |
|
| 1394 | + if (!isset(self::$eolChars)) |
|
| 1395 | 1395 | { |
| 1396 | 1396 | $cr = chr((int)hexdec('0d')); |
| 1397 | 1397 | $lf = chr((int)hexdec('0a')); |
@@ -1422,18 +1422,18 @@ discard block |
||
| 1422 | 1422 | |
| 1423 | 1423 | $max = 0; |
| 1424 | 1424 | $results = array(); |
| 1425 | - foreach(self::$eolChars as $def) |
|
| 1425 | + foreach (self::$eolChars as $def) |
|
| 1426 | 1426 | { |
| 1427 | 1427 | $amount = substr_count($subjectString, $def['char']); |
| 1428 | 1428 | |
| 1429 | - if($amount > $max) |
|
| 1429 | + if ($amount > $max) |
|
| 1430 | 1430 | { |
| 1431 | 1431 | $max = $amount; |
| 1432 | 1432 | $results[] = $def; |
| 1433 | 1433 | } |
| 1434 | 1434 | } |
| 1435 | 1435 | |
| 1436 | - if(empty($results)) { |
|
| 1436 | + if (empty($results)) { |
|
| 1437 | 1437 | return null; |
| 1438 | 1438 | } |
| 1439 | 1439 | |
@@ -1453,9 +1453,9 @@ discard block |
||
| 1453 | 1453 | */ |
| 1454 | 1454 | public static function arrayRemoveKeys(array &$array, array $keys) : void |
| 1455 | 1455 | { |
| 1456 | - foreach($keys as $key) |
|
| 1456 | + foreach ($keys as $key) |
|
| 1457 | 1457 | { |
| 1458 | - if(array_key_exists($key, $array)) { |
|
| 1458 | + if (array_key_exists($key, $array)) { |
|
| 1459 | 1459 | unset($array[$key]); |
| 1460 | 1460 | } |
| 1461 | 1461 | } |
@@ -1470,17 +1470,17 @@ discard block |
||
| 1470 | 1470 | */ |
| 1471 | 1471 | public static function isInteger($value) : bool |
| 1472 | 1472 | { |
| 1473 | - if(is_int($value)) { |
|
| 1473 | + if (is_int($value)) { |
|
| 1474 | 1474 | return true; |
| 1475 | 1475 | } |
| 1476 | 1476 | |
| 1477 | 1477 | // booleans get converted to numbers, so they would |
| 1478 | 1478 | // actually match the regex. |
| 1479 | - if(is_bool($value)) { |
|
| 1479 | + if (is_bool($value)) { |
|
| 1480 | 1480 | return false; |
| 1481 | 1481 | } |
| 1482 | 1482 | |
| 1483 | - if(is_string($value) && $value !== '') { |
|
| 1483 | + if (is_string($value) && $value !== '') { |
|
| 1484 | 1484 | return preg_match('/\A-?\d+\z/', $value) === 1; |
| 1485 | 1485 | } |
| 1486 | 1486 | |
@@ -14,9 +14,9 @@ discard block |
||
| 14 | 14 | * @param mixed $value |
| 15 | 15 | * @return \AppUtils\NumberInfo |
| 16 | 16 | */ |
| 17 | -function parseNumber($value, $forceNew=false) |
|
| 17 | +function parseNumber($value, $forceNew = false) |
|
| 18 | 18 | { |
| 19 | - if($value instanceof NumberInfo && $forceNew !== true) { |
|
| 19 | + if ($value instanceof NumberInfo && $forceNew !== true) { |
|
| 20 | 20 | return $value; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $args = func_get_args(); |
| 98 | 98 | |
| 99 | 99 | // is the localization package installed? |
| 100 | - if(class_exists('\AppLocalize\Localization')) |
|
| 100 | + if (class_exists('\AppLocalize\Localization')) |
|
| 101 | 101 | { |
| 102 | 102 | return call_user_func_array('\AppLocalize\t', $args); |
| 103 | 103 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | */ |
| 116 | 116 | function requireCURL() : void |
| 117 | 117 | { |
| 118 | - if(function_exists('curl_init')) { |
|
| 118 | + if (function_exists('curl_init')) { |
|
| 119 | 119 | return; |
| 120 | 120 | } |
| 121 | 121 | |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * @param bool $initial The initial boolean value to use. |
| 133 | 133 | * @return Value_Bool |
| 134 | 134 | */ |
| 135 | -function valBool(bool $initial=false) : Value_Bool |
|
| 135 | +function valBool(bool $initial = false) : Value_Bool |
|
| 136 | 136 | { |
| 137 | 137 | return new Value_Bool($initial); |
| 138 | 138 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * @param bool $initial |
| 146 | 146 | * @return Value_Bool_True |
| 147 | 147 | */ |
| 148 | -function valBoolTrue(bool $initial=false) : Value_Bool_True |
|
| 148 | +function valBoolTrue(bool $initial = false) : Value_Bool_True |
|
| 149 | 149 | { |
| 150 | 150 | return new Value_Bool_True($initial); |
| 151 | 151 | } |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @param bool $initial |
| 159 | 159 | * @return Value_Bool_False |
| 160 | 160 | */ |
| 161 | -function valBoolFalse(bool $initial=true) : Value_Bool_False |
|
| 161 | +function valBoolFalse(bool $initial = true) : Value_Bool_False |
|
| 162 | 162 | { |
| 163 | 163 | return new Value_Bool_False($initial); |
| 164 | 164 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | function init() |
| 172 | 172 | { |
| 173 | - if(!class_exists('\AppLocalize\Localization')) { |
|
| 173 | + if (!class_exists('\AppLocalize\Localization')) { |
|
| 174 | 174 | return; |
| 175 | 175 | } |
| 176 | 176 | |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | { |
| 22 | 22 | protected $value = false; |
| 23 | 23 | |
| 24 | - public function __construct(bool $value=false) |
|
| 24 | + public function __construct(bool $value = false) |
|
| 25 | 25 | { |
| 26 | 26 | $this->value = $value; |
| 27 | 27 | } |
@@ -22,14 +22,14 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class Value_Bool_False extends Value_Bool |
| 24 | 24 | { |
| 25 | - public function __construct(bool $value=true) |
|
| 25 | + public function __construct(bool $value = true) |
|
| 26 | 26 | { |
| 27 | 27 | parent::__construct($value); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | public function set(bool $value) : Value_Bool |
| 31 | 31 | { |
| 32 | - if($value === false) |
|
| 32 | + if ($value === false) |
|
| 33 | 33 | { |
| 34 | 34 | parent::set($value); |
| 35 | 35 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | { |
| 25 | 25 | public function set(bool $value) : Value_Bool |
| 26 | 26 | { |
| 27 | - if($value === true) |
|
| 27 | + if ($value === true) |
|
| 28 | 28 | { |
| 29 | 29 | parent::set($value); |
| 30 | 30 | } |
@@ -56,9 +56,9 @@ discard block |
||
| 56 | 56 | * @param mixed $value |
| 57 | 57 | * @param array|null $serialized |
| 58 | 58 | */ |
| 59 | - public function __construct($value, $serialized=null) |
|
| 59 | + public function __construct($value, $serialized = null) |
|
| 60 | 60 | { |
| 61 | - if(is_array($serialized)) |
|
| 61 | + if (is_array($serialized)) |
|
| 62 | 62 | { |
| 63 | 63 | $this->parseSerialized($serialized); |
| 64 | 64 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | protected function parseSerialized(array $serialized) : void |
| 106 | 106 | { |
| 107 | - if(!isset($serialized['string']) || !isset($serialized['type']) || !isset($serialized['options'])) |
|
| 107 | + if (!isset($serialized['string']) || !isset($serialized['type']) || !isset($serialized['options'])) |
|
| 108 | 108 | { |
| 109 | 109 | throw new BaseException( |
| 110 | 110 | 'Invalid variable info serialized data.', |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $this->value = $value; |
| 125 | 125 | $this->type = strtolower(gettype($value)); |
| 126 | 126 | |
| 127 | - if(is_array($value) && is_callable($value)) { |
|
| 127 | + if (is_array($value) && is_callable($value)) { |
|
| 128 | 128 | $this->type = self::TYPE_CALLABLE; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * @param bool $enable |
| 163 | 163 | * @return VariableInfo |
| 164 | 164 | */ |
| 165 | - public function enableType(bool $enable=true) : VariableInfo |
|
| 165 | + public function enableType(bool $enable = true) : VariableInfo |
|
| 166 | 166 | { |
| 167 | 167 | return $this->setOption('prepend-type', $enable); |
| 168 | 168 | } |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | { |
| 172 | 172 | $converted = $this->string; |
| 173 | 173 | |
| 174 | - if($this->getOption('prepend-type') === true && !$this->isNull()) |
|
| 174 | + if ($this->getOption('prepend-type') === true && !$this->isNull()) |
|
| 175 | 175 | { |
| 176 | - if($this->isString()) |
|
| 176 | + if ($this->isString()) |
|
| 177 | 177 | { |
| 178 | 178 | $converted = '"'.$converted.'"'; |
| 179 | 179 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @param bool $enabled |
| 55 | 55 | * @return ConvertHelper_URLFinder |
| 56 | 56 | */ |
| 57 | - public function enableSorting(bool $enabled=true) : ConvertHelper_URLFinder |
|
| 57 | + public function enableSorting(bool $enabled = true) : ConvertHelper_URLFinder |
|
| 58 | 58 | { |
| 59 | 59 | $this->sorting = $enabled; |
| 60 | 60 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | { |
| 71 | 71 | $replaces = array(); |
| 72 | 72 | |
| 73 | - foreach($this->schemes as $scheme) |
|
| 73 | + foreach ($this->schemes as $scheme) |
|
| 74 | 74 | { |
| 75 | 75 | $replaces[$scheme.':'] = PHP_EOL.$scheme.':'; |
| 76 | 76 | } |
@@ -94,18 +94,18 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | $result = array(); |
| 96 | 96 | |
| 97 | - if(is_array($matches)) |
|
| 97 | + if (is_array($matches)) |
|
| 98 | 98 | { |
| 99 | - foreach($matches[0] as $match) |
|
| 99 | + foreach ($matches[0] as $match) |
|
| 100 | 100 | { |
| 101 | - if(strstr($match, '://') && !in_array($match, $result)) |
|
| 101 | + if (strstr($match, '://') && !in_array($match, $result)) |
|
| 102 | 102 | { |
| 103 | 103 | $result[] = $match; |
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - if($this->sorting) |
|
| 108 | + if ($this->sorting) |
|
| 109 | 109 | { |
| 110 | 110 | usort($result, function(string $a, string $b) { |
| 111 | 111 | return strnatcasecmp($a, $b); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | $result = array(); |
| 128 | 128 | |
| 129 | - foreach($urls as $url) |
|
| 129 | + foreach ($urls as $url) |
|
| 130 | 130 | { |
| 131 | 131 | $result[] = parseURL($url); |
| 132 | 132 | } |
@@ -13,15 +13,15 @@ |
||
| 13 | 13 | return print_r($result, true); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - protected function traverseArray(array $array, int $level=0) : array |
|
| 16 | + protected function traverseArray(array $array, int $level = 0) : array |
|
| 17 | 17 | { |
| 18 | 18 | $result = array(); |
| 19 | 19 | |
| 20 | - foreach($array as $key => $val) |
|
| 20 | + foreach ($array as $key => $val) |
|
| 21 | 21 | { |
| 22 | - if(is_array($val)) |
|
| 22 | + if (is_array($val)) |
|
| 23 | 23 | { |
| 24 | - $result[$key] = $this->traverseArray($val, ($level+1)); |
|
| 24 | + $result[$key] = $this->traverseArray($val, ($level + 1)); |
|
| 25 | 25 | } |
| 26 | 26 | else |
| 27 | 27 | { |