@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $amount = substr_count($line, "\t") - $min; |
| 60 | 60 | $line = trim($line); |
| 61 | 61 | if ($amount >= 1) { |
| 62 | - $line = str_repeat("\t", $amount) . $line; |
|
| 62 | + $line = str_repeat("\t", $amount).$line; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | $converted[] = $line; |
@@ -131,10 +131,10 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | // specifically handle zero |
| 133 | 133 | if ($seconds <= 0) { |
| 134 | - return '0 ' . t('seconds'); |
|
| 134 | + return '0 '.t('seconds'); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if($seconds < 1) { |
|
| 137 | + if ($seconds < 1) { |
|
| 138 | 138 | return t('less than a second'); |
| 139 | 139 | } |
| 140 | 140 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | foreach ($units as $def) { |
| 143 | 143 | $quot = intval($seconds / $def['value']); |
| 144 | 144 | if ($quot) { |
| 145 | - $item = $quot . ' '; |
|
| 145 | + $item = $quot.' '; |
|
| 146 | 146 | if (abs($quot) > 1) { |
| 147 | 147 | $item .= $def['plural']; |
| 148 | 148 | } else { |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | return $last; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - return implode(', ', $tokens) . ' ' . t('and') . ' ' . $last; |
|
| 162 | + return implode(', ', $tokens).' '.t('and').' '.$last; |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | { |
| 179 | 179 | $converter = new ConvertHelper_DurationConverter(); |
| 180 | 180 | |
| 181 | - if($datefrom instanceof \DateTime) |
|
| 181 | + if ($datefrom instanceof \DateTime) |
|
| 182 | 182 | { |
| 183 | 183 | $converter->setDateFrom($datefrom); |
| 184 | 184 | } |
@@ -187,11 +187,11 @@ discard block |
||
| 187 | 187 | $converter->setDateFrom(self::timestamp2date($datefrom)); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - if($dateto instanceof \DateTime) |
|
| 190 | + if ($dateto instanceof \DateTime) |
|
| 191 | 191 | { |
| 192 | 192 | $converter->setDateTo($dateto); |
| 193 | 193 | } |
| 194 | - else if($dateto > 0) |
|
| 194 | + else if ($dateto > 0) |
|
| 195 | 195 | { |
| 196 | 196 | $converter->setDateTo(self::timestamp2date($dateto)); |
| 197 | 197 | } |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | return $geshi->parse_code(); |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - public static function highlight_xml($xml, $formatSource=false) |
|
| 214 | + public static function highlight_xml($xml, $formatSource = false) |
|
| 215 | 215 | { |
| 216 | - if($formatSource) |
|
| 216 | + if ($formatSource) |
|
| 217 | 217 | { |
| 218 | 218 | $dom = new \DOMDocument(); |
| 219 | 219 | $dom->loadXML($xml); |
@@ -251,22 +251,22 @@ discard block |
||
| 251 | 251 | $terabyte = $gigabyte * 1024; |
| 252 | 252 | |
| 253 | 253 | if (($bytes >= 0) && ($bytes < $kilobyte)) { |
| 254 | - return $bytes . ' ' . t('B'); |
|
| 254 | + return $bytes.' '.t('B'); |
|
| 255 | 255 | |
| 256 | 256 | } elseif (($bytes >= $kilobyte) && ($bytes < $megabyte)) { |
| 257 | - return round($bytes / $kilobyte, $precision) . ' ' . t('Kb'); |
|
| 257 | + return round($bytes / $kilobyte, $precision).' '.t('Kb'); |
|
| 258 | 258 | |
| 259 | 259 | } elseif (($bytes >= $megabyte) && ($bytes < $gigabyte)) { |
| 260 | - return round($bytes / $megabyte, $precision) . ' ' . t('Mb'); |
|
| 260 | + return round($bytes / $megabyte, $precision).' '.t('Mb'); |
|
| 261 | 261 | |
| 262 | 262 | } elseif (($bytes >= $gigabyte) && ($bytes < $terabyte)) { |
| 263 | - return round($bytes / $gigabyte, $precision) . ' ' . t('Gb'); |
|
| 263 | + return round($bytes / $gigabyte, $precision).' '.t('Gb'); |
|
| 264 | 264 | |
| 265 | 265 | } elseif ($bytes >= $terabyte) { |
| 266 | - return round($bytes / $gigabyte, $precision) . ' ' . t('Tb'); |
|
| 266 | + return round($bytes / $gigabyte, $precision).' '.t('Tb'); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - return $bytes . ' ' . t('B'); |
|
| 269 | + return $bytes.' '.t('B'); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | /** |
@@ -286,34 +286,34 @@ discard block |
||
| 286 | 286 | return $text; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - $text = trim(mb_substr($text, 0, $targetLength)) . $append; |
|
| 289 | + $text = trim(mb_substr($text, 0, $targetLength)).$append; |
|
| 290 | 290 | |
| 291 | 291 | return $text; |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - public static function var_dump($var, $html=true) |
|
| 294 | + public static function var_dump($var, $html = true) |
|
| 295 | 295 | { |
| 296 | 296 | $info = parseVariable($var); |
| 297 | 297 | |
| 298 | - if($html) { |
|
| 298 | + if ($html) { |
|
| 299 | 299 | return $info->toHTML(); |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | return $info->toString(); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - public static function print_r($var, $return=false, $html=true) |
|
| 305 | + public static function print_r($var, $return = false, $html = true) |
|
| 306 | 306 | { |
| 307 | 307 | $result = self::var_dump($var, $html); |
| 308 | 308 | |
| 309 | - if($html) { |
|
| 309 | + if ($html) { |
|
| 310 | 310 | $result = |
| 311 | 311 | '<pre style="background:#fff;color:#333;padding:16px;border:solid 1px #bbb;border-radius:4px">'. |
| 312 | 312 | $result. |
| 313 | 313 | '</pre>'; |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - if($return) { |
|
| 316 | + if ($return) { |
|
| 317 | 317 | return $result; |
| 318 | 318 | } |
| 319 | 319 | |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | |
| 334 | 334 | public static function string2bool($string) |
| 335 | 335 | { |
| 336 | - if($string === '' || $string === null) { |
|
| 336 | + if ($string === '' || $string === null) { |
|
| 337 | 337 | return false; |
| 338 | 338 | } |
| 339 | 339 | |
@@ -388,10 +388,10 @@ discard block |
||
| 388 | 388 | public static function date2listLabel(\DateTime $date, $includeTime = false, $shortMonth = false) |
| 389 | 389 | { |
| 390 | 390 | $today = new \DateTime(); |
| 391 | - if($date->format('d.m.Y') == $today->format('d.m.Y')) { |
|
| 391 | + if ($date->format('d.m.Y') == $today->format('d.m.Y')) { |
|
| 392 | 392 | $label = t('Today'); |
| 393 | 393 | } else { |
| 394 | - $label = $date->format('d') . '. ' . self::month2string((int)$date->format('m'), $shortMonth) . ' '; |
|
| 394 | + $label = $date->format('d').'. '.self::month2string((int)$date->format('m'), $shortMonth).' '; |
|
| 395 | 395 | if ($date->format('Y') != date('Y')) { |
| 396 | 396 | $label .= $date->format('Y'); |
| 397 | 397 | } |
@@ -482,28 +482,28 @@ discard block |
||
| 482 | 482 | $hexAlphabet = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
| 483 | 483 | |
| 484 | 484 | $stack = array(); |
| 485 | - foreach(self::$controlChars as $char) |
|
| 485 | + foreach (self::$controlChars as $char) |
|
| 486 | 486 | { |
| 487 | 487 | $tokens = explode('-', $char); |
| 488 | 488 | $start = $tokens[0]; |
| 489 | 489 | $end = $tokens[1]; |
| 490 | 490 | $prefix = substr($start, 0, 3); |
| 491 | 491 | $range = array(); |
| 492 | - foreach($hexAlphabet as $number) { |
|
| 492 | + foreach ($hexAlphabet as $number) { |
|
| 493 | 493 | $range[] = $prefix.$number; |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | $use = false; |
| 497 | - foreach($range as $number) { |
|
| 498 | - if($number == $start) { |
|
| 497 | + foreach ($range as $number) { |
|
| 498 | + if ($number == $start) { |
|
| 499 | 499 | $use = true; |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | - if($use) { |
|
| 502 | + if ($use) { |
|
| 503 | 503 | $stack[] = $number; |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | - if($number == $end) { |
|
| 506 | + if ($number == $end) { |
|
| 507 | 507 | break; |
| 508 | 508 | } |
| 509 | 509 | } |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | $chars = self::getControlCharactersAsHex(); |
| 525 | 525 | |
| 526 | 526 | $result = array(); |
| 527 | - foreach($chars as $char) { |
|
| 527 | + foreach ($chars as $char) { |
|
| 528 | 528 | $result[] = hex2bin($char); |
| 529 | 529 | } |
| 530 | 530 | |
@@ -542,14 +542,14 @@ discard block |
||
| 542 | 542 | $chars = self::getControlCharactersAsHex(); |
| 543 | 543 | |
| 544 | 544 | $result = array(); |
| 545 | - foreach($chars as $char) { |
|
| 545 | + foreach ($chars as $char) { |
|
| 546 | 546 | $result[] = '\u'.strtolower($char); |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | return $result; |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | - protected static $controlChars = array( |
|
| 552 | + protected static $controlChars = array( |
|
| 553 | 553 | '0000-0008', // control chars |
| 554 | 554 | '000E-000F', // control chars |
| 555 | 555 | '0010-001F', // control chars |
@@ -571,19 +571,19 @@ discard block |
||
| 571 | 571 | */ |
| 572 | 572 | public static function stripControlCharacters(string $string) : string |
| 573 | 573 | { |
| 574 | - if(empty($string)) { |
|
| 574 | + if (empty($string)) { |
|
| 575 | 575 | return $string; |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | // create the regex from the unicode characters list |
| 579 | - if(!isset(self::$controlCharsRegex)) |
|
| 579 | + if (!isset(self::$controlCharsRegex)) |
|
| 580 | 580 | { |
| 581 | 581 | $chars = self::getControlCharactersAsHex(); |
| 582 | 582 | |
| 583 | 583 | // we use the notation \x{0000} to specify the unicode character key |
| 584 | 584 | // in the regular expression. |
| 585 | 585 | $stack = array(); |
| 586 | - foreach($chars as $char) { |
|
| 586 | + foreach ($chars as $char) { |
|
| 587 | 587 | $stack[] = '\x{'.$char.'}'; |
| 588 | 588 | } |
| 589 | 589 | |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | $ordInt = ord($octet); |
| 618 | 618 | // Convert from int (base 10) to hex (base 16), for PHP \x syntax |
| 619 | 619 | $ordHex = base_convert($ordInt, 10, 16); |
| 620 | - $output .= '\x' . $ordHex; |
|
| 620 | + $output .= '\x'.$ordHex; |
|
| 621 | 621 | } |
| 622 | 622 | return $output; |
| 623 | 623 | } |
@@ -649,19 +649,19 @@ discard block |
||
| 649 | 649 | |
| 650 | 650 | protected static function convertScalarForComparison($scalar) |
| 651 | 651 | { |
| 652 | - if($scalar === '' || is_null($scalar)) { |
|
| 652 | + if ($scalar === '' || is_null($scalar)) { |
|
| 653 | 653 | return null; |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | - if(is_bool($scalar)) { |
|
| 656 | + if (is_bool($scalar)) { |
|
| 657 | 657 | return self::bool2string($scalar); |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | - if(is_array($scalar)) { |
|
| 660 | + if (is_array($scalar)) { |
|
| 661 | 661 | $scalar = md5(serialize($scalar)); |
| 662 | 662 | } |
| 663 | 663 | |
| 664 | - if($scalar !== null && !is_scalar($scalar)) { |
|
| 664 | + if ($scalar !== null && !is_scalar($scalar)) { |
|
| 665 | 665 | throw new ConvertHelper_Exception( |
| 666 | 666 | 'Not a scalar value in comparison', |
| 667 | 667 | null, |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | public static function bool2string($boolean, bool $yesno = false) : string |
| 711 | 711 | { |
| 712 | 712 | // allow 'yes', 'true', 'no', 'false' string notations as well |
| 713 | - if(!is_bool($boolean)) { |
|
| 713 | + if (!is_bool($boolean)) { |
|
| 714 | 714 | $boolean = self::string2bool($boolean); |
| 715 | 715 | } |
| 716 | 716 | |
@@ -751,15 +751,15 @@ discard block |
||
| 751 | 751 | public static function array2attributeString($array) |
| 752 | 752 | { |
| 753 | 753 | $tokens = array(); |
| 754 | - foreach($array as $attr => $value) { |
|
| 755 | - if($value == '' || $value == null) { |
|
| 754 | + foreach ($array as $attr => $value) { |
|
| 755 | + if ($value == '' || $value == null) { |
|
| 756 | 756 | continue; |
| 757 | 757 | } |
| 758 | 758 | |
| 759 | 759 | $tokens[] = $attr.'="'.$value.'"'; |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | - if(empty($tokens)) { |
|
| 762 | + if (empty($tokens)) { |
|
| 763 | 763 | return ''; |
| 764 | 764 | } |
| 765 | 765 | |
@@ -774,10 +774,10 @@ discard block |
||
| 774 | 774 | * @param string $string |
| 775 | 775 | * @return string |
| 776 | 776 | */ |
| 777 | - public static function string2attributeJS($string, $quoted=true) |
|
| 777 | + public static function string2attributeJS($string, $quoted = true) |
|
| 778 | 778 | { |
| 779 | 779 | $converted = addslashes(htmlspecialchars(strip_tags($string), ENT_QUOTES, 'UTF-8')); |
| 780 | - if($quoted) { |
|
| 780 | + if ($quoted) { |
|
| 781 | 781 | $converted = "'".$converted."'"; |
| 782 | 782 | } |
| 783 | 783 | |
@@ -795,11 +795,11 @@ discard block |
||
| 795 | 795 | */ |
| 796 | 796 | public static function isBoolean($value) : bool |
| 797 | 797 | { |
| 798 | - if(is_bool($value)) { |
|
| 798 | + if (is_bool($value)) { |
|
| 799 | 799 | return true; |
| 800 | 800 | } |
| 801 | 801 | |
| 802 | - if(!is_scalar($value)) { |
|
| 802 | + if (!is_scalar($value)) { |
|
| 803 | 803 | return false; |
| 804 | 804 | } |
| 805 | 805 | |
@@ -815,7 +815,7 @@ discard block |
||
| 815 | 815 | public static function array2styleString(array $subject) : string |
| 816 | 816 | { |
| 817 | 817 | $tokens = array(); |
| 818 | - foreach($subject as $name => $value) { |
|
| 818 | + foreach ($subject as $name => $value) { |
|
| 819 | 819 | $tokens[] = $name.':'.$value; |
| 820 | 820 | } |
| 821 | 821 | |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | * |
| 874 | 874 | * @see JSHelper::buildRegexStatement() |
| 875 | 875 | */ |
| 876 | - public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT) |
|
| 876 | + public static function regex2js(string $regex, string $statementType = JSHelper::JS_REGEX_OBJECT) |
|
| 877 | 877 | { |
| 878 | 878 | return JSHelper::buildRegexStatement($regex, $statementType); |
| 879 | 879 | } |
@@ -890,11 +890,11 @@ discard block |
||
| 890 | 890 | * @throws ConvertHelper_Exception |
| 891 | 891 | * @return string |
| 892 | 892 | */ |
| 893 | - public static function var2json($variable, int $options=0, int $depth=512) : string |
|
| 893 | + public static function var2json($variable, int $options = 0, int $depth = 512) : string |
|
| 894 | 894 | { |
| 895 | 895 | $result = json_encode($variable, $options, $depth); |
| 896 | 896 | |
| 897 | - if($result !== false) { |
|
| 897 | + if ($result !== false) { |
|
| 898 | 898 | return $result; |
| 899 | 899 | } |
| 900 | 900 | |
@@ -919,10 +919,10 @@ discard block |
||
| 919 | 919 | public static function stripUTFBom($string) |
| 920 | 920 | { |
| 921 | 921 | $boms = FileHelper::getUTFBOMs(); |
| 922 | - foreach($boms as $bomChars) { |
|
| 922 | + foreach ($boms as $bomChars) { |
|
| 923 | 923 | $length = mb_strlen($bomChars); |
| 924 | 924 | $text = mb_substr($string, 0, $length); |
| 925 | - if($text==$bomChars) { |
|
| 925 | + if ($text == $bomChars) { |
|
| 926 | 926 | return mb_substr($string, $length); |
| 927 | 927 | } |
| 928 | 928 | } |
@@ -939,7 +939,7 @@ discard block |
||
| 939 | 939 | */ |
| 940 | 940 | public static function string2utf8($string) |
| 941 | 941 | { |
| 942 | - if(!self::isStringASCII($string)) { |
|
| 942 | + if (!self::isStringASCII($string)) { |
|
| 943 | 943 | return \ForceUTF8\Encoding::toUTF8($string); |
| 944 | 944 | } |
| 945 | 945 | |
@@ -957,11 +957,11 @@ discard block |
||
| 957 | 957 | */ |
| 958 | 958 | public static function isStringASCII($string) : bool |
| 959 | 959 | { |
| 960 | - if($string === '' || $string === NULL) { |
|
| 960 | + if ($string === '' || $string === NULL) { |
|
| 961 | 961 | return true; |
| 962 | 962 | } |
| 963 | 963 | |
| 964 | - if(!is_string($string)) { |
|
| 964 | + if (!is_string($string)) { |
|
| 965 | 965 | return false; |
| 966 | 966 | } |
| 967 | 967 | |
@@ -995,7 +995,7 @@ discard block |
||
| 995 | 995 | * @param array $options |
| 996 | 996 | * @return float |
| 997 | 997 | */ |
| 998 | - public static function matchString($source, $target, $options=array()) |
|
| 998 | + public static function matchString($source, $target, $options = array()) |
|
| 999 | 999 | { |
| 1000 | 1000 | $defaults = array( |
| 1001 | 1001 | 'maxLevenshtein' => 10, |
@@ -1005,12 +1005,12 @@ discard block |
||
| 1005 | 1005 | $options = array_merge($defaults, $options); |
| 1006 | 1006 | |
| 1007 | 1007 | // avoid doing this via levenshtein |
| 1008 | - if($source == $target) { |
|
| 1008 | + if ($source == $target) { |
|
| 1009 | 1009 | return 100; |
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | 1012 | $diff = levenshtein($source, $target); |
| 1013 | - if($diff > $options['maxLevenshtein']) { |
|
| 1013 | + if ($diff > $options['maxLevenshtein']) { |
|
| 1014 | 1014 | return 0; |
| 1015 | 1015 | } |
| 1016 | 1016 | |
@@ -1024,8 +1024,8 @@ discard block |
||
| 1024 | 1024 | |
| 1025 | 1025 | $offset = 0; |
| 1026 | 1026 | $keep = array(); |
| 1027 | - foreach($tokens as $token) { |
|
| 1028 | - if($interval->$token > 0) { |
|
| 1027 | + foreach ($tokens as $token) { |
|
| 1028 | + if ($interval->$token > 0) { |
|
| 1029 | 1029 | $keep = array_slice($tokens, $offset); |
| 1030 | 1030 | break; |
| 1031 | 1031 | } |
@@ -1034,16 +1034,16 @@ discard block |
||
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | 1036 | $parts = array(); |
| 1037 | - foreach($keep as $token) |
|
| 1037 | + foreach ($keep as $token) |
|
| 1038 | 1038 | { |
| 1039 | 1039 | $value = $interval->$token; |
| 1040 | 1040 | $label = ''; |
| 1041 | 1041 | |
| 1042 | 1042 | $suffix = 'p'; |
| 1043 | - if($value == 1) { $suffix = 's'; } |
|
| 1043 | + if ($value == 1) { $suffix = 's'; } |
|
| 1044 | 1044 | $token .= $suffix; |
| 1045 | 1045 | |
| 1046 | - switch($token) { |
|
| 1046 | + switch ($token) { |
|
| 1047 | 1047 | case 'ys': $label = t('1 year'); break; |
| 1048 | 1048 | case 'yp': $label = t('%1$s years', $value); break; |
| 1049 | 1049 | case 'ms': $label = t('1 month'); break; |
@@ -1061,7 +1061,7 @@ discard block |
||
| 1061 | 1061 | $parts[] = $label; |
| 1062 | 1062 | } |
| 1063 | 1063 | |
| 1064 | - if(count($parts) == 1) { |
|
| 1064 | + if (count($parts) == 1) { |
|
| 1065 | 1065 | return $parts[0]; |
| 1066 | 1066 | } |
| 1067 | 1067 | |
@@ -1132,24 +1132,24 @@ discard block |
||
| 1132 | 1132 | * @see ConvertHelper::INTERVAL_HOURS |
| 1133 | 1133 | * @see ConvertHelper::INTERVAL_DAYS |
| 1134 | 1134 | */ |
| 1135 | - public static function interval2total(\DateInterval $interval, $unit=self::INTERVAL_SECONDS) : int |
|
| 1135 | + public static function interval2total(\DateInterval $interval, $unit = self::INTERVAL_SECONDS) : int |
|
| 1136 | 1136 | { |
| 1137 | 1137 | $total = $interval->format('%a'); |
| 1138 | 1138 | if ($unit == self::INTERVAL_DAYS) { |
| 1139 | 1139 | return (int)$total; |
| 1140 | 1140 | } |
| 1141 | 1141 | |
| 1142 | - $total = ($total * 24) + ($interval->h ); |
|
| 1142 | + $total = ($total * 24) + ($interval->h); |
|
| 1143 | 1143 | if ($unit == self::INTERVAL_HOURS) { |
| 1144 | 1144 | return (int)$total; |
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | - $total = ($total * 60) + ($interval->i ); |
|
| 1147 | + $total = ($total * 60) + ($interval->i); |
|
| 1148 | 1148 | if ($unit == self::INTERVAL_MINUTES) { |
| 1149 | 1149 | return (int)$total; |
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | - $total = ($total * 60) + ($interval->s ); |
|
| 1152 | + $total = ($total * 60) + ($interval->s); |
|
| 1153 | 1153 | if ($unit == self::INTERVAL_SECONDS) { |
| 1154 | 1154 | return (int)$total; |
| 1155 | 1155 | } |
@@ -1178,13 +1178,13 @@ discard block |
||
| 1178 | 1178 | * @param string $short |
| 1179 | 1179 | * @return string|NULL |
| 1180 | 1180 | */ |
| 1181 | - public static function date2dayName(\DateTime $date, $short=false) |
|
| 1181 | + public static function date2dayName(\DateTime $date, $short = false) |
|
| 1182 | 1182 | { |
| 1183 | 1183 | $day = $date->format('l'); |
| 1184 | 1184 | $invariant = self::getDayNamesInvariant(); |
| 1185 | 1185 | |
| 1186 | 1186 | $idx = array_search($day, $invariant); |
| 1187 | - if($idx !== false) { |
|
| 1187 | + if ($idx !== false) { |
|
| 1188 | 1188 | $localized = self::getDayNames($short); |
| 1189 | 1189 | return $localized[$idx]; |
| 1190 | 1190 | } |
@@ -1207,10 +1207,10 @@ discard block |
||
| 1207 | 1207 | * @param string $short |
| 1208 | 1208 | * @return string[] |
| 1209 | 1209 | */ |
| 1210 | - public static function getDayNames($short=false) |
|
| 1210 | + public static function getDayNames($short = false) |
|
| 1211 | 1211 | { |
| 1212 | - if($short) { |
|
| 1213 | - if(!isset(self::$daysShort)) { |
|
| 1212 | + if ($short) { |
|
| 1213 | + if (!isset(self::$daysShort)) { |
|
| 1214 | 1214 | self::$daysShort = array( |
| 1215 | 1215 | t('Mon'), |
| 1216 | 1216 | t('Tue'), |
@@ -1225,7 +1225,7 @@ discard block |
||
| 1225 | 1225 | return self::$daysShort; |
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | - if(!isset(self::$days)) { |
|
| 1228 | + if (!isset(self::$days)) { |
|
| 1229 | 1229 | self::$days = array( |
| 1230 | 1230 | t('Monday'), |
| 1231 | 1231 | t('Tuesday'), |
@@ -1250,17 +1250,17 @@ discard block |
||
| 1250 | 1250 | */ |
| 1251 | 1251 | public static function implodeWithAnd(array $list, $sep = ', ', $conjunction = null) |
| 1252 | 1252 | { |
| 1253 | - if(empty($list)) { |
|
| 1253 | + if (empty($list)) { |
|
| 1254 | 1254 | return ''; |
| 1255 | 1255 | } |
| 1256 | 1256 | |
| 1257 | - if(empty($conjunction)) { |
|
| 1257 | + if (empty($conjunction)) { |
|
| 1258 | 1258 | $conjunction = t('and'); |
| 1259 | 1259 | } |
| 1260 | 1260 | |
| 1261 | 1261 | $last = array_pop($list); |
| 1262 | - if($list) { |
|
| 1263 | - return implode($sep, $list) . $conjunction . ' ' . $last; |
|
| 1262 | + if ($list) { |
|
| 1263 | + return implode($sep, $list).$conjunction.' '.$last; |
|
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | 1266 | return $last; |
@@ -1279,7 +1279,7 @@ discard block |
||
| 1279 | 1279 | public static function string2array(string $string) : array |
| 1280 | 1280 | { |
| 1281 | 1281 | $result = preg_split('//u', $string, null, PREG_SPLIT_NO_EMPTY); |
| 1282 | - if($result !== false) { |
|
| 1282 | + if ($result !== false) { |
|
| 1283 | 1283 | return $result; |
| 1284 | 1284 | } |
| 1285 | 1285 | |
@@ -1294,12 +1294,12 @@ discard block |
||
| 1294 | 1294 | */ |
| 1295 | 1295 | public static function isStringHTML(string $string) : bool |
| 1296 | 1296 | { |
| 1297 | - if(preg_match('%<[a-z/][\s\S]*>%siU', $string)) { |
|
| 1297 | + if (preg_match('%<[a-z/][\s\S]*>%siU', $string)) { |
|
| 1298 | 1298 | return true; |
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | 1301 | $decoded = html_entity_decode($string); |
| 1302 | - if($decoded !== $string) { |
|
| 1302 | + if ($decoded !== $string) { |
|
| 1303 | 1303 | return true; |
| 1304 | 1304 | } |
| 1305 | 1305 | |
@@ -1408,14 +1408,14 @@ discard block |
||
| 1408 | 1408 | * @param bool $caseInsensitive |
| 1409 | 1409 | * @return ConvertHelper_StringMatch[] |
| 1410 | 1410 | */ |
| 1411 | - public static function findString(string $needle, string $haystack, bool $caseInsensitive=false) |
|
| 1411 | + public static function findString(string $needle, string $haystack, bool $caseInsensitive = false) |
|
| 1412 | 1412 | { |
| 1413 | - if($needle === '') { |
|
| 1413 | + if ($needle === '') { |
|
| 1414 | 1414 | return array(); |
| 1415 | 1415 | } |
| 1416 | 1416 | |
| 1417 | 1417 | $function = 'mb_strpos'; |
| 1418 | - if($caseInsensitive) { |
|
| 1418 | + if ($caseInsensitive) { |
|
| 1419 | 1419 | $function = 'mb_stripos'; |
| 1420 | 1420 | } |
| 1421 | 1421 | |
@@ -1423,7 +1423,7 @@ discard block |
||
| 1423 | 1423 | $positions = array(); |
| 1424 | 1424 | $length = mb_strlen($needle); |
| 1425 | 1425 | |
| 1426 | - while( ($pos = $function($haystack, $needle, $pos)) !== false) |
|
| 1426 | + while (($pos = $function($haystack, $needle, $pos)) !== false) |
|
| 1427 | 1427 | { |
| 1428 | 1428 | $match = mb_substr($haystack, $pos, $length); |
| 1429 | 1429 | $positions[] = new ConvertHelper_StringMatch($pos, $match); |
@@ -1443,7 +1443,7 @@ discard block |
||
| 1443 | 1443 | */ |
| 1444 | 1444 | public static function explodeTrim(string $delimiter, string $string) : array |
| 1445 | 1445 | { |
| 1446 | - if(empty($string) || empty($delimiter)) { |
|
| 1446 | + if (empty($string) || empty($delimiter)) { |
|
| 1447 | 1447 | return array(); |
| 1448 | 1448 | } |
| 1449 | 1449 | |
@@ -1451,8 +1451,8 @@ discard block |
||
| 1451 | 1451 | $tokens = array_map('trim', $tokens); |
| 1452 | 1452 | |
| 1453 | 1453 | $keep = array(); |
| 1454 | - foreach($tokens as $token) { |
|
| 1455 | - if($token !== '') { |
|
| 1454 | + foreach ($tokens as $token) { |
|
| 1455 | + if ($token !== '') { |
|
| 1456 | 1456 | $keep[] = $token; |
| 1457 | 1457 | } |
| 1458 | 1458 | } |
@@ -1470,11 +1470,11 @@ discard block |
||
| 1470 | 1470 | */ |
| 1471 | 1471 | public static function detectEOLCharacter(string $subjectString) : ?ConvertHelper_EOL |
| 1472 | 1472 | { |
| 1473 | - if(empty($subjectString)) { |
|
| 1473 | + if (empty($subjectString)) { |
|
| 1474 | 1474 | return null; |
| 1475 | 1475 | } |
| 1476 | 1476 | |
| 1477 | - if(!isset(self::$eolChars)) |
|
| 1477 | + if (!isset(self::$eolChars)) |
|
| 1478 | 1478 | { |
| 1479 | 1479 | $cr = chr((int)hexdec('0d')); |
| 1480 | 1480 | $lf = chr((int)hexdec('0a')); |
@@ -1505,18 +1505,18 @@ discard block |
||
| 1505 | 1505 | |
| 1506 | 1506 | $max = 0; |
| 1507 | 1507 | $results = array(); |
| 1508 | - foreach(self::$eolChars as $def) |
|
| 1508 | + foreach (self::$eolChars as $def) |
|
| 1509 | 1509 | { |
| 1510 | 1510 | $amount = substr_count($subjectString, $def['char']); |
| 1511 | 1511 | |
| 1512 | - if($amount > $max) |
|
| 1512 | + if ($amount > $max) |
|
| 1513 | 1513 | { |
| 1514 | 1514 | $max = $amount; |
| 1515 | 1515 | $results[] = $def; |
| 1516 | 1516 | } |
| 1517 | 1517 | } |
| 1518 | 1518 | |
| 1519 | - if(empty($results)) { |
|
| 1519 | + if (empty($results)) { |
|
| 1520 | 1520 | return null; |
| 1521 | 1521 | } |
| 1522 | 1522 | |
@@ -1536,9 +1536,9 @@ discard block |
||
| 1536 | 1536 | */ |
| 1537 | 1537 | public static function arrayRemoveKeys(array &$array, array $keys) : void |
| 1538 | 1538 | { |
| 1539 | - foreach($keys as $key) |
|
| 1539 | + foreach ($keys as $key) |
|
| 1540 | 1540 | { |
| 1541 | - if(array_key_exists($key, $array)) { |
|
| 1541 | + if (array_key_exists($key, $array)) { |
|
| 1542 | 1542 | unset($array[$key]); |
| 1543 | 1543 | } |
| 1544 | 1544 | } |
@@ -1553,17 +1553,17 @@ discard block |
||
| 1553 | 1553 | */ |
| 1554 | 1554 | public static function isInteger($value) : bool |
| 1555 | 1555 | { |
| 1556 | - if(is_int($value)) { |
|
| 1556 | + if (is_int($value)) { |
|
| 1557 | 1557 | return true; |
| 1558 | 1558 | } |
| 1559 | 1559 | |
| 1560 | 1560 | // booleans get converted to numbers, so they would |
| 1561 | 1561 | // actually match the regex. |
| 1562 | - if(is_bool($value)) { |
|
| 1562 | + if (is_bool($value)) { |
|
| 1563 | 1563 | return false; |
| 1564 | 1564 | } |
| 1565 | 1565 | |
| 1566 | - if(is_string($value) && $value !== '') { |
|
| 1566 | + if (is_string($value) && $value !== '') { |
|
| 1567 | 1567 | return preg_match('/\A-?\d+\z/', $value) === 1; |
| 1568 | 1568 | } |
| 1569 | 1569 | |
@@ -1590,7 +1590,7 @@ discard block |
||
| 1590 | 1590 | $d2->add(new \DateInterval('PT'.$seconds.'S')); |
| 1591 | 1591 | |
| 1592 | 1592 | $result = $d2->diff($d1); |
| 1593 | - if($result !== false) { |
|
| 1593 | + if ($result !== false) { |
|
| 1594 | 1594 | return $result; |
| 1595 | 1595 | } |
| 1596 | 1596 | |
@@ -181,8 +181,7 @@ discard block |
||
| 181 | 181 | if($datefrom instanceof \DateTime) |
| 182 | 182 | { |
| 183 | 183 | $converter->setDateFrom($datefrom); |
| 184 | - } |
|
| 185 | - else |
|
| 184 | + } else |
|
| 186 | 185 | { |
| 187 | 186 | $converter->setDateFrom(self::timestamp2date($datefrom)); |
| 188 | 187 | } |
@@ -190,8 +189,7 @@ discard block |
||
| 190 | 189 | if($dateto instanceof \DateTime) |
| 191 | 190 | { |
| 192 | 191 | $converter->setDateTo($dateto); |
| 193 | - } |
|
| 194 | - else if($dateto > 0) |
|
| 192 | + } else if($dateto > 0) |
|
| 195 | 193 | { |
| 196 | 194 | $converter->setDateTo(self::timestamp2date($dateto)); |
| 197 | 195 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | // extract parameter names from the query string |
| 38 | 38 | $result = array(); |
| 39 | 39 | preg_match_all('/&?([^&]+)=.*/sixU', $queryString, $result, PREG_PATTERN_ORDER); |
| 40 | - if(isset($result[1])) { |
|
| 40 | + if (isset($result[1])) { |
|
| 41 | 41 | $paramNames = $result[1]; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -60,11 +60,11 @@ discard block |
||
| 60 | 60 | // possible naming conflicts like having both parameters "foo.bar" |
| 61 | 61 | // and "foo_bar" in the query string: since "foo.bar" would be converted |
| 62 | 62 | // to "foo_bar", one of the two would be replaced. |
| 63 | - if($fixRequired) |
|
| 63 | + if ($fixRequired) |
|
| 64 | 64 | { |
| 65 | 65 | $counter = 1; |
| 66 | 66 | $placeholders = array(); |
| 67 | - foreach($paramNames as $paramName) |
|
| 67 | + foreach ($paramNames as $paramName) |
|
| 68 | 68 | { |
| 69 | 69 | // create a unique placeholder name |
| 70 | 70 | $placeholder = '__PLACEHOLDER'.$counter.'__'; |
@@ -94,13 +94,13 @@ discard block |
||
| 94 | 94 | parse_str($queryString, $parsed); |
| 95 | 95 | |
| 96 | 96 | // do any of the parameter names need to be fixed? |
| 97 | - if(!$fixRequired) { |
|
| 97 | + if (!$fixRequired) { |
|
| 98 | 98 | return $parsed; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | $keep = array(); |
| 102 | 102 | |
| 103 | - foreach($parsed as $name => $value) |
|
| 103 | + foreach ($parsed as $name => $value) |
|
| 104 | 104 | { |
| 105 | 105 | $keep[$table[$name]] = $value; |
| 106 | 106 | } |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | return $this->getBoolOption('cut'); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - public function setCuttingEnabled(bool $enabled=true) : ConvertHelper_WordWrapper |
|
| 66 | + public function setCuttingEnabled(bool $enabled = true) : ConvertHelper_WordWrapper |
|
| 67 | 67 | { |
| 68 | 68 | $this->setOption('cut', $enabled); |
| 69 | 69 | return $this; |
@@ -92,8 +92,7 @@ |
||
| 92 | 92 | if (mb_strlen($actual.$word) <= $width) |
| 93 | 93 | { |
| 94 | 94 | $actual .= $word.' '; |
| 95 | - } |
|
| 96 | - else |
|
| 95 | + } else |
|
| 97 | 96 | { |
| 98 | 97 | if ($actual != '') { |
| 99 | 98 | $line .= rtrim($actual).$break; |