@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | $this->bytes = $bytes; |
| 34 | 34 | |
| 35 | 35 | // correct negative values |
| 36 | - if($this->bytes < 0) |
|
| 36 | + if ($this->bytes < 0) |
|
| 37 | 37 | { |
| 38 | 38 | $this->bytes = 0; |
| 39 | 39 | } |
@@ -49,19 +49,19 @@ discard block |
||
| 49 | 49 | { |
| 50 | 50 | $sizes = $this->getSizesSorted($base); |
| 51 | 51 | |
| 52 | - if($this->bytes >= $sizes[0]->getBytes()) |
|
| 52 | + if ($this->bytes >= $sizes[0]->getBytes()) |
|
| 53 | 53 | { |
| 54 | 54 | $total = count($sizes); |
| 55 | 55 | |
| 56 | - for($i=0; $i < $total; $i++) |
|
| 56 | + for ($i = 0; $i < $total; $i++) |
|
| 57 | 57 | { |
| 58 | 58 | $size = $sizes[$i]; |
| 59 | 59 | |
| 60 | - if(!isset($sizes[($i+1)])) { |
|
| 60 | + if (!isset($sizes[($i + 1)])) { |
|
| 61 | 61 | return $size; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - if($this->bytes >= $size->getBytes() && $this->bytes < $sizes[($i+1)]->getBytes()) { |
|
| 64 | + if ($this->bytes >= $size->getBytes() && $this->bytes < $sizes[($i + 1)]->getBytes()) { |
|
| 65 | 65 | return $size; |
| 66 | 66 | } |
| 67 | 67 | } |
@@ -99,11 +99,11 @@ discard block |
||
| 99 | 99 | * @see ConvertHelper_StorageSizeEnum::BASE_10 |
| 100 | 100 | * @see ConvertHelper_StorageSizeEnum::BASE_2 |
| 101 | 101 | */ |
| 102 | - public function toString(int $precision, int $base=ConvertHelper_StorageSizeEnum::BASE_10) : string |
|
| 102 | + public function toString(int $precision, int $base = ConvertHelper_StorageSizeEnum::BASE_10) : string |
|
| 103 | 103 | { |
| 104 | 104 | $size = $this->detectSize($base); |
| 105 | 105 | |
| 106 | - return round($this->bytes / $size->getBytes(), $precision) . ' ' . $size->getSuffix(); |
|
| 106 | + return round($this->bytes / $size->getBytes(), $precision).' '.$size->getSuffix(); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | /** |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @param int $precision Amount of decimals (rounded up) |
| 127 | 127 | * @return float |
| 128 | 128 | */ |
| 129 | - public function toKilobytes(int $precision=1) : float |
|
| 129 | + public function toKilobytes(int $precision = 1) : float |
|
| 130 | 130 | { |
| 131 | 131 | return $this->toNumber($precision, 'kb'); |
| 132 | 132 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @param int $precision Amount of decimals (rounded up) |
| 138 | 138 | * @return float |
| 139 | 139 | */ |
| 140 | - public function toMegabytes(int $precision=1) : float |
|
| 140 | + public function toMegabytes(int $precision = 1) : float |
|
| 141 | 141 | { |
| 142 | 142 | return $this->toNumber($precision, 'mb'); |
| 143 | 143 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @param int $precision Amount of decimals (rounded up) |
| 149 | 149 | * @return float |
| 150 | 150 | */ |
| 151 | - public function toGigabytes(int $precision=1) : float |
|
| 151 | + public function toGigabytes(int $precision = 1) : float |
|
| 152 | 152 | { |
| 153 | 153 | return $this->toNumber($precision, 'gb'); |
| 154 | 154 | } |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * @param int $precision Amount of decimals (rounded up) |
| 160 | 160 | * @return float |
| 161 | 161 | */ |
| 162 | - public function toTerabytes(int $precision=1) : float |
|
| 162 | + public function toTerabytes(int $precision = 1) : float |
|
| 163 | 163 | { |
| 164 | 164 | return $this->toNumber($precision, 'tb'); |
| 165 | 165 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * @param int $precision Amount of decimals (rounded up) |
| 171 | 171 | * @return float |
| 172 | 172 | */ |
| 173 | - public function toPetabytes(int $precision=1) : float |
|
| 173 | + public function toPetabytes(int $precision = 1) : float |
|
| 174 | 174 | { |
| 175 | 175 | return $this->toNumber($precision, 'pb'); |
| 176 | 176 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * @param int $precision Amount of decimals (rounded up) |
| 182 | 182 | * @return float |
| 183 | 183 | */ |
| 184 | - public function toKibibytes(int $precision=1) : float |
|
| 184 | + public function toKibibytes(int $precision = 1) : float |
|
| 185 | 185 | { |
| 186 | 186 | return $this->toNumber($precision, 'kib'); |
| 187 | 187 | } |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * @param int $precision Amount of decimals (rounded up) |
| 193 | 193 | * @return float |
| 194 | 194 | */ |
| 195 | - public function toMebibytes(int $precision=1) : float |
|
| 195 | + public function toMebibytes(int $precision = 1) : float |
|
| 196 | 196 | { |
| 197 | 197 | return $this->toNumber($precision, 'mib'); |
| 198 | 198 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * @param int $precision Amount of decimals (rounded up) |
| 204 | 204 | * @return float |
| 205 | 205 | */ |
| 206 | - public function toGibibytes(int $precision=1) : float |
|
| 206 | + public function toGibibytes(int $precision = 1) : float |
|
| 207 | 207 | { |
| 208 | 208 | return $this->toNumber($precision, 'gib'); |
| 209 | 209 | } |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * @param int $precision Amount of decimals (rounded up) |
| 215 | 215 | * @return float |
| 216 | 216 | */ |
| 217 | - public function toTebibytes(int $precision=1) : float |
|
| 217 | + public function toTebibytes(int $precision = 1) : float |
|
| 218 | 218 | { |
| 219 | 219 | return $this->toNumber($precision, 'tib'); |
| 220 | 220 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * @param int $precision Amount of decimals (rounded up) |
| 226 | 226 | * @return float |
| 227 | 227 | */ |
| 228 | - public function toPebibytes(int $precision=1) : float |
|
| 228 | + public function toPebibytes(int $precision = 1) : float |
|
| 229 | 229 | { |
| 230 | 230 | return $this->toNumber($precision, 'pib'); |
| 231 | 231 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | $amount = substr_count($line, "\t") - $min; |
| 58 | 58 | $line = trim($line); |
| 59 | 59 | if ($amount >= 1) { |
| 60 | - $line = str_repeat("\t", $amount) . $line; |
|
| 60 | + $line = str_repeat("\t", $amount).$line; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | $converted[] = $line; |
@@ -129,10 +129,10 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | // specifically handle zero |
| 131 | 131 | if ($seconds <= 0) { |
| 132 | - return '0 ' . t('seconds'); |
|
| 132 | + return '0 '.t('seconds'); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - if($seconds < 1) { |
|
| 135 | + if ($seconds < 1) { |
|
| 136 | 136 | return t('less than a second'); |
| 137 | 137 | } |
| 138 | 138 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | foreach ($units as $def) { |
| 141 | 141 | $quot = intval($seconds / $def['value']); |
| 142 | 142 | if ($quot) { |
| 143 | - $item = $quot . ' '; |
|
| 143 | + $item = $quot.' '; |
|
| 144 | 144 | if (abs($quot) > 1) { |
| 145 | 145 | $item .= $def['plural']; |
| 146 | 146 | } else { |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | return $last; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - return implode(', ', $tokens) . ' ' . t('and') . ' ' . $last; |
|
| 160 | + return implode(', ', $tokens).' '.t('and').' '.$last; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | { |
| 177 | 177 | $converter = new ConvertHelper_DurationConverter(); |
| 178 | 178 | |
| 179 | - if($datefrom instanceof \DateTime) |
|
| 179 | + if ($datefrom instanceof \DateTime) |
|
| 180 | 180 | { |
| 181 | 181 | $converter->setDateFrom($datefrom); |
| 182 | 182 | } |
@@ -185,11 +185,11 @@ discard block |
||
| 185 | 185 | $converter->setDateFrom(self::timestamp2date($datefrom)); |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - if($dateto instanceof \DateTime) |
|
| 188 | + if ($dateto instanceof \DateTime) |
|
| 189 | 189 | { |
| 190 | 190 | $converter->setDateTo($dateto); |
| 191 | 191 | } |
| 192 | - else if($dateto > 0) |
|
| 192 | + else if ($dateto > 0) |
|
| 193 | 193 | { |
| 194 | 194 | $converter->setDateTo(self::timestamp2date($dateto)); |
| 195 | 195 | } |
@@ -209,9 +209,9 @@ discard block |
||
| 209 | 209 | return $geshi->parse_code(); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - public static function highlight_xml($xml, $formatSource=false) |
|
| 212 | + public static function highlight_xml($xml, $formatSource = false) |
|
| 213 | 213 | { |
| 214 | - if($formatSource) |
|
| 214 | + if ($formatSource) |
|
| 215 | 215 | { |
| 216 | 216 | $dom = new \DOMDocument(); |
| 217 | 217 | $dom->loadXML($xml); |
@@ -278,34 +278,34 @@ discard block |
||
| 278 | 278 | return $text; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - $text = trim(mb_substr($text, 0, $targetLength)) . $append; |
|
| 281 | + $text = trim(mb_substr($text, 0, $targetLength)).$append; |
|
| 282 | 282 | |
| 283 | 283 | return $text; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - public static function var_dump($var, $html=true) |
|
| 286 | + public static function var_dump($var, $html = true) |
|
| 287 | 287 | { |
| 288 | 288 | $info = parseVariable($var); |
| 289 | 289 | |
| 290 | - if($html) { |
|
| 290 | + if ($html) { |
|
| 291 | 291 | return $info->toHTML(); |
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | return $info->toString(); |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - public static function print_r($var, $return=false, $html=true) |
|
| 297 | + public static function print_r($var, $return = false, $html = true) |
|
| 298 | 298 | { |
| 299 | 299 | $result = self::var_dump($var, $html); |
| 300 | 300 | |
| 301 | - if($html) { |
|
| 301 | + if ($html) { |
|
| 302 | 302 | $result = |
| 303 | 303 | '<pre style="background:#fff;color:#333;padding:16px;border:solid 1px #bbb;border-radius:4px">'. |
| 304 | 304 | $result. |
| 305 | 305 | '</pre>'; |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - if($return) { |
|
| 308 | + if ($return) { |
|
| 309 | 309 | return $result; |
| 310 | 310 | } |
| 311 | 311 | |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | |
| 326 | 326 | public static function string2bool($string) |
| 327 | 327 | { |
| 328 | - if($string === '' || $string === null) { |
|
| 328 | + if ($string === '' || $string === null) { |
|
| 329 | 329 | return false; |
| 330 | 330 | } |
| 331 | 331 | |
@@ -380,10 +380,10 @@ discard block |
||
| 380 | 380 | public static function date2listLabel(\DateTime $date, $includeTime = false, $shortMonth = false) |
| 381 | 381 | { |
| 382 | 382 | $today = new \DateTime(); |
| 383 | - if($date->format('d.m.Y') == $today->format('d.m.Y')) { |
|
| 383 | + if ($date->format('d.m.Y') == $today->format('d.m.Y')) { |
|
| 384 | 384 | $label = t('Today'); |
| 385 | 385 | } else { |
| 386 | - $label = $date->format('d') . '. ' . self::month2string((int)$date->format('m'), $shortMonth) . ' '; |
|
| 386 | + $label = $date->format('d').'. '.self::month2string((int)$date->format('m'), $shortMonth).' '; |
|
| 387 | 387 | if ($date->format('Y') != date('Y')) { |
| 388 | 388 | $label .= $date->format('Y'); |
| 389 | 389 | } |
@@ -474,28 +474,28 @@ discard block |
||
| 474 | 474 | $hexAlphabet = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
| 475 | 475 | |
| 476 | 476 | $stack = array(); |
| 477 | - foreach(self::$controlChars as $char) |
|
| 477 | + foreach (self::$controlChars as $char) |
|
| 478 | 478 | { |
| 479 | 479 | $tokens = explode('-', $char); |
| 480 | 480 | $start = $tokens[0]; |
| 481 | 481 | $end = $tokens[1]; |
| 482 | 482 | $prefix = substr($start, 0, 3); |
| 483 | 483 | $range = array(); |
| 484 | - foreach($hexAlphabet as $number) { |
|
| 484 | + foreach ($hexAlphabet as $number) { |
|
| 485 | 485 | $range[] = $prefix.$number; |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | $use = false; |
| 489 | - foreach($range as $number) { |
|
| 490 | - if($number == $start) { |
|
| 489 | + foreach ($range as $number) { |
|
| 490 | + if ($number == $start) { |
|
| 491 | 491 | $use = true; |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | - if($use) { |
|
| 494 | + if ($use) { |
|
| 495 | 495 | $stack[] = $number; |
| 496 | 496 | } |
| 497 | 497 | |
| 498 | - if($number == $end) { |
|
| 498 | + if ($number == $end) { |
|
| 499 | 499 | break; |
| 500 | 500 | } |
| 501 | 501 | } |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | $chars = self::getControlCharactersAsHex(); |
| 517 | 517 | |
| 518 | 518 | $result = array(); |
| 519 | - foreach($chars as $char) { |
|
| 519 | + foreach ($chars as $char) { |
|
| 520 | 520 | $result[] = hex2bin($char); |
| 521 | 521 | } |
| 522 | 522 | |
@@ -534,14 +534,14 @@ discard block |
||
| 534 | 534 | $chars = self::getControlCharactersAsHex(); |
| 535 | 535 | |
| 536 | 536 | $result = array(); |
| 537 | - foreach($chars as $char) { |
|
| 537 | + foreach ($chars as $char) { |
|
| 538 | 538 | $result[] = '\u'.strtolower($char); |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | return $result; |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | - protected static $controlChars = array( |
|
| 544 | + protected static $controlChars = array( |
|
| 545 | 545 | '0000-0008', // control chars |
| 546 | 546 | '000E-000F', // control chars |
| 547 | 547 | '0010-001F', // control chars |
@@ -563,19 +563,19 @@ discard block |
||
| 563 | 563 | */ |
| 564 | 564 | public static function stripControlCharacters(string $string) : string |
| 565 | 565 | { |
| 566 | - if(empty($string)) { |
|
| 566 | + if (empty($string)) { |
|
| 567 | 567 | return $string; |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | // create the regex from the unicode characters list |
| 571 | - if(!isset(self::$controlCharsRegex)) |
|
| 571 | + if (!isset(self::$controlCharsRegex)) |
|
| 572 | 572 | { |
| 573 | 573 | $chars = self::getControlCharactersAsHex(); |
| 574 | 574 | |
| 575 | 575 | // we use the notation \x{0000} to specify the unicode character key |
| 576 | 576 | // in the regular expression. |
| 577 | 577 | $stack = array(); |
| 578 | - foreach($chars as $char) { |
|
| 578 | + foreach ($chars as $char) { |
|
| 579 | 579 | $stack[] = '\x{'.$char.'}'; |
| 580 | 580 | } |
| 581 | 581 | |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | $ordInt = ord($octet); |
| 610 | 610 | // Convert from int (base 10) to hex (base 16), for PHP \x syntax |
| 611 | 611 | $ordHex = base_convert($ordInt, 10, 16); |
| 612 | - $output .= '\x' . $ordHex; |
|
| 612 | + $output .= '\x'.$ordHex; |
|
| 613 | 613 | } |
| 614 | 614 | return $output; |
| 615 | 615 | } |
@@ -641,19 +641,19 @@ discard block |
||
| 641 | 641 | |
| 642 | 642 | protected static function convertScalarForComparison($scalar) |
| 643 | 643 | { |
| 644 | - if($scalar === '' || is_null($scalar)) { |
|
| 644 | + if ($scalar === '' || is_null($scalar)) { |
|
| 645 | 645 | return null; |
| 646 | 646 | } |
| 647 | 647 | |
| 648 | - if(is_bool($scalar)) { |
|
| 648 | + if (is_bool($scalar)) { |
|
| 649 | 649 | return self::bool2string($scalar); |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - if(is_array($scalar)) { |
|
| 652 | + if (is_array($scalar)) { |
|
| 653 | 653 | $scalar = md5(serialize($scalar)); |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | - if($scalar !== null && !is_scalar($scalar)) { |
|
| 656 | + if ($scalar !== null && !is_scalar($scalar)) { |
|
| 657 | 657 | throw new ConvertHelper_Exception( |
| 658 | 658 | 'Not a scalar value in comparison', |
| 659 | 659 | null, |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | public static function bool2string($boolean, bool $yesno = false) : string |
| 703 | 703 | { |
| 704 | 704 | // allow 'yes', 'true', 'no', 'false' string notations as well |
| 705 | - if(!is_bool($boolean)) { |
|
| 705 | + if (!is_bool($boolean)) { |
|
| 706 | 706 | $boolean = self::string2bool($boolean); |
| 707 | 707 | } |
| 708 | 708 | |
@@ -743,15 +743,15 @@ discard block |
||
| 743 | 743 | public static function array2attributeString($array) |
| 744 | 744 | { |
| 745 | 745 | $tokens = array(); |
| 746 | - foreach($array as $attr => $value) { |
|
| 747 | - if($value == '' || $value == null) { |
|
| 746 | + foreach ($array as $attr => $value) { |
|
| 747 | + if ($value == '' || $value == null) { |
|
| 748 | 748 | continue; |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | $tokens[] = $attr.'="'.$value.'"'; |
| 752 | 752 | } |
| 753 | 753 | |
| 754 | - if(empty($tokens)) { |
|
| 754 | + if (empty($tokens)) { |
|
| 755 | 755 | return ''; |
| 756 | 756 | } |
| 757 | 757 | |
@@ -766,10 +766,10 @@ discard block |
||
| 766 | 766 | * @param string $string |
| 767 | 767 | * @return string |
| 768 | 768 | */ |
| 769 | - public static function string2attributeJS($string, $quoted=true) |
|
| 769 | + public static function string2attributeJS($string, $quoted = true) |
|
| 770 | 770 | { |
| 771 | 771 | $converted = addslashes(htmlspecialchars(strip_tags($string), ENT_QUOTES, 'UTF-8')); |
| 772 | - if($quoted) { |
|
| 772 | + if ($quoted) { |
|
| 773 | 773 | $converted = "'".$converted."'"; |
| 774 | 774 | } |
| 775 | 775 | |
@@ -787,11 +787,11 @@ discard block |
||
| 787 | 787 | */ |
| 788 | 788 | public static function isBoolean($value) : bool |
| 789 | 789 | { |
| 790 | - if(is_bool($value)) { |
|
| 790 | + if (is_bool($value)) { |
|
| 791 | 791 | return true; |
| 792 | 792 | } |
| 793 | 793 | |
| 794 | - if(!is_scalar($value)) { |
|
| 794 | + if (!is_scalar($value)) { |
|
| 795 | 795 | return false; |
| 796 | 796 | } |
| 797 | 797 | |
@@ -807,7 +807,7 @@ discard block |
||
| 807 | 807 | public static function array2styleString(array $subject) : string |
| 808 | 808 | { |
| 809 | 809 | $tokens = array(); |
| 810 | - foreach($subject as $name => $value) { |
|
| 810 | + foreach ($subject as $name => $value) { |
|
| 811 | 811 | $tokens[] = $name.':'.$value; |
| 812 | 812 | } |
| 813 | 813 | |
@@ -865,7 +865,7 @@ discard block |
||
| 865 | 865 | * |
| 866 | 866 | * @see JSHelper::buildRegexStatement() |
| 867 | 867 | */ |
| 868 | - public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT) |
|
| 868 | + public static function regex2js(string $regex, string $statementType = JSHelper::JS_REGEX_OBJECT) |
|
| 869 | 869 | { |
| 870 | 870 | return JSHelper::buildRegexStatement($regex, $statementType); |
| 871 | 871 | } |
@@ -882,11 +882,11 @@ discard block |
||
| 882 | 882 | * @throws ConvertHelper_Exception |
| 883 | 883 | * @return string |
| 884 | 884 | */ |
| 885 | - public static function var2json($variable, int $options=0, int $depth=512) : string |
|
| 885 | + public static function var2json($variable, int $options = 0, int $depth = 512) : string |
|
| 886 | 886 | { |
| 887 | 887 | $result = json_encode($variable, $options, $depth); |
| 888 | 888 | |
| 889 | - if($result !== false) { |
|
| 889 | + if ($result !== false) { |
|
| 890 | 890 | return $result; |
| 891 | 891 | } |
| 892 | 892 | |
@@ -911,10 +911,10 @@ discard block |
||
| 911 | 911 | public static function stripUTFBom($string) |
| 912 | 912 | { |
| 913 | 913 | $boms = FileHelper::getUTFBOMs(); |
| 914 | - foreach($boms as $bomChars) { |
|
| 914 | + foreach ($boms as $bomChars) { |
|
| 915 | 915 | $length = mb_strlen($bomChars); |
| 916 | 916 | $text = mb_substr($string, 0, $length); |
| 917 | - if($text==$bomChars) { |
|
| 917 | + if ($text == $bomChars) { |
|
| 918 | 918 | return mb_substr($string, $length); |
| 919 | 919 | } |
| 920 | 920 | } |
@@ -931,7 +931,7 @@ discard block |
||
| 931 | 931 | */ |
| 932 | 932 | public static function string2utf8($string) |
| 933 | 933 | { |
| 934 | - if(!self::isStringASCII($string)) { |
|
| 934 | + if (!self::isStringASCII($string)) { |
|
| 935 | 935 | return \ForceUTF8\Encoding::toUTF8($string); |
| 936 | 936 | } |
| 937 | 937 | |
@@ -949,11 +949,11 @@ discard block |
||
| 949 | 949 | */ |
| 950 | 950 | public static function isStringASCII($string) : bool |
| 951 | 951 | { |
| 952 | - if($string === '' || $string === NULL) { |
|
| 952 | + if ($string === '' || $string === NULL) { |
|
| 953 | 953 | return true; |
| 954 | 954 | } |
| 955 | 955 | |
| 956 | - if(!is_string($string)) { |
|
| 956 | + if (!is_string($string)) { |
|
| 957 | 957 | return false; |
| 958 | 958 | } |
| 959 | 959 | |
@@ -987,7 +987,7 @@ discard block |
||
| 987 | 987 | * @param array $options |
| 988 | 988 | * @return float |
| 989 | 989 | */ |
| 990 | - public static function matchString($source, $target, $options=array()) |
|
| 990 | + public static function matchString($source, $target, $options = array()) |
|
| 991 | 991 | { |
| 992 | 992 | $defaults = array( |
| 993 | 993 | 'maxLevenshtein' => 10, |
@@ -997,12 +997,12 @@ discard block |
||
| 997 | 997 | $options = array_merge($defaults, $options); |
| 998 | 998 | |
| 999 | 999 | // avoid doing this via levenshtein |
| 1000 | - if($source == $target) { |
|
| 1000 | + if ($source == $target) { |
|
| 1001 | 1001 | return 100; |
| 1002 | 1002 | } |
| 1003 | 1003 | |
| 1004 | 1004 | $diff = levenshtein($source, $target); |
| 1005 | - if($diff > $options['maxLevenshtein']) { |
|
| 1005 | + if ($diff > $options['maxLevenshtein']) { |
|
| 1006 | 1006 | return 0; |
| 1007 | 1007 | } |
| 1008 | 1008 | |
@@ -1086,24 +1086,24 @@ discard block |
||
| 1086 | 1086 | * @see ConvertHelper::INTERVAL_HOURS |
| 1087 | 1087 | * @see ConvertHelper::INTERVAL_DAYS |
| 1088 | 1088 | */ |
| 1089 | - public static function interval2total(\DateInterval $interval, $unit=self::INTERVAL_SECONDS) : int |
|
| 1089 | + public static function interval2total(\DateInterval $interval, $unit = self::INTERVAL_SECONDS) : int |
|
| 1090 | 1090 | { |
| 1091 | 1091 | $total = (int)$interval->format('%a'); |
| 1092 | 1092 | if ($unit == self::INTERVAL_DAYS) { |
| 1093 | 1093 | return $total; |
| 1094 | 1094 | } |
| 1095 | 1095 | |
| 1096 | - $total = ($total * 24) + ((int)$interval->h ); |
|
| 1096 | + $total = ($total * 24) + ((int)$interval->h); |
|
| 1097 | 1097 | if ($unit == self::INTERVAL_HOURS) { |
| 1098 | 1098 | return $total; |
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | - $total = ($total * 60) + ((int)$interval->i ); |
|
| 1101 | + $total = ($total * 60) + ((int)$interval->i); |
|
| 1102 | 1102 | if ($unit == self::INTERVAL_MINUTES) { |
| 1103 | 1103 | return $total; |
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | - $total = ($total * 60) + ((int)$interval->s ); |
|
| 1106 | + $total = ($total * 60) + ((int)$interval->s); |
|
| 1107 | 1107 | if ($unit == self::INTERVAL_SECONDS) { |
| 1108 | 1108 | return $total; |
| 1109 | 1109 | } |
@@ -1132,13 +1132,13 @@ discard block |
||
| 1132 | 1132 | * @param bool $short |
| 1133 | 1133 | * @return string|NULL |
| 1134 | 1134 | */ |
| 1135 | - public static function date2dayName(\DateTime $date, bool $short=false) |
|
| 1135 | + public static function date2dayName(\DateTime $date, bool $short = false) |
|
| 1136 | 1136 | { |
| 1137 | 1137 | $day = $date->format('l'); |
| 1138 | 1138 | $invariant = self::getDayNamesInvariant(); |
| 1139 | 1139 | |
| 1140 | 1140 | $idx = array_search($day, $invariant); |
| 1141 | - if($idx !== false) { |
|
| 1141 | + if ($idx !== false) { |
|
| 1142 | 1142 | $localized = self::getDayNames($short); |
| 1143 | 1143 | return $localized[$idx]; |
| 1144 | 1144 | } |
@@ -1161,10 +1161,10 @@ discard block |
||
| 1161 | 1161 | * @param bool $short |
| 1162 | 1162 | * @return array |
| 1163 | 1163 | */ |
| 1164 | - public static function getDayNames(bool $short=false) : array |
|
| 1164 | + public static function getDayNames(bool $short = false) : array |
|
| 1165 | 1165 | { |
| 1166 | - if($short) { |
|
| 1167 | - if(!isset(self::$daysShort)) { |
|
| 1166 | + if ($short) { |
|
| 1167 | + if (!isset(self::$daysShort)) { |
|
| 1168 | 1168 | self::$daysShort = array( |
| 1169 | 1169 | t('Mon'), |
| 1170 | 1170 | t('Tue'), |
@@ -1179,7 +1179,7 @@ discard block |
||
| 1179 | 1179 | return self::$daysShort; |
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | - if(!isset(self::$days)) { |
|
| 1182 | + if (!isset(self::$days)) { |
|
| 1183 | 1183 | self::$days = array( |
| 1184 | 1184 | t('Monday'), |
| 1185 | 1185 | t('Tuesday'), |
@@ -1204,17 +1204,17 @@ discard block |
||
| 1204 | 1204 | */ |
| 1205 | 1205 | public static function implodeWithAnd(array $list, $sep = ', ', $conjunction = null) |
| 1206 | 1206 | { |
| 1207 | - if(empty($list)) { |
|
| 1207 | + if (empty($list)) { |
|
| 1208 | 1208 | return ''; |
| 1209 | 1209 | } |
| 1210 | 1210 | |
| 1211 | - if(empty($conjunction)) { |
|
| 1211 | + if (empty($conjunction)) { |
|
| 1212 | 1212 | $conjunction = t('and'); |
| 1213 | 1213 | } |
| 1214 | 1214 | |
| 1215 | 1215 | $last = array_pop($list); |
| 1216 | - if($list) { |
|
| 1217 | - return implode($sep, $list) . $conjunction . ' ' . $last; |
|
| 1216 | + if ($list) { |
|
| 1217 | + return implode($sep, $list).$conjunction.' '.$last; |
|
| 1218 | 1218 | } |
| 1219 | 1219 | |
| 1220 | 1220 | return $last; |
@@ -1233,7 +1233,7 @@ discard block |
||
| 1233 | 1233 | public static function string2array(string $string) : array |
| 1234 | 1234 | { |
| 1235 | 1235 | $result = preg_split('//u', $string, null, PREG_SPLIT_NO_EMPTY); |
| 1236 | - if($result !== false) { |
|
| 1236 | + if ($result !== false) { |
|
| 1237 | 1237 | return $result; |
| 1238 | 1238 | } |
| 1239 | 1239 | |
@@ -1248,12 +1248,12 @@ discard block |
||
| 1248 | 1248 | */ |
| 1249 | 1249 | public static function isStringHTML(string $string) : bool |
| 1250 | 1250 | { |
| 1251 | - if(preg_match('%<[a-z/][\s\S]*>%siU', $string)) { |
|
| 1251 | + if (preg_match('%<[a-z/][\s\S]*>%siU', $string)) { |
|
| 1252 | 1252 | return true; |
| 1253 | 1253 | } |
| 1254 | 1254 | |
| 1255 | 1255 | $decoded = html_entity_decode($string); |
| 1256 | - if($decoded !== $string) { |
|
| 1256 | + if ($decoded !== $string) { |
|
| 1257 | 1257 | return true; |
| 1258 | 1258 | } |
| 1259 | 1259 | |
@@ -1362,14 +1362,14 @@ discard block |
||
| 1362 | 1362 | * @param bool $caseInsensitive |
| 1363 | 1363 | * @return ConvertHelper_StringMatch[] |
| 1364 | 1364 | */ |
| 1365 | - public static function findString(string $needle, string $haystack, bool $caseInsensitive=false) |
|
| 1365 | + public static function findString(string $needle, string $haystack, bool $caseInsensitive = false) |
|
| 1366 | 1366 | { |
| 1367 | - if($needle === '') { |
|
| 1367 | + if ($needle === '') { |
|
| 1368 | 1368 | return array(); |
| 1369 | 1369 | } |
| 1370 | 1370 | |
| 1371 | 1371 | $function = 'mb_strpos'; |
| 1372 | - if($caseInsensitive) { |
|
| 1372 | + if ($caseInsensitive) { |
|
| 1373 | 1373 | $function = 'mb_stripos'; |
| 1374 | 1374 | } |
| 1375 | 1375 | |
@@ -1377,7 +1377,7 @@ discard block |
||
| 1377 | 1377 | $positions = array(); |
| 1378 | 1378 | $length = mb_strlen($needle); |
| 1379 | 1379 | |
| 1380 | - while( ($pos = $function($haystack, $needle, $pos)) !== false) |
|
| 1380 | + while (($pos = $function($haystack, $needle, $pos)) !== false) |
|
| 1381 | 1381 | { |
| 1382 | 1382 | $match = mb_substr($haystack, $pos, $length); |
| 1383 | 1383 | $positions[] = new ConvertHelper_StringMatch($pos, $match); |
@@ -1397,7 +1397,7 @@ discard block |
||
| 1397 | 1397 | */ |
| 1398 | 1398 | public static function explodeTrim(string $delimiter, string $string) : array |
| 1399 | 1399 | { |
| 1400 | - if(empty($string) || empty($delimiter)) { |
|
| 1400 | + if (empty($string) || empty($delimiter)) { |
|
| 1401 | 1401 | return array(); |
| 1402 | 1402 | } |
| 1403 | 1403 | |
@@ -1405,8 +1405,8 @@ discard block |
||
| 1405 | 1405 | $tokens = array_map('trim', $tokens); |
| 1406 | 1406 | |
| 1407 | 1407 | $keep = array(); |
| 1408 | - foreach($tokens as $token) { |
|
| 1409 | - if($token !== '') { |
|
| 1408 | + foreach ($tokens as $token) { |
|
| 1409 | + if ($token !== '') { |
|
| 1410 | 1410 | $keep[] = $token; |
| 1411 | 1411 | } |
| 1412 | 1412 | } |
@@ -1424,11 +1424,11 @@ discard block |
||
| 1424 | 1424 | */ |
| 1425 | 1425 | public static function detectEOLCharacter(string $subjectString) : ?ConvertHelper_EOL |
| 1426 | 1426 | { |
| 1427 | - if(empty($subjectString)) { |
|
| 1427 | + if (empty($subjectString)) { |
|
| 1428 | 1428 | return null; |
| 1429 | 1429 | } |
| 1430 | 1430 | |
| 1431 | - if(!isset(self::$eolChars)) |
|
| 1431 | + if (!isset(self::$eolChars)) |
|
| 1432 | 1432 | { |
| 1433 | 1433 | $cr = chr((int)hexdec('0d')); |
| 1434 | 1434 | $lf = chr((int)hexdec('0a')); |
@@ -1459,18 +1459,18 @@ discard block |
||
| 1459 | 1459 | |
| 1460 | 1460 | $max = 0; |
| 1461 | 1461 | $results = array(); |
| 1462 | - foreach(self::$eolChars as $def) |
|
| 1462 | + foreach (self::$eolChars as $def) |
|
| 1463 | 1463 | { |
| 1464 | 1464 | $amount = substr_count($subjectString, $def['char']); |
| 1465 | 1465 | |
| 1466 | - if($amount > $max) |
|
| 1466 | + if ($amount > $max) |
|
| 1467 | 1467 | { |
| 1468 | 1468 | $max = $amount; |
| 1469 | 1469 | $results[] = $def; |
| 1470 | 1470 | } |
| 1471 | 1471 | } |
| 1472 | 1472 | |
| 1473 | - if(empty($results)) { |
|
| 1473 | + if (empty($results)) { |
|
| 1474 | 1474 | return null; |
| 1475 | 1475 | } |
| 1476 | 1476 | |
@@ -1490,9 +1490,9 @@ discard block |
||
| 1490 | 1490 | */ |
| 1491 | 1491 | public static function arrayRemoveKeys(array &$array, array $keys) : void |
| 1492 | 1492 | { |
| 1493 | - foreach($keys as $key) |
|
| 1493 | + foreach ($keys as $key) |
|
| 1494 | 1494 | { |
| 1495 | - if(array_key_exists($key, $array)) { |
|
| 1495 | + if (array_key_exists($key, $array)) { |
|
| 1496 | 1496 | unset($array[$key]); |
| 1497 | 1497 | } |
| 1498 | 1498 | } |
@@ -1507,17 +1507,17 @@ discard block |
||
| 1507 | 1507 | */ |
| 1508 | 1508 | public static function isInteger($value) : bool |
| 1509 | 1509 | { |
| 1510 | - if(is_int($value)) { |
|
| 1510 | + if (is_int($value)) { |
|
| 1511 | 1511 | return true; |
| 1512 | 1512 | } |
| 1513 | 1513 | |
| 1514 | 1514 | // booleans get converted to numbers, so they would |
| 1515 | 1515 | // actually match the regex. |
| 1516 | - if(is_bool($value)) { |
|
| 1516 | + if (is_bool($value)) { |
|
| 1517 | 1517 | return false; |
| 1518 | 1518 | } |
| 1519 | 1519 | |
| 1520 | - if(is_string($value) && $value !== '') { |
|
| 1520 | + if (is_string($value) && $value !== '') { |
|
| 1521 | 1521 | return preg_match('/\A-?\d+\z/', $value) === 1; |
| 1522 | 1522 | } |
| 1523 | 1523 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | protected static function init() |
| 46 | 46 | { |
| 47 | - if(isset(self::$sizes)) { |
|
| 47 | + if (isset(self::$sizes)) { |
|
| 48 | 48 | return; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | self::addSize('b', 1, 1, t('B'), t('Byte'), t('Bytes')); |
| 66 | 66 | |
| 67 | - if(class_exists('AppLocalize\Localization')) |
|
| 67 | + if (class_exists('AppLocalize\Localization')) |
|
| 68 | 68 | { |
| 69 | 69 | \AppLocalize\Localization::onLocaleChanged(array(self::class, 'handle_localeChanged')); |
| 70 | 70 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | $name = strtolower($name); |
| 134 | 134 | |
| 135 | - if(isset(self::$sizes[$name])) { |
|
| 135 | + if (isset(self::$sizes[$name])) { |
|
| 136 | 136 | return self::$sizes[$name]; |
| 137 | 137 | } |
| 138 | 138 | |
@@ -174,9 +174,9 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | $result = array(); |
| 176 | 176 | |
| 177 | - foreach(self::$sizes as $size) |
|
| 177 | + foreach (self::$sizes as $size) |
|
| 178 | 178 | { |
| 179 | - if($size->getBase() === $base) { |
|
| 179 | + if ($size->getBase() === $base) { |
|
| 180 | 180 | $result[] = $size; |
| 181 | 181 | } |
| 182 | 182 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @return string |
| 100 | 100 | * @see ConvertHelper::bytes2readable() |
| 101 | 101 | */ |
| 102 | - public function toString(int $precision=1) : string |
|
| 102 | + public function toString(int $precision = 1) : string |
|
| 103 | 103 | { |
| 104 | 104 | return ConvertHelper::bytes2readable($this->bytes, $precision, $this->getBase()); |
| 105 | 105 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | public function getBase() : int |
| 112 | 112 | { |
| 113 | - if($this->isValid()) { |
|
| 113 | + if ($this->isValid()) { |
|
| 114 | 114 | return $this->sizeDefinition->getBase(); |
| 115 | 115 | } |
| 116 | 116 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function getSizeDefinition() : ?ConvertHelper_StorageSizeEnum_Size |
| 128 | 128 | { |
| 129 | - if($this->isValid()) { |
|
| 129 | + if ($this->isValid()) { |
|
| 130 | 130 | return $this->sizeDefinition; |
| 131 | 131 | } |
| 132 | 132 | |
@@ -175,18 +175,18 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | protected function parseSize() : void |
| 177 | 177 | { |
| 178 | - if(!$this->detectParts()) { |
|
| 178 | + if (!$this->detectParts()) { |
|
| 179 | 179 | return; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | // we detected units in the string: all good. |
| 183 | - if($this->units !== null) |
|
| 183 | + if ($this->units !== null) |
|
| 184 | 184 | { |
| 185 | 185 | return; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | // just a numeric value: we assume this means we're dealing with bytes. |
| 189 | - if(is_numeric($this->number)) |
|
| 189 | + if (is_numeric($this->number)) |
|
| 190 | 190 | { |
| 191 | 191 | $this->units = 'b'; |
| 192 | 192 | return; |
@@ -212,12 +212,12 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | $number = $this->sizeString; |
| 214 | 214 | |
| 215 | - foreach($units as $unit) |
|
| 215 | + foreach ($units as $unit) |
|
| 216 | 216 | { |
| 217 | - if(stristr($number, $unit)) |
|
| 217 | + if (stristr($number, $unit)) |
|
| 218 | 218 | { |
| 219 | 219 | // there are more than 1 unit defined in the string |
| 220 | - if($this->units !== null) |
|
| 220 | + if ($this->units !== null) |
|
| 221 | 221 | { |
| 222 | 222 | $this->setError( |
| 223 | 223 | t( |
@@ -273,14 +273,14 @@ discard block |
||
| 273 | 273 | { |
| 274 | 274 | $this->parseSize(); |
| 275 | 275 | |
| 276 | - if(!$this->valid) { |
|
| 276 | + if (!$this->valid) { |
|
| 277 | 277 | return; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | $int = intval($this->number); |
| 281 | 281 | |
| 282 | 282 | // negative values |
| 283 | - if($int < 0) |
|
| 283 | + if ($int < 0) |
|
| 284 | 284 | { |
| 285 | 285 | $this->setError( |
| 286 | 286 | t('Negative values cannot be used as size.'), |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | $this->parse(); |
| 61 | 61 | |
| 62 | - if(!$this->detectType()) { |
|
| 62 | + if (!$this->detectType()) { |
|
| 63 | 63 | $this->validate(); |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -93,11 +93,11 @@ discard block |
||
| 93 | 93 | 'phoneLink' |
| 94 | 94 | ); |
| 95 | 95 | |
| 96 | - foreach($types as $type) |
|
| 96 | + foreach ($types as $type) |
|
| 97 | 97 | { |
| 98 | 98 | $method = 'detectType_'.$type; |
| 99 | 99 | |
| 100 | - if($this->$method() === true) |
|
| 100 | + if ($this->$method() === true) |
|
| 101 | 101 | { |
| 102 | 102 | $this->isValid = true; |
| 103 | 103 | return true; |
@@ -115,11 +115,11 @@ discard block |
||
| 115 | 115 | 'hostIsPresent' |
| 116 | 116 | ); |
| 117 | 117 | |
| 118 | - foreach($validations as $validation) |
|
| 118 | + foreach ($validations as $validation) |
|
| 119 | 119 | { |
| 120 | 120 | $method = 'validate_'.$validation; |
| 121 | 121 | |
| 122 | - if($this->$method() !== true) { |
|
| 122 | + if ($this->$method() !== true) { |
|
| 123 | 123 | return; |
| 124 | 124 | } |
| 125 | 125 | } |
@@ -132,13 +132,13 @@ discard block |
||
| 132 | 132 | // every link needs a host. This case can happen for ex, if |
| 133 | 133 | // the link starts with a typo with only one slash, like: |
| 134 | 134 | // "http:/hostname" |
| 135 | - if(isset($this->info['host'])) { |
|
| 135 | + if (isset($this->info['host'])) { |
|
| 136 | 136 | return true; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | $this->setError( |
| 140 | 140 | URLInfo::ERROR_MISSING_HOST, |
| 141 | - t('Cannot determine the link\'s host name.') . ' ' . |
|
| 141 | + t('Cannot determine the link\'s host name.').' '. |
|
| 142 | 142 | t('This usually happens when there\'s a typo somewhere.') |
| 143 | 143 | ); |
| 144 | 144 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | protected function validate_schemeIsSet() : bool |
| 149 | 149 | { |
| 150 | - if(isset($this->info['scheme'])) { |
|
| 150 | + if (isset($this->info['scheme'])) { |
|
| 151 | 151 | return true; |
| 152 | 152 | } |
| 153 | 153 | |
@@ -164,13 +164,13 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | protected function validate_schemeIsKnown() : bool |
| 166 | 166 | { |
| 167 | - if(in_array($this->info['scheme'], $this->knownSchemes)) { |
|
| 167 | + if (in_array($this->info['scheme'], $this->knownSchemes)) { |
|
| 168 | 168 | return true; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | $this->setError( |
| 172 | 172 | URLInfo::ERROR_INVALID_SCHEME, |
| 173 | - t('The scheme %1$s is not supported for links.', $this->info['scheme']) . ' ' . |
|
| 173 | + t('The scheme %1$s is not supported for links.', $this->info['scheme']).' '. |
|
| 174 | 174 | t('Valid schemes are: %1$s.', implode(', ', $this->knownSchemes)) |
| 175 | 175 | ); |
| 176 | 176 | |
@@ -184,9 +184,9 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | protected function filterParsed() |
| 186 | 186 | { |
| 187 | - foreach($this->info as $key => $val) |
|
| 187 | + foreach ($this->info as $key => $val) |
|
| 188 | 188 | { |
| 189 | - if(is_string($val)) { |
|
| 189 | + if (is_string($val)) { |
|
| 190 | 190 | $this->info[$key] = trim($val); |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -194,15 +194,15 @@ discard block |
||
| 194 | 194 | $this->info['params'] = array(); |
| 195 | 195 | $this->info['type'] = URLInfo::TYPE_URL; |
| 196 | 196 | |
| 197 | - if(isset($this->info['host'])) { |
|
| 197 | + if (isset($this->info['host'])) { |
|
| 198 | 198 | $this->info['host'] = str_replace(' ', '', $this->info['host']); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - if(isset($this->info['path'])) { |
|
| 201 | + if (isset($this->info['path'])) { |
|
| 202 | 202 | $this->info['path'] = str_replace(' ', '', $this->info['path']); |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - if(isset($this->info['query']) && !empty($this->info['query'])) |
|
| 205 | + if (isset($this->info['query']) && !empty($this->info['query'])) |
|
| 206 | 206 | { |
| 207 | 207 | $this->info['params'] = \AppUtils\ConvertHelper::parseQueryString($this->info['query']); |
| 208 | 208 | ksort($this->info['params']); |
@@ -211,12 +211,12 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | protected function detectType_email() : bool |
| 213 | 213 | { |
| 214 | - if(isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') { |
|
| 214 | + if (isset($this->info['scheme']) && $this->info['scheme'] == 'mailto') { |
|
| 215 | 215 | $this->info['type'] = URLInfo::TYPE_EMAIL; |
| 216 | 216 | return true; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - if(isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path'])) |
|
| 219 | + if (isset($this->info['path']) && preg_match(\AppUtils\RegexHelper::REGEX_EMAIL, $this->info['path'])) |
|
| 220 | 220 | { |
| 221 | 221 | $this->info['scheme'] = 'mailto'; |
| 222 | 222 | $this->info['type'] = URLInfo::TYPE_EMAIL; |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | protected function detectType_fragmentLink() : bool |
| 230 | 230 | { |
| 231 | - if(isset($this->info['fragment']) && !isset($this->info['scheme'])) { |
|
| 231 | + if (isset($this->info['fragment']) && !isset($this->info['scheme'])) { |
|
| 232 | 232 | $this->info['type'] = URLInfo::TYPE_FRAGMENT; |
| 233 | 233 | return true; |
| 234 | 234 | } |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | protected function detectType_phoneLink() : bool |
| 240 | 240 | { |
| 241 | - if(isset($this->info['scheme']) && $this->info['scheme'] == 'tel') { |
|
| 241 | + if (isset($this->info['scheme']) && $this->info['scheme'] == 'tel') { |
|
| 242 | 242 | $this->info['type'] = URLInfo::TYPE_PHONE; |
| 243 | 243 | return true; |
| 244 | 244 | } |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | public function getErrorMessage() : string |
| 265 | 265 | { |
| 266 | - if(isset($this->error)) { |
|
| 266 | + if (isset($this->error)) { |
|
| 267 | 267 | return $this->error['message']; |
| 268 | 268 | } |
| 269 | 269 | |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | |
| 273 | 273 | public function getErrorCode() : int |
| 274 | 274 | { |
| 275 | - if(isset($this->error)) { |
|
| 275 | + if (isset($this->error)) { |
|
| 276 | 276 | return $this->error['code']; |
| 277 | 277 | } |
| 278 | 278 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | 'fragment' |
| 78 | 78 | ); |
| 79 | 79 | |
| 80 | - foreach($parts as $part) |
|
| 80 | + foreach ($parts as $part) |
|
| 81 | 81 | { |
| 82 | 82 | $method = 'render_'.$part; |
| 83 | 83 | $result[] = (string)$this->$method(); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | protected function render_scheme() : string |
| 90 | 90 | { |
| 91 | - if(!$this->info->hasScheme()) { |
|
| 91 | + if (!$this->info->hasScheme()) { |
|
| 92 | 92 | return ''; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | protected function render_username() : string |
| 105 | 105 | { |
| 106 | - if(!$this->info->hasUsername()) { |
|
| 106 | + if (!$this->info->hasUsername()) { |
|
| 107 | 107 | return ''; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | protected function render_host() : string |
| 121 | 121 | { |
| 122 | - if(!$this->info->hasHost()) { |
|
| 122 | + if (!$this->info->hasHost()) { |
|
| 123 | 123 | return ''; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | protected function render_port() : string |
| 133 | 133 | { |
| 134 | - if(!$this->info->hasPort()) { |
|
| 134 | + if (!$this->info->hasPort()) { |
|
| 135 | 135 | return ''; |
| 136 | 136 | } |
| 137 | 137 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | protected function render_path() : string |
| 146 | 146 | { |
| 147 | - if(!$this->info->hasPath()) { |
|
| 147 | + if (!$this->info->hasPath()) { |
|
| 148 | 148 | return ''; |
| 149 | 149 | } |
| 150 | 150 | |
@@ -162,19 +162,19 @@ discard block |
||
| 162 | 162 | { |
| 163 | 163 | $params = $this->info->getParams(); |
| 164 | 164 | |
| 165 | - if(empty($params)) { |
|
| 165 | + if (empty($params)) { |
|
| 166 | 166 | return ''; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | $tokens = array(); |
| 170 | 170 | $excluded = array(); |
| 171 | 171 | |
| 172 | - if($this->info->isParamExclusionEnabled()) |
|
| 172 | + if ($this->info->isParamExclusionEnabled()) |
|
| 173 | 173 | { |
| 174 | 174 | $excluded = $this->info->getExcludedParams(); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - foreach($params as $param => $value) |
|
| 177 | + foreach ($params as $param => $value) |
|
| 178 | 178 | { |
| 179 | 179 | $parts = sprintf( |
| 180 | 180 | '<span class="link-param-name">%s</span>'. |
@@ -192,10 +192,10 @@ discard block |
||
| 192 | 192 | $tag = ''; |
| 193 | 193 | |
| 194 | 194 | // is parameter exclusion enabled, and is this an excluded parameter? |
| 195 | - if(isset($excluded[$param])) |
|
| 195 | + if (isset($excluded[$param])) |
|
| 196 | 196 | { |
| 197 | 197 | // display the excluded parameter, but highlight it |
| 198 | - if($this->info->isHighlightExcludeEnabled()) |
|
| 198 | + if ($this->info->isHighlightExcludeEnabled()) |
|
| 199 | 199 | { |
| 200 | 200 | $tooltip = $excluded[$param]; |
| 201 | 201 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | protected function render_fragment() : string |
| 230 | 230 | { |
| 231 | - if(!$this->info->hasFragment()) { |
|
| 231 | + if (!$this->info->hasFragment()) { |
|
| 232 | 232 | return ''; |
| 233 | 233 | } |
| 234 | 234 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function isSecure() : bool |
| 123 | 123 | { |
| 124 | - if(isset($this->info['scheme']) && $this->info['scheme'] === 'https') { |
|
| 124 | + if (isset($this->info['scheme']) && $this->info['scheme'] === 'https') { |
|
| 125 | 125 | return true; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | public function getPort() : int |
| 197 | 197 | { |
| 198 | 198 | $port = $this->getInfoKey('port'); |
| 199 | - if(!empty($port)) { |
|
| 199 | + if (!empty($port)) { |
|
| 200 | 200 | return (int)$port; |
| 201 | 201 | } |
| 202 | 202 | |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | |
| 277 | 277 | protected function getInfoKey(string $name) : string |
| 278 | 278 | { |
| 279 | - if(isset($this->info[$name])) { |
|
| 279 | + if (isset($this->info[$name])) { |
|
| 280 | 280 | return (string)$this->info[$name]; |
| 281 | 281 | } |
| 282 | 282 | |
@@ -285,34 +285,34 @@ discard block |
||
| 285 | 285 | |
| 286 | 286 | public function getNormalized() : string |
| 287 | 287 | { |
| 288 | - if(!$this->isValid()) { |
|
| 288 | + if (!$this->isValid()) { |
|
| 289 | 289 | return ''; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - if($this->isAnchor()) |
|
| 292 | + if ($this->isAnchor()) |
|
| 293 | 293 | { |
| 294 | 294 | return '#'.$this->getFragment(); |
| 295 | 295 | } |
| 296 | - else if($this->isPhoneNumber()) |
|
| 296 | + else if ($this->isPhoneNumber()) |
|
| 297 | 297 | { |
| 298 | 298 | return 'tel://'.$this->getHost(); |
| 299 | 299 | } |
| 300 | - else if($this->isEmail()) |
|
| 300 | + else if ($this->isEmail()) |
|
| 301 | 301 | { |
| 302 | 302 | return 'mailto:'.$this->getPath(); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | $normalized = $this->info['scheme'].'://'.$this->info['host']; |
| 306 | - if(isset($this->info['path'])) { |
|
| 306 | + if (isset($this->info['path'])) { |
|
| 307 | 307 | $normalized .= $this->info['path']; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | $params = $this->getParams(); |
| 311 | - if(!empty($params)) { |
|
| 311 | + if (!empty($params)) { |
|
| 312 | 312 | $normalized .= '?'.http_build_query($params); |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - if(isset($this->info['fragment'])) { |
|
| 315 | + if (isset($this->info['fragment'])) { |
|
| 316 | 316 | $normalized .= '#'.$this->info['fragment']; |
| 317 | 317 | } |
| 318 | 318 | |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | */ |
| 341 | 341 | public function getHighlighted() : string |
| 342 | 342 | { |
| 343 | - if(!$this->isValid()) { |
|
| 343 | + if (!$this->isValid()) { |
|
| 344 | 344 | return ''; |
| 345 | 345 | } |
| 346 | 346 | |
@@ -382,13 +382,13 @@ discard block |
||
| 382 | 382 | */ |
| 383 | 383 | public function getParams() : array |
| 384 | 384 | { |
| 385 | - if(!$this->paramExclusion || empty($this->excludedParams)) { |
|
| 385 | + if (!$this->paramExclusion || empty($this->excludedParams)) { |
|
| 386 | 386 | return $this->info['params']; |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | $keep = array(); |
| 390 | - foreach($this->info['params'] as $name => $value) { |
|
| 391 | - if(!isset($this->excludedParams[$name])) { |
|
| 390 | + foreach ($this->info['params'] as $name => $value) { |
|
| 391 | + if (!isset($this->excludedParams[$name])) { |
|
| 392 | 392 | $keep[$name] = $value; |
| 393 | 393 | } |
| 394 | 394 | } |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | */ |
| 415 | 415 | public function getParam(string $name) : string |
| 416 | 416 | { |
| 417 | - if(isset($this->info['params'][$name])) { |
|
| 417 | + if (isset($this->info['params'][$name])) { |
|
| 418 | 418 | return $this->info['params'][$name]; |
| 419 | 419 | } |
| 420 | 420 | |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | */ |
| 434 | 434 | public function excludeParam(string $name, string $reason) : URLInfo |
| 435 | 435 | { |
| 436 | - if(!isset($this->excludedParams[$name])) |
|
| 436 | + if (!isset($this->excludedParams[$name])) |
|
| 437 | 437 | { |
| 438 | 438 | $this->excludedParams[$name] = $reason; |
| 439 | 439 | $this->setParamExclusion(); |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | |
| 460 | 460 | public function getTypeLabel() : string |
| 461 | 461 | { |
| 462 | - if(!isset(self::$typeLabels)) |
|
| 462 | + if (!isset(self::$typeLabels)) |
|
| 463 | 463 | { |
| 464 | 464 | self::$typeLabels = array( |
| 465 | 465 | self::TYPE_EMAIL => t('Email'), |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | |
| 472 | 472 | $type = $this->getType(); |
| 473 | 473 | |
| 474 | - if(!isset(self::$typeLabels[$type])) |
|
| 474 | + if (!isset(self::$typeLabels[$type])) |
|
| 475 | 475 | { |
| 476 | 476 | throw new BaseException( |
| 477 | 477 | sprintf('Unknown URL type label for type [%s].', $type), |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | * @param bool $highlight |
| 492 | 492 | * @return URLInfo |
| 493 | 493 | */ |
| 494 | - public function setHighlightExcluded(bool $highlight=true) : URLInfo |
|
| 494 | + public function setHighlightExcluded(bool $highlight = true) : URLInfo |
|
| 495 | 495 | { |
| 496 | 496 | $this->highlightExcluded = $highlight; |
| 497 | 497 | return $this; |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | * @see URLInfo::isParamExclusionEnabled() |
| 540 | 540 | * @see URLInfo::setHighlightExcluded() |
| 541 | 541 | */ |
| 542 | - public function setParamExclusion(bool $enabled=true) : URLInfo |
|
| 542 | + public function setParamExclusion(bool $enabled = true) : URLInfo |
|
| 543 | 543 | { |
| 544 | 544 | $this->paramExclusion = $enabled; |
| 545 | 545 | return $this; |
@@ -565,13 +565,13 @@ discard block |
||
| 565 | 565 | */ |
| 566 | 566 | public function containsExcludedParams() : bool |
| 567 | 567 | { |
| 568 | - if(empty($this->excludedParams)) { |
|
| 568 | + if (empty($this->excludedParams)) { |
|
| 569 | 569 | return false; |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | $names = array_keys($this->info['params']); |
| 573 | - foreach($names as $name) { |
|
| 574 | - if(isset($this->excludedParams[$name])) { |
|
| 573 | + foreach ($names as $name) { |
|
| 574 | + if (isset($this->excludedParams[$name])) { |
|
| 575 | 575 | return true; |
| 576 | 576 | } |
| 577 | 577 | } |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | |
| 588 | 588 | public function offsetSet($offset, $value) |
| 589 | 589 | { |
| 590 | - if(in_array($offset, $this->infoKeys)) { |
|
| 590 | + if (in_array($offset, $this->infoKeys)) { |
|
| 591 | 591 | $this->info[$offset] = $value; |
| 592 | 592 | } |
| 593 | 593 | } |
@@ -604,11 +604,11 @@ discard block |
||
| 604 | 604 | |
| 605 | 605 | public function offsetGet($offset) |
| 606 | 606 | { |
| 607 | - if($offset === 'port') { |
|
| 607 | + if ($offset === 'port') { |
|
| 608 | 608 | return $this->getPort(); |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | - if(in_array($offset, $this->infoKeys)) { |
|
| 611 | + if (in_array($offset, $this->infoKeys)) { |
|
| 612 | 612 | return $this->getInfoKey($offset); |
| 613 | 613 | } |
| 614 | 614 | |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | { |
| 620 | 620 | $cssFolder = realpath(__DIR__.'/../css'); |
| 621 | 621 | |
| 622 | - if($cssFolder === false) { |
|
| 622 | + if ($cssFolder === false) { |
|
| 623 | 623 | throw new BaseException( |
| 624 | 624 | 'Cannot find package CSS folder.', |
| 625 | 625 | null, |