@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @param int $tabSize The amount of spaces per tab. |
56 | 56 | * @return string |
57 | 57 | */ |
58 | - public static function tabs2spaces(string $string, int $tabSize=4) : string |
|
58 | + public static function tabs2spaces(string $string, int $tabSize = 4) : string |
|
59 | 59 | { |
60 | 60 | return ConvertHelper_String::tabs2spaces($string, $tabSize); |
61 | 61 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param int $tabSize The amount of spaces per tab in the source string. |
68 | 68 | * @return string |
69 | 69 | */ |
70 | - public static function spaces2tabs(string $string, int $tabSize=4) : string |
|
70 | + public static function spaces2tabs(string $string, int $tabSize = 4) : string |
|
71 | 71 | { |
72 | 72 | return ConvertHelper_String::spaces2tabs($string, $tabSize); |
73 | 73 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @deprecated Use the Highlighter class directly instead. |
141 | 141 | * @see Highlighter::xml() |
142 | 142 | */ |
143 | - public static function highlight_xml(string $xml, bool $formatSource=false) : string |
|
143 | + public static function highlight_xml(string $xml, bool $formatSource = false) : string |
|
144 | 144 | { |
145 | 145 | return Highlighter::xml($xml, $formatSource); |
146 | 146 | } |
@@ -206,11 +206,11 @@ discard block |
||
206 | 206 | * @param bool $html |
207 | 207 | * @return string |
208 | 208 | */ |
209 | - public static function var_dump($var, bool $html=true) : string |
|
209 | + public static function var_dump($var, bool $html = true) : string |
|
210 | 210 | { |
211 | 211 | $info = parseVariable($var); |
212 | 212 | |
213 | - if($html) { |
|
213 | + if ($html) { |
|
214 | 214 | return $info->toHTML(); |
215 | 215 | } |
216 | 216 | |
@@ -225,11 +225,11 @@ discard block |
||
225 | 225 | * @param bool $html Whether to style the dump as HTML. |
226 | 226 | * @return string |
227 | 227 | */ |
228 | - public static function print_r($var, bool $return=false, bool $html=true) : string |
|
228 | + public static function print_r($var, bool $return = false, bool $html = true) : string |
|
229 | 229 | { |
230 | 230 | $result = parseVariable($var)->enableType()->toString(); |
231 | 231 | |
232 | - if($html) |
|
232 | + if ($html) |
|
233 | 233 | { |
234 | 234 | $result = |
235 | 235 | '<pre style="background:#fff;color:#333;padding:16px;border:solid 1px #bbb;border-radius:4px">'. |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | '</pre>'; |
238 | 238 | } |
239 | 239 | |
240 | - if(!$return) |
|
240 | + if (!$return) |
|
241 | 241 | { |
242 | 242 | echo $result; |
243 | 243 | } |
@@ -419,12 +419,12 @@ discard block |
||
419 | 419 | $output = ''; |
420 | 420 | $split = str_split($unicodeChar); |
421 | 421 | |
422 | - foreach($split as $octet) |
|
422 | + foreach ($split as $octet) |
|
423 | 423 | { |
424 | 424 | $ordInt = ord($octet); |
425 | 425 | // Convert from int (base 10) to hex (base 16), for PHP \x syntax |
426 | 426 | $ordHex = base_convert((string)$ordInt, 10, 16); |
427 | - $output .= '\x' . $ordHex; |
|
427 | + $output .= '\x'.$ordHex; |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | return $output; |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | * |
639 | 639 | * @see JSHelper::buildRegexStatement() |
640 | 640 | */ |
641 | - public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT) : string |
|
641 | + public static function regex2js(string $regex, string $statementType = JSHelper::JS_REGEX_OBJECT) : string |
|
642 | 642 | { |
643 | 643 | return JSHelper::buildRegexStatement($regex, $statementType); |
644 | 644 | } |
@@ -657,11 +657,11 @@ discard block |
||
657 | 657 | * @throws ConvertHelper_Exception |
658 | 658 | * @see ConvertHelper::ERROR_JSON_ENCODE_FAILED |
659 | 659 | */ |
660 | - public static function var2json($variable, int $options=0, int $depth=512) : string |
|
660 | + public static function var2json($variable, int $options = 0, int $depth = 512) : string |
|
661 | 661 | { |
662 | 662 | $result = json_encode($variable, $options, $depth); |
663 | 663 | |
664 | - if($result !== false) { |
|
664 | + if ($result !== false) { |
|
665 | 665 | return $result; |
666 | 666 | } |
667 | 667 | |
@@ -701,12 +701,12 @@ discard block |
||
701 | 701 | { |
702 | 702 | $boms = FileHelper::getUTFBOMs(); |
703 | 703 | |
704 | - foreach($boms as $bomChars) |
|
704 | + foreach ($boms as $bomChars) |
|
705 | 705 | { |
706 | 706 | $length = mb_strlen($bomChars); |
707 | 707 | $text = mb_substr($string, 0, $length); |
708 | 708 | |
709 | - if($text===$bomChars) |
|
709 | + if ($text === $bomChars) |
|
710 | 710 | { |
711 | 711 | return mb_substr($string, $length); |
712 | 712 | } |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | * @see ConvertHelper_TextComparer::OPTION_MAX_LEVENSHTEIN_DISTANCE |
779 | 779 | * @see ConvertHelper_TextComparer::OPTION_PRECISION |
780 | 780 | */ |
781 | - public static function matchString(string $source, string $target, array $options=array()) : float |
|
781 | + public static function matchString(string $source, string $target, array $options = array()) : float |
|
782 | 782 | { |
783 | 783 | return (new ConvertHelper_TextComparer()) |
784 | 784 | ->setOptions($options) |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | * @see ConvertHelper::INTERVAL_HOURS |
857 | 857 | * @see ConvertHelper::INTERVAL_DAYS |
858 | 858 | */ |
859 | - public static function interval2total(DateInterval $interval, string $unit=self::INTERVAL_SECONDS) : int |
|
859 | + public static function interval2total(DateInterval $interval, string $unit = self::INTERVAL_SECONDS) : int |
|
860 | 860 | { |
861 | 861 | return ConvertHelper_DateInterval::toTotal($interval, $unit); |
862 | 862 | } |
@@ -868,7 +868,7 @@ discard block |
||
868 | 868 | * @param bool $short |
869 | 869 | * @return string|NULL |
870 | 870 | */ |
871 | - public static function date2dayName(DateTime $date, bool $short=false) : ?string |
|
871 | + public static function date2dayName(DateTime $date, bool $short = false) : ?string |
|
872 | 872 | { |
873 | 873 | return ConvertHelper_Date::toDayName($date, $short); |
874 | 874 | } |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | * @param bool $short |
889 | 889 | * @return string[] |
890 | 890 | */ |
891 | - public static function getDayNames(bool $short=false) : array |
|
891 | + public static function getDayNames(bool $short = false) : array |
|
892 | 892 | { |
893 | 893 | return ConvertHelper_Date::getDayNames($short); |
894 | 894 | } |
@@ -1047,7 +1047,7 @@ discard block |
||
1047 | 1047 | * @param bool $caseInsensitive |
1048 | 1048 | * @return ConvertHelper_StringMatch[] |
1049 | 1049 | */ |
1050 | - public static function findString(string $needle, string $haystack, bool $caseInsensitive=false): array |
|
1050 | + public static function findString(string $needle, string $haystack, bool $caseInsensitive = false): array |
|
1051 | 1051 | { |
1052 | 1052 | return ConvertHelper_String::findString($needle, $haystack, $caseInsensitive); |
1053 | 1053 | } |
@@ -1097,17 +1097,17 @@ discard block |
||
1097 | 1097 | */ |
1098 | 1098 | public static function isInteger($value) : bool |
1099 | 1099 | { |
1100 | - if(is_int($value)) { |
|
1100 | + if (is_int($value)) { |
|
1101 | 1101 | return true; |
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | // booleans get converted to numbers, so they would |
1105 | 1105 | // actually match the regex. |
1106 | - if(is_bool($value)) { |
|
1106 | + if (is_bool($value)) { |
|
1107 | 1107 | return false; |
1108 | 1108 | } |
1109 | 1109 | |
1110 | - if(is_string($value) && $value !== '') { |
|
1110 | + if (is_string($value) && $value !== '') { |
|
1111 | 1111 | return preg_match('/\A-?\d+\z/', $value) === 1; |
1112 | 1112 | } |
1113 | 1113 | |
@@ -1173,7 +1173,7 @@ discard block |
||
1173 | 1173 | * @param bool $keepKeys |
1174 | 1174 | * @return array<number|string,mixed> |
1175 | 1175 | */ |
1176 | - public static function arrayRemoveValues(array $sourceArray, array $values, bool $keepKeys=false) : array |
|
1176 | + public static function arrayRemoveValues(array $sourceArray, array $values, bool $keepKeys = false) : array |
|
1177 | 1177 | { |
1178 | 1178 | return ConvertHelper_Array::removeValues($sourceArray, $values, $keepKeys); |
1179 | 1179 | } |
@@ -87,14 +87,14 @@ |
||
87 | 87 | public function match(string $source, string $target) : float |
88 | 88 | { |
89 | 89 | // avoid doing this via levenshtein |
90 | - if($source === $target) { |
|
90 | + if ($source === $target) { |
|
91 | 91 | return 100; |
92 | 92 | } |
93 | 93 | |
94 | 94 | $maxL = $this->getMaxDistance(); |
95 | 95 | |
96 | 96 | $diff = levenshtein($source, $target); |
97 | - if($diff > $maxL) { |
|
97 | + if ($diff > $maxL) { |
|
98 | 98 | return 0; |
99 | 99 | } |
100 | 100 |
@@ -49,19 +49,19 @@ |
||
49 | 49 | */ |
50 | 50 | protected static function convertScalarForComparison($scalar) : ?string |
51 | 51 | { |
52 | - if($scalar === '' || is_null($scalar)) { |
|
52 | + if ($scalar === '' || is_null($scalar)) { |
|
53 | 53 | return null; |
54 | 54 | } |
55 | 55 | |
56 | - if(is_bool($scalar)) { |
|
56 | + if (is_bool($scalar)) { |
|
57 | 57 | return ConvertHelper_Bool::toStringStrict($scalar); |
58 | 58 | } |
59 | 59 | |
60 | - if(is_array($scalar)) { |
|
60 | + if (is_array($scalar)) { |
|
61 | 61 | $scalar = md5(serialize($scalar)); |
62 | 62 | } |
63 | 63 | |
64 | - if($scalar !== null && !is_scalar($scalar)) { |
|
64 | + if ($scalar !== null && !is_scalar($scalar)) { |
|
65 | 65 | throw new ConvertHelper_Exception( |
66 | 66 | 'Not a scalar value in comparison', |
67 | 67 | null, |
@@ -33,14 +33,14 @@ discard block |
||
33 | 33 | * @param bool $caseInsensitive |
34 | 34 | * @return ConvertHelper_StringMatch[] |
35 | 35 | */ |
36 | - public static function findString(string $needle, string $haystack, bool $caseInsensitive=false): array |
|
36 | + public static function findString(string $needle, string $haystack, bool $caseInsensitive = false): array |
|
37 | 37 | { |
38 | - if($needle === '') { |
|
38 | + if ($needle === '') { |
|
39 | 39 | return array(); |
40 | 40 | } |
41 | 41 | |
42 | 42 | $function = 'mb_strpos'; |
43 | - if($caseInsensitive) { |
|
43 | + if ($caseInsensitive) { |
|
44 | 44 | $function = 'mb_stripos'; |
45 | 45 | } |
46 | 46 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $positions = array(); |
49 | 49 | $length = mb_strlen($needle); |
50 | 50 | |
51 | - while( ($pos = $function($haystack, $needle, $pos)) !== false) |
|
51 | + while (($pos = $function($haystack, $needle, $pos)) !== false) |
|
52 | 52 | { |
53 | 53 | $match = mb_substr($haystack, $pos, $length); |
54 | 54 | $positions[] = new ConvertHelper_StringMatch($pos, $match); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | public static function toArray(string $string) : array |
72 | 72 | { |
73 | 73 | $result = preg_split('//u', $string, 0, PREG_SPLIT_NO_EMPTY); |
74 | - if($result !== false) { |
|
74 | + if ($result !== false) { |
|
75 | 75 | return $result; |
76 | 76 | } |
77 | 77 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public static function toUtf8(string $string) : string |
126 | 126 | { |
127 | - if(!self::isASCII($string)) { |
|
127 | + if (!self::isASCII($string)) { |
|
128 | 128 | return Encoding::toUTF8($string); |
129 | 129 | } |
130 | 130 | |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | */ |
143 | 143 | public static function isASCII($string) : bool |
144 | 144 | { |
145 | - if($string === '' || $string === NULL) { |
|
145 | + if ($string === '' || $string === NULL) { |
|
146 | 146 | return true; |
147 | 147 | } |
148 | 148 | |
149 | - if(!is_string($string)) { |
|
149 | + if (!is_string($string)) { |
|
150 | 150 | return false; |
151 | 151 | } |
152 | 152 | |
@@ -161,12 +161,12 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public static function isHTML(string $string) : bool |
163 | 163 | { |
164 | - if(preg_match('%<[a-z/][\s\S]*>%siU', $string)) { |
|
164 | + if (preg_match('%<[a-z/][\s\S]*>%siU', $string)) { |
|
165 | 165 | return true; |
166 | 166 | } |
167 | 167 | |
168 | 168 | $decoded = html_entity_decode($string); |
169 | - if($decoded !== $string) { |
|
169 | + if ($decoded !== $string) { |
|
170 | 170 | return true; |
171 | 171 | } |
172 | 172 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @param int $tabSize The amount of spaces per tab. |
199 | 199 | * @return string |
200 | 200 | */ |
201 | - public static function tabs2spaces(string $string, int $tabSize=4) : string |
|
201 | + public static function tabs2spaces(string $string, int $tabSize = 4) : string |
|
202 | 202 | { |
203 | 203 | return str_replace("\t", str_repeat(' ', $tabSize), $string); |
204 | 204 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * @param int $tabSize The amount of spaces per tab in the source string. |
211 | 211 | * @return string |
212 | 212 | */ |
213 | - public static function spaces2tabs(string $string, int $tabSize=4) : string |
|
213 | + public static function spaces2tabs(string $string, int $tabSize = 4) : string |
|
214 | 214 | { |
215 | 215 | return str_replace(str_repeat(' ', $tabSize), "\t", $string); |
216 | 216 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | return $text; |
290 | 290 | } |
291 | 291 | |
292 | - return trim(mb_substr($text, 0, $targetLength)) . $append; |
|
292 | + return trim(mb_substr($text, 0, $targetLength)).$append; |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | */ |
303 | 303 | public static function explodeTrim(string $delimiter, string $string) : array |
304 | 304 | { |
305 | - if(empty($string) || empty($delimiter)) { |
|
305 | + if (empty($string) || empty($delimiter)) { |
|
306 | 306 | return array(); |
307 | 307 | } |
308 | 308 | |
@@ -310,8 +310,8 @@ discard block |
||
310 | 310 | $tokens = array_map('trim', $tokens); |
311 | 311 | |
312 | 312 | $keep = array(); |
313 | - foreach($tokens as $token) { |
|
314 | - if($token !== '') { |
|
313 | + foreach ($tokens as $token) { |
|
314 | + if ($token !== '') { |
|
315 | 315 | $keep[] = $token; |
316 | 316 | } |
317 | 317 | } |