@@ -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 | } |
@@ -160,41 +160,41 @@ discard block |
||
160 | 160 | return implode(', ', $tokens) . ' ' . t('and') . ' ' . $last; |
161 | 161 | } |
162 | 162 | |
163 | - /** |
|
164 | - * Converts a timestamp into an easily understandable |
|
165 | - * format, e.g. "2 hours", "1 day", "3 months" |
|
166 | - * |
|
167 | - * If you set the date to parameter, the difference |
|
168 | - * will be calculated between the two dates and not |
|
169 | - * the current time. |
|
170 | - * |
|
171 | - * @param integer|\DateTime $datefrom |
|
172 | - * @param integer|\DateTime $dateto |
|
173 | - * @return string |
|
174 | - */ |
|
163 | + /** |
|
164 | + * Converts a timestamp into an easily understandable |
|
165 | + * format, e.g. "2 hours", "1 day", "3 months" |
|
166 | + * |
|
167 | + * If you set the date to parameter, the difference |
|
168 | + * will be calculated between the two dates and not |
|
169 | + * the current time. |
|
170 | + * |
|
171 | + * @param integer|\DateTime $datefrom |
|
172 | + * @param integer|\DateTime $dateto |
|
173 | + * @return string |
|
174 | + */ |
|
175 | 175 | public static function duration2string($datefrom, $dateto = -1) : string |
176 | 176 | { |
177 | - $converter = new ConvertHelper_DurationConverter(); |
|
177 | + $converter = new ConvertHelper_DurationConverter(); |
|
178 | 178 | |
179 | - if($datefrom instanceof \DateTime) |
|
180 | - { |
|
181 | - $converter->setDateFrom($datefrom); |
|
182 | - } |
|
183 | - else |
|
184 | - { |
|
185 | - $converter->setDateFrom(self::timestamp2date($datefrom)); |
|
186 | - } |
|
179 | + if($datefrom instanceof \DateTime) |
|
180 | + { |
|
181 | + $converter->setDateFrom($datefrom); |
|
182 | + } |
|
183 | + else |
|
184 | + { |
|
185 | + $converter->setDateFrom(self::timestamp2date($datefrom)); |
|
186 | + } |
|
187 | 187 | |
188 | - if($dateto instanceof \DateTime) |
|
189 | - { |
|
190 | - $converter->setDateTo($dateto); |
|
191 | - } |
|
192 | - else if($dateto > 0) |
|
193 | - { |
|
194 | - $converter->setDateTo(self::timestamp2date($dateto)); |
|
195 | - } |
|
188 | + if($dateto instanceof \DateTime) |
|
189 | + { |
|
190 | + $converter->setDateTo($dateto); |
|
191 | + } |
|
192 | + else if($dateto > 0) |
|
193 | + { |
|
194 | + $converter->setDateTo(self::timestamp2date($dateto)); |
|
195 | + } |
|
196 | 196 | |
197 | - return $converter->convert(); |
|
197 | + return $converter->convert(); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -267,16 +267,16 @@ discard block |
||
267 | 267 | return $bytes . ' ' . t('B'); |
268 | 268 | } |
269 | 269 | |
270 | - /** |
|
271 | - * Cuts a text to the specified length if it is longer than the |
|
272 | - * target length. Appends a text to signify it has been cut at |
|
273 | - * the end of the string. |
|
274 | - * |
|
275 | - * @param string $text |
|
276 | - * @param int $targetLength |
|
277 | - * @param string $append |
|
278 | - * @return string |
|
279 | - */ |
|
270 | + /** |
|
271 | + * Cuts a text to the specified length if it is longer than the |
|
272 | + * target length. Appends a text to signify it has been cut at |
|
273 | + * the end of the string. |
|
274 | + * |
|
275 | + * @param string $text |
|
276 | + * @param int $targetLength |
|
277 | + * @param string $append |
|
278 | + * @return string |
|
279 | + */ |
|
280 | 280 | public static function text_cut(string $text, int $targetLength, string $append = '...') : string |
281 | 281 | { |
282 | 282 | $length = mb_strlen($text); |
@@ -346,27 +346,27 @@ discard block |
||
346 | 346 | return self::$booleanStrings[$string]; |
347 | 347 | } |
348 | 348 | |
349 | - /** |
|
350 | - * Whether the specified string is a boolean string or boolean value. |
|
351 | - * Alias for {@link ConvertHelper::isBoolean()}. |
|
352 | - * |
|
353 | - * @param mixed $string |
|
354 | - * @return bool |
|
355 | - * @deprecated |
|
356 | - * @see ConvertHelper::isBoolean() |
|
357 | - */ |
|
349 | + /** |
|
350 | + * Whether the specified string is a boolean string or boolean value. |
|
351 | + * Alias for {@link ConvertHelper::isBoolean()}. |
|
352 | + * |
|
353 | + * @param mixed $string |
|
354 | + * @return bool |
|
355 | + * @deprecated |
|
356 | + * @see ConvertHelper::isBoolean() |
|
357 | + */ |
|
358 | 358 | public static function isBooleanString($string) : bool |
359 | 359 | { |
360 | 360 | return self::isBoolean($string); |
361 | 361 | } |
362 | 362 | |
363 | - /** |
|
364 | - * Alias for the {@\AppUtils\XMLHelper::string2xml()} method. |
|
365 | - * |
|
366 | - * @param string $text |
|
367 | - * @return string |
|
368 | - * @deprecated |
|
369 | - */ |
|
363 | + /** |
|
364 | + * Alias for the {@\AppUtils\XMLHelper::string2xml()} method. |
|
365 | + * |
|
366 | + * @param string $text |
|
367 | + * @return string |
|
368 | + * @deprecated |
|
369 | + */ |
|
370 | 370 | public static function text_makeXMLCompliant($text) |
371 | 371 | { |
372 | 372 | return XMLHelper::string2xml($text); |
@@ -468,13 +468,13 @@ discard block |
||
468 | 468 | return $translit->convert($string); |
469 | 469 | } |
470 | 470 | |
471 | - /** |
|
472 | - * Retrieves the HEX character codes for all control |
|
473 | - * characters that the {@link stripControlCharacters()} |
|
474 | - * method will remove. |
|
475 | - * |
|
476 | - * @return string[] |
|
477 | - */ |
|
471 | + /** |
|
472 | + * Retrieves the HEX character codes for all control |
|
473 | + * characters that the {@link stripControlCharacters()} |
|
474 | + * method will remove. |
|
475 | + * |
|
476 | + * @return string[] |
|
477 | + */ |
|
478 | 478 | public static function getControlCharactersAsHex() |
479 | 479 | { |
480 | 480 | $hexAlphabet = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
@@ -510,13 +510,13 @@ discard block |
||
510 | 510 | return $stack; |
511 | 511 | } |
512 | 512 | |
513 | - /** |
|
514 | - * Retrieves an array of all control characters that |
|
515 | - * the {@link stripControlCharacters()} method will |
|
516 | - * remove, as the actual UTF-8 characters. |
|
517 | - * |
|
518 | - * @return string[] |
|
519 | - */ |
|
513 | + /** |
|
514 | + * Retrieves an array of all control characters that |
|
515 | + * the {@link stripControlCharacters()} method will |
|
516 | + * remove, as the actual UTF-8 characters. |
|
517 | + * |
|
518 | + * @return string[] |
|
519 | + */ |
|
520 | 520 | public static function getControlCharactersAsUTF8() |
521 | 521 | { |
522 | 522 | $chars = self::getControlCharactersAsHex(); |
@@ -529,12 +529,12 @@ discard block |
||
529 | 529 | return $result; |
530 | 530 | } |
531 | 531 | |
532 | - /** |
|
533 | - * Retrieves all control characters as JSON encoded |
|
534 | - * characters, e.g. "\u200b". |
|
535 | - * |
|
536 | - * @return string[] |
|
537 | - */ |
|
532 | + /** |
|
533 | + * Retrieves all control characters as JSON encoded |
|
534 | + * characters, e.g. "\u200b". |
|
535 | + * |
|
536 | + * @return string[] |
|
537 | + */ |
|
538 | 538 | public static function getControlCharactersAsJSON() |
539 | 539 | { |
540 | 540 | $chars = self::getControlCharactersAsHex(); |
@@ -591,20 +591,20 @@ discard block |
||
591 | 591 | return preg_replace(self::$controlCharsRegex, '', $string); |
592 | 592 | } |
593 | 593 | |
594 | - /** |
|
595 | - * Converts a unicode character to the PHPO notation. |
|
596 | - * |
|
597 | - * Example: |
|
598 | - * |
|
599 | - * <pre>unicodeChar2php('"\u0000"')</pre> |
|
600 | - * |
|
601 | - * Returns |
|
602 | - * |
|
603 | - * <pre>\x0</pre> |
|
604 | - * |
|
605 | - * @param string $unicodeChar |
|
606 | - * @return string |
|
607 | - */ |
|
594 | + /** |
|
595 | + * Converts a unicode character to the PHPO notation. |
|
596 | + * |
|
597 | + * Example: |
|
598 | + * |
|
599 | + * <pre>unicodeChar2php('"\u0000"')</pre> |
|
600 | + * |
|
601 | + * Returns |
|
602 | + * |
|
603 | + * <pre>\x0</pre> |
|
604 | + * |
|
605 | + * @param string $unicodeChar |
|
606 | + * @return string |
|
607 | + */ |
|
608 | 608 | public static function unicodeChar2php($unicodeChar) |
609 | 609 | { |
610 | 610 | $unicodeChar = json_decode($unicodeChar); |
@@ -727,25 +727,25 @@ discard block |
||
727 | 727 | return 'false'; |
728 | 728 | } |
729 | 729 | |
730 | - /** |
|
731 | - * Converts an associative array with attribute name > value pairs |
|
732 | - * to an attribute string that can be used in an HTML tag. Empty |
|
733 | - * attribute values are ignored. |
|
734 | - * |
|
735 | - * Example: |
|
736 | - * |
|
737 | - * array2attributeString(array( |
|
738 | - * 'id' => 45, |
|
739 | - * 'href' => 'http://www.mistralys.com' |
|
740 | - * )); |
|
741 | - * |
|
742 | - * Result: |
|
743 | - * |
|
744 | - * id="45" href="http://www.mistralys.com" |
|
745 | - * |
|
746 | - * @param array $array |
|
747 | - * @return string |
|
748 | - */ |
|
730 | + /** |
|
731 | + * Converts an associative array with attribute name > value pairs |
|
732 | + * to an attribute string that can be used in an HTML tag. Empty |
|
733 | + * attribute values are ignored. |
|
734 | + * |
|
735 | + * Example: |
|
736 | + * |
|
737 | + * array2attributeString(array( |
|
738 | + * 'id' => 45, |
|
739 | + * 'href' => 'http://www.mistralys.com' |
|
740 | + * )); |
|
741 | + * |
|
742 | + * Result: |
|
743 | + * |
|
744 | + * id="45" href="http://www.mistralys.com" |
|
745 | + * |
|
746 | + * @param array $array |
|
747 | + * @return string |
|
748 | + */ |
|
749 | 749 | public static function array2attributeString($array) |
750 | 750 | { |
751 | 751 | $tokens = array(); |
@@ -764,14 +764,14 @@ discard block |
||
764 | 764 | return ' '.implode(' ', $tokens); |
765 | 765 | } |
766 | 766 | |
767 | - /** |
|
768 | - * Converts a string so it can safely be used in a javascript |
|
769 | - * statement in an HTML tag: uses single quotes around the string |
|
770 | - * and encodes all special characters as needed. |
|
771 | - * |
|
772 | - * @param string $string |
|
773 | - * @return string |
|
774 | - */ |
|
767 | + /** |
|
768 | + * Converts a string so it can safely be used in a javascript |
|
769 | + * statement in an HTML tag: uses single quotes around the string |
|
770 | + * and encodes all special characters as needed. |
|
771 | + * |
|
772 | + * @param string $string |
|
773 | + * @return string |
|
774 | + */ |
|
775 | 775 | public static function string2attributeJS($string, $quoted=true) |
776 | 776 | { |
777 | 777 | $converted = addslashes(htmlspecialchars(strip_tags($string), ENT_QUOTES, 'UTF-8')); |
@@ -782,15 +782,15 @@ discard block |
||
782 | 782 | return $converted; |
783 | 783 | } |
784 | 784 | |
785 | - /** |
|
786 | - * Checks if the specified string is a boolean value, which |
|
787 | - * includes string representations of boolean values, like |
|
788 | - * <code>yes</code> or <code>no</code>, and <code>true</code> |
|
789 | - * or <code>false</code>. |
|
790 | - * |
|
791 | - * @param mixed $value |
|
792 | - * @return boolean |
|
793 | - */ |
|
785 | + /** |
|
786 | + * Checks if the specified string is a boolean value, which |
|
787 | + * includes string representations of boolean values, like |
|
788 | + * <code>yes</code> or <code>no</code>, and <code>true</code> |
|
789 | + * or <code>false</code>. |
|
790 | + * |
|
791 | + * @param mixed $value |
|
792 | + * @return boolean |
|
793 | + */ |
|
794 | 794 | public static function isBoolean($value) : bool |
795 | 795 | { |
796 | 796 | if(is_bool($value)) { |
@@ -804,12 +804,12 @@ discard block |
||
804 | 804 | return array_key_exists($value, self::$booleanStrings); |
805 | 805 | } |
806 | 806 | |
807 | - /** |
|
808 | - * Converts an associative array to an HTML style attribute value string. |
|
809 | - * |
|
810 | - * @param array $subject |
|
811 | - * @return string |
|
812 | - */ |
|
807 | + /** |
|
808 | + * Converts an associative array to an HTML style attribute value string. |
|
809 | + * |
|
810 | + * @param array $subject |
|
811 | + * @return string |
|
812 | + */ |
|
813 | 813 | public static function array2styleString(array $subject) : string |
814 | 814 | { |
815 | 815 | $tokens = array(); |
@@ -820,23 +820,23 @@ discard block |
||
820 | 820 | return implode(';', $tokens); |
821 | 821 | } |
822 | 822 | |
823 | - /** |
|
824 | - * Converts a DateTime object to a timestamp, which |
|
825 | - * is PHP 5.2 compatible. |
|
826 | - * |
|
827 | - * @param \DateTime $date |
|
828 | - * @return integer |
|
829 | - */ |
|
823 | + /** |
|
824 | + * Converts a DateTime object to a timestamp, which |
|
825 | + * is PHP 5.2 compatible. |
|
826 | + * |
|
827 | + * @param \DateTime $date |
|
828 | + * @return integer |
|
829 | + */ |
|
830 | 830 | public static function date2timestamp(\DateTime $date) : int |
831 | 831 | { |
832 | 832 | return (int)$date->format('U'); |
833 | 833 | } |
834 | 834 | |
835 | - /** |
|
836 | - * Converts a timestamp into a DateTime instance. |
|
837 | - * @param int $timestamp |
|
838 | - * @return \DateTime |
|
839 | - */ |
|
835 | + /** |
|
836 | + * Converts a timestamp into a DateTime instance. |
|
837 | + * @param int $timestamp |
|
838 | + * @return \DateTime |
|
839 | + */ |
|
840 | 840 | public static function timestamp2date(int $timestamp) : \DateTime |
841 | 841 | { |
842 | 842 | $date = new \DateTime(); |
@@ -844,50 +844,50 @@ discard block |
||
844 | 844 | return $date; |
845 | 845 | } |
846 | 846 | |
847 | - /** |
|
848 | - * Strips an absolute path to a file within the application |
|
849 | - * to make the path relative to the application root path. |
|
850 | - * |
|
851 | - * @param string $path |
|
852 | - * @return string |
|
853 | - * |
|
854 | - * @see FileHelper::relativizePath() |
|
855 | - * @see FileHelper::relativizePathByDepth() |
|
856 | - */ |
|
847 | + /** |
|
848 | + * Strips an absolute path to a file within the application |
|
849 | + * to make the path relative to the application root path. |
|
850 | + * |
|
851 | + * @param string $path |
|
852 | + * @return string |
|
853 | + * |
|
854 | + * @see FileHelper::relativizePath() |
|
855 | + * @see FileHelper::relativizePathByDepth() |
|
856 | + */ |
|
857 | 857 | public static function fileRelativize(string $path) : string |
858 | 858 | { |
859 | 859 | return FileHelper::relativizePathByDepth($path); |
860 | 860 | } |
861 | 861 | |
862 | 862 | /** |
863 | - * Converts a PHP regex to a javascript RegExp object statement. |
|
864 | - * |
|
865 | - * NOTE: This is an alias for the JSHelper's `convertRegex` method. |
|
866 | - * More details are available on its usage there. |
|
867 | - * |
|
868 | - * @param string $regex A PHP preg regex |
|
869 | - * @param string $statementType The type of statement to return: Defaults to a statement to create a RegExp object. |
|
870 | - * @return array|string Depending on the specified return type. |
|
871 | - * |
|
872 | - * @see JSHelper::buildRegexStatement() |
|
873 | - */ |
|
863 | + * Converts a PHP regex to a javascript RegExp object statement. |
|
864 | + * |
|
865 | + * NOTE: This is an alias for the JSHelper's `convertRegex` method. |
|
866 | + * More details are available on its usage there. |
|
867 | + * |
|
868 | + * @param string $regex A PHP preg regex |
|
869 | + * @param string $statementType The type of statement to return: Defaults to a statement to create a RegExp object. |
|
870 | + * @return array|string Depending on the specified return type. |
|
871 | + * |
|
872 | + * @see JSHelper::buildRegexStatement() |
|
873 | + */ |
|
874 | 874 | public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT) |
875 | 875 | { |
876 | 876 | return JSHelper::buildRegexStatement($regex, $statementType); |
877 | 877 | } |
878 | 878 | |
879 | - /** |
|
880 | - * Converts the specified variable to JSON. Works just |
|
881 | - * like the native `json_encode` method, except that it |
|
882 | - * will trigger an exception on failure, which has the |
|
883 | - * json error details included in its developer details. |
|
884 | - * |
|
885 | - * @param mixed $variable |
|
886 | - * @param int|NULL $options JSON encode options. |
|
887 | - * @param int|NULL $depth |
|
888 | - * @throws ConvertHelper_Exception |
|
889 | - * @return string |
|
890 | - */ |
|
879 | + /** |
|
880 | + * Converts the specified variable to JSON. Works just |
|
881 | + * like the native `json_encode` method, except that it |
|
882 | + * will trigger an exception on failure, which has the |
|
883 | + * json error details included in its developer details. |
|
884 | + * |
|
885 | + * @param mixed $variable |
|
886 | + * @param int|NULL $options JSON encode options. |
|
887 | + * @param int|NULL $depth |
|
888 | + * @throws ConvertHelper_Exception |
|
889 | + * @return string |
|
890 | + */ |
|
891 | 891 | public static function var2json($variable, int $options=0, int $depth=512) : string |
892 | 892 | { |
893 | 893 | $result = json_encode($variable, $options, $depth); |
@@ -908,12 +908,12 @@ discard block |
||
908 | 908 | ); |
909 | 909 | } |
910 | 910 | |
911 | - /** |
|
912 | - * Strips all known UTF byte order marks from the specified string. |
|
913 | - * |
|
914 | - * @param string $string |
|
915 | - * @return string |
|
916 | - */ |
|
911 | + /** |
|
912 | + * Strips all known UTF byte order marks from the specified string. |
|
913 | + * |
|
914 | + * @param string $string |
|
915 | + * @return string |
|
916 | + */ |
|
917 | 917 | public static function stripUTFBom($string) |
918 | 918 | { |
919 | 919 | $boms = FileHelper::getUTFBOMs(); |
@@ -928,13 +928,13 @@ discard block |
||
928 | 928 | return $string; |
929 | 929 | } |
930 | 930 | |
931 | - /** |
|
932 | - * Converts a string to valid utf8, regardless |
|
933 | - * of the string's encoding(s). |
|
934 | - * |
|
935 | - * @param string $string |
|
936 | - * @return string |
|
937 | - */ |
|
931 | + /** |
|
932 | + * Converts a string to valid utf8, regardless |
|
933 | + * of the string's encoding(s). |
|
934 | + * |
|
935 | + * @param string $string |
|
936 | + * @return string |
|
937 | + */ |
|
938 | 938 | public static function string2utf8($string) |
939 | 939 | { |
940 | 940 | if(!self::isStringASCII($string)) { |
@@ -944,15 +944,15 @@ discard block |
||
944 | 944 | return $string; |
945 | 945 | } |
946 | 946 | |
947 | - /** |
|
948 | - * Checks whether the specified string is an ASCII |
|
949 | - * string, without any special or UTF8 characters. |
|
950 | - * Note: empty strings and NULL are considered ASCII. |
|
951 | - * Any variable types other than strings are not. |
|
952 | - * |
|
953 | - * @param mixed $string |
|
954 | - * @return boolean |
|
955 | - */ |
|
947 | + /** |
|
948 | + * Checks whether the specified string is an ASCII |
|
949 | + * string, without any special or UTF8 characters. |
|
950 | + * Note: empty strings and NULL are considered ASCII. |
|
951 | + * Any variable types other than strings are not. |
|
952 | + * |
|
953 | + * @param mixed $string |
|
954 | + * @return boolean |
|
955 | + */ |
|
956 | 956 | public static function isStringASCII($string) : bool |
957 | 957 | { |
958 | 958 | if($string === '' || $string === NULL) { |
@@ -977,22 +977,22 @@ discard block |
||
977 | 977 | return $url; |
978 | 978 | } |
979 | 979 | |
980 | - /** |
|
981 | - * Calculates a percentage match of the source string with the target string. |
|
982 | - * |
|
983 | - * Options are: |
|
984 | - * |
|
985 | - * - maxLevenshtein, default: 10 |
|
986 | - * Any levenshtein results above this value are ignored. |
|
987 | - * |
|
988 | - * - precision, default: 1 |
|
989 | - * The precision of the percentage float value |
|
990 | - * |
|
991 | - * @param string $source |
|
992 | - * @param string $target |
|
993 | - * @param array $options |
|
994 | - * @return float |
|
995 | - */ |
|
980 | + /** |
|
981 | + * Calculates a percentage match of the source string with the target string. |
|
982 | + * |
|
983 | + * Options are: |
|
984 | + * |
|
985 | + * - maxLevenshtein, default: 10 |
|
986 | + * Any levenshtein results above this value are ignored. |
|
987 | + * |
|
988 | + * - precision, default: 1 |
|
989 | + * The precision of the percentage float value |
|
990 | + * |
|
991 | + * @param string $source |
|
992 | + * @param string $target |
|
993 | + * @param array $options |
|
994 | + * @return float |
|
995 | + */ |
|
996 | 996 | public static function matchString($source, $target, $options=array()) |
997 | 997 | { |
998 | 998 | $defaults = array( |
@@ -1016,14 +1016,14 @@ discard block |
||
1016 | 1016 | return round(100 - $percent, $options['precision']); |
1017 | 1017 | } |
1018 | 1018 | |
1019 | - /** |
|
1020 | - * Converts a date interval to a human readable string with |
|
1021 | - * all necessary time components, e.g. "1 year, 2 months and 4 days". |
|
1022 | - * |
|
1023 | - * @param \DateInterval $interval |
|
1024 | - * @return string |
|
1025 | - * @see ConvertHelper_IntervalConverter |
|
1026 | - */ |
|
1019 | + /** |
|
1020 | + * Converts a date interval to a human readable string with |
|
1021 | + * all necessary time components, e.g. "1 year, 2 months and 4 days". |
|
1022 | + * |
|
1023 | + * @param \DateInterval $interval |
|
1024 | + * @return string |
|
1025 | + * @see ConvertHelper_IntervalConverter |
|
1026 | + */ |
|
1027 | 1027 | public static function interval2string(\DateInterval $interval) : string |
1028 | 1028 | { |
1029 | 1029 | $converter = new ConvertHelper_IntervalConverter(); |
@@ -1038,60 +1038,60 @@ discard block |
||
1038 | 1038 | |
1039 | 1039 | const INTERVAL_SECONDS = 'seconds'; |
1040 | 1040 | |
1041 | - /** |
|
1042 | - * Converts an interval to its total amount of days. |
|
1043 | - * @param \DateInterval $interval |
|
1044 | - * @return int |
|
1045 | - */ |
|
1041 | + /** |
|
1042 | + * Converts an interval to its total amount of days. |
|
1043 | + * @param \DateInterval $interval |
|
1044 | + * @return int |
|
1045 | + */ |
|
1046 | 1046 | public static function interval2days(\DateInterval $interval) : int |
1047 | 1047 | { |
1048 | 1048 | return self::interval2total($interval, self::INTERVAL_DAYS); |
1049 | 1049 | } |
1050 | 1050 | |
1051 | - /** |
|
1052 | - * Converts an interval to its total amount of hours. |
|
1053 | - * @param \DateInterval $interval |
|
1054 | - * @return int |
|
1055 | - */ |
|
1051 | + /** |
|
1052 | + * Converts an interval to its total amount of hours. |
|
1053 | + * @param \DateInterval $interval |
|
1054 | + * @return int |
|
1055 | + */ |
|
1056 | 1056 | public static function interval2hours(\DateInterval $interval) : int |
1057 | 1057 | { |
1058 | 1058 | return self::interval2total($interval, self::INTERVAL_HOURS); |
1059 | 1059 | } |
1060 | 1060 | |
1061 | - /** |
|
1062 | - * Converts an interval to its total amount of minutes. |
|
1063 | - * @param \DateInterval $interval |
|
1064 | - * @return int |
|
1065 | - */ |
|
1061 | + /** |
|
1062 | + * Converts an interval to its total amount of minutes. |
|
1063 | + * @param \DateInterval $interval |
|
1064 | + * @return int |
|
1065 | + */ |
|
1066 | 1066 | public static function interval2minutes(\DateInterval $interval) : int |
1067 | 1067 | { |
1068 | 1068 | return self::interval2total($interval, self::INTERVAL_MINUTES); |
1069 | 1069 | } |
1070 | 1070 | |
1071 | - /** |
|
1072 | - * Converts an interval to its total amount of seconds. |
|
1073 | - * @param \DateInterval $interval |
|
1074 | - * @return int |
|
1075 | - */ |
|
1071 | + /** |
|
1072 | + * Converts an interval to its total amount of seconds. |
|
1073 | + * @param \DateInterval $interval |
|
1074 | + * @return int |
|
1075 | + */ |
|
1076 | 1076 | public static function interval2seconds(\DateInterval $interval) : int |
1077 | 1077 | { |
1078 | 1078 | return self::interval2total($interval, self::INTERVAL_SECONDS); |
1079 | 1079 | } |
1080 | 1080 | |
1081 | - /** |
|
1082 | - * Calculates the total amount of days / hours / minutes or seconds |
|
1083 | - * of a date interval object (depending in the specified units), and |
|
1084 | - * returns the total amount. |
|
1085 | - * |
|
1086 | - * @param \DateInterval $interval |
|
1087 | - * @param string $unit What total value to calculate. |
|
1088 | - * @return integer |
|
1089 | - * |
|
1090 | - * @see ConvertHelper::INTERVAL_SECONDS |
|
1091 | - * @see ConvertHelper::INTERVAL_MINUTES |
|
1092 | - * @see ConvertHelper::INTERVAL_HOURS |
|
1093 | - * @see ConvertHelper::INTERVAL_DAYS |
|
1094 | - */ |
|
1081 | + /** |
|
1082 | + * Calculates the total amount of days / hours / minutes or seconds |
|
1083 | + * of a date interval object (depending in the specified units), and |
|
1084 | + * returns the total amount. |
|
1085 | + * |
|
1086 | + * @param \DateInterval $interval |
|
1087 | + * @param string $unit What total value to calculate. |
|
1088 | + * @return integer |
|
1089 | + * |
|
1090 | + * @see ConvertHelper::INTERVAL_SECONDS |
|
1091 | + * @see ConvertHelper::INTERVAL_MINUTES |
|
1092 | + * @see ConvertHelper::INTERVAL_HOURS |
|
1093 | + * @see ConvertHelper::INTERVAL_DAYS |
|
1094 | + */ |
|
1095 | 1095 | public static function interval2total(\DateInterval $interval, $unit=self::INTERVAL_SECONDS) : int |
1096 | 1096 | { |
1097 | 1097 | $total = (int)$interval->format('%a'); |
@@ -1131,13 +1131,13 @@ discard block |
||
1131 | 1131 | 'Sunday' |
1132 | 1132 | ); |
1133 | 1133 | |
1134 | - /** |
|
1135 | - * Converts a date to the corresponding day name. |
|
1136 | - * |
|
1137 | - * @param \DateTime $date |
|
1138 | - * @param bool $short |
|
1139 | - * @return string|NULL |
|
1140 | - */ |
|
1134 | + /** |
|
1135 | + * Converts a date to the corresponding day name. |
|
1136 | + * |
|
1137 | + * @param \DateTime $date |
|
1138 | + * @param bool $short |
|
1139 | + * @return string|NULL |
|
1140 | + */ |
|
1141 | 1141 | public static function date2dayName(\DateTime $date, bool $short=false) |
1142 | 1142 | { |
1143 | 1143 | $day = $date->format('l'); |
@@ -1152,21 +1152,21 @@ discard block |
||
1152 | 1152 | return null; |
1153 | 1153 | } |
1154 | 1154 | |
1155 | - /** |
|
1156 | - * Retrieves a list of english day names. |
|
1157 | - * @return string[] |
|
1158 | - */ |
|
1155 | + /** |
|
1156 | + * Retrieves a list of english day names. |
|
1157 | + * @return string[] |
|
1158 | + */ |
|
1159 | 1159 | public static function getDayNamesInvariant() |
1160 | 1160 | { |
1161 | 1161 | return self::$daysInvariant; |
1162 | 1162 | } |
1163 | 1163 | |
1164 | - /** |
|
1165 | - * Retrieves the day names list for the current locale. |
|
1166 | - * |
|
1167 | - * @param bool $short |
|
1168 | - * @return array |
|
1169 | - */ |
|
1164 | + /** |
|
1165 | + * Retrieves the day names list for the current locale. |
|
1166 | + * |
|
1167 | + * @param bool $short |
|
1168 | + * @return array |
|
1169 | + */ |
|
1170 | 1170 | public static function getDayNames(bool $short=false) : array |
1171 | 1171 | { |
1172 | 1172 | if($short) { |
@@ -1226,16 +1226,16 @@ discard block |
||
1226 | 1226 | return $last; |
1227 | 1227 | } |
1228 | 1228 | |
1229 | - /** |
|
1230 | - * Splits a string into an array of all characters it is composed of. |
|
1231 | - * Unicode character safe. |
|
1232 | - * |
|
1233 | - * NOTE: Spaces and newlines (both \r and \n) are also considered single |
|
1234 | - * characters. |
|
1235 | - * |
|
1236 | - * @param string $string |
|
1237 | - * @return array |
|
1238 | - */ |
|
1229 | + /** |
|
1230 | + * Splits a string into an array of all characters it is composed of. |
|
1231 | + * Unicode character safe. |
|
1232 | + * |
|
1233 | + * NOTE: Spaces and newlines (both \r and \n) are also considered single |
|
1234 | + * characters. |
|
1235 | + * |
|
1236 | + * @param string $string |
|
1237 | + * @return array |
|
1238 | + */ |
|
1239 | 1239 | public static function string2array(string $string) : array |
1240 | 1240 | { |
1241 | 1241 | $result = preg_split('//u', $string, null, PREG_SPLIT_NO_EMPTY); |
@@ -1246,12 +1246,12 @@ discard block |
||
1246 | 1246 | return array(); |
1247 | 1247 | } |
1248 | 1248 | |
1249 | - /** |
|
1250 | - * Checks whether the specified string contains HTML code. |
|
1251 | - * |
|
1252 | - * @param string $string |
|
1253 | - * @return boolean |
|
1254 | - */ |
|
1249 | + /** |
|
1250 | + * Checks whether the specified string contains HTML code. |
|
1251 | + * |
|
1252 | + * @param string $string |
|
1253 | + * @return boolean |
|
1254 | + */ |
|
1255 | 1255 | public static function isStringHTML(string $string) : bool |
1256 | 1256 | { |
1257 | 1257 | if(preg_match('%<[a-z/][\s\S]*>%siU', $string)) { |
@@ -1266,17 +1266,17 @@ discard block |
||
1266 | 1266 | return false; |
1267 | 1267 | } |
1268 | 1268 | |
1269 | - /** |
|
1270 | - * UTF8-safe wordwrap method: works like the regular wordwrap |
|
1271 | - * PHP function but compatible with UTF8. Otherwise the lengths |
|
1272 | - * are not calculated correctly. |
|
1273 | - * |
|
1274 | - * @param string $str |
|
1275 | - * @param int $width |
|
1276 | - * @param string $break |
|
1277 | - * @param bool $cut |
|
1278 | - * @return string |
|
1279 | - */ |
|
1269 | + /** |
|
1270 | + * UTF8-safe wordwrap method: works like the regular wordwrap |
|
1271 | + * PHP function but compatible with UTF8. Otherwise the lengths |
|
1272 | + * are not calculated correctly. |
|
1273 | + * |
|
1274 | + * @param string $str |
|
1275 | + * @param int $width |
|
1276 | + * @param string $break |
|
1277 | + * @param bool $cut |
|
1278 | + * @return string |
|
1279 | + */ |
|
1280 | 1280 | public static function wordwrap(string $str, int $width = 75, string $break = "\n", bool $cut = false) : string |
1281 | 1281 | { |
1282 | 1282 | $wrapper = new ConvertHelper_WordWrapper(); |
@@ -1288,27 +1288,27 @@ discard block |
||
1288 | 1288 | ->wrapText($str); |
1289 | 1289 | } |
1290 | 1290 | |
1291 | - /** |
|
1292 | - * Calculates the byte length of a string, taking into |
|
1293 | - * account any unicode characters. |
|
1294 | - * |
|
1295 | - * @param string $string |
|
1296 | - * @return int |
|
1297 | - * @see https://stackoverflow.com/a/9718273/2298192 |
|
1298 | - */ |
|
1291 | + /** |
|
1292 | + * Calculates the byte length of a string, taking into |
|
1293 | + * account any unicode characters. |
|
1294 | + * |
|
1295 | + * @param string $string |
|
1296 | + * @return int |
|
1297 | + * @see https://stackoverflow.com/a/9718273/2298192 |
|
1298 | + */ |
|
1299 | 1299 | public static function string2bytes($string) |
1300 | 1300 | { |
1301 | 1301 | return mb_strlen($string, '8bit'); |
1302 | 1302 | } |
1303 | 1303 | |
1304 | - /** |
|
1305 | - * Creates a short, 8-character long hash for the specified string. |
|
1306 | - * |
|
1307 | - * WARNING: Not cryptographically safe. |
|
1308 | - * |
|
1309 | - * @param string $string |
|
1310 | - * @return string |
|
1311 | - */ |
|
1304 | + /** |
|
1305 | + * Creates a short, 8-character long hash for the specified string. |
|
1306 | + * |
|
1307 | + * WARNING: Not cryptographically safe. |
|
1308 | + * |
|
1309 | + * @param string $string |
|
1310 | + * @return string |
|
1311 | + */ |
|
1312 | 1312 | public static function string2shortHash($string) |
1313 | 1313 | { |
1314 | 1314 | return hash('crc32', $string, false); |
@@ -1334,40 +1334,40 @@ discard block |
||
1334 | 1334 | return ConvertHelper_ThrowableInfo::fromThrowable($e); |
1335 | 1335 | } |
1336 | 1336 | |
1337 | - /** |
|
1338 | - * Parses the specified query string like the native |
|
1339 | - * function <code>parse_str</code>, without the key |
|
1340 | - * naming limitations. |
|
1341 | - * |
|
1342 | - * Using parse_str, dots or spaces in key names are |
|
1343 | - * replaced by underscores. This method keeps all names |
|
1344 | - * intact. |
|
1345 | - * |
|
1346 | - * It still uses the parse_str implementation as it |
|
1347 | - * is tested and tried, but fixes the parameter names |
|
1348 | - * after parsing, as needed. |
|
1349 | - * |
|
1350 | - * @param string $queryString |
|
1351 | - * @return array |
|
1352 | - * @see ConvertHelper_QueryParser |
|
1353 | - */ |
|
1337 | + /** |
|
1338 | + * Parses the specified query string like the native |
|
1339 | + * function <code>parse_str</code>, without the key |
|
1340 | + * naming limitations. |
|
1341 | + * |
|
1342 | + * Using parse_str, dots or spaces in key names are |
|
1343 | + * replaced by underscores. This method keeps all names |
|
1344 | + * intact. |
|
1345 | + * |
|
1346 | + * It still uses the parse_str implementation as it |
|
1347 | + * is tested and tried, but fixes the parameter names |
|
1348 | + * after parsing, as needed. |
|
1349 | + * |
|
1350 | + * @param string $queryString |
|
1351 | + * @return array |
|
1352 | + * @see ConvertHelper_QueryParser |
|
1353 | + */ |
|
1354 | 1354 | public static function parseQueryString(string $queryString) : array |
1355 | 1355 | { |
1356 | 1356 | $parser = new ConvertHelper_QueryParser(); |
1357 | 1357 | return $parser->parse($queryString); |
1358 | 1358 | } |
1359 | 1359 | |
1360 | - /** |
|
1361 | - * Searches for needle in the specified string, and returns a list |
|
1362 | - * of all occurrences, including the matched string. The matched |
|
1363 | - * string is useful when doing a case insensitive search, as it |
|
1364 | - * shows the exact matched case of needle. |
|
1365 | - * |
|
1366 | - * @param string $needle |
|
1367 | - * @param string $haystack |
|
1368 | - * @param bool $caseInsensitive |
|
1369 | - * @return ConvertHelper_StringMatch[] |
|
1370 | - */ |
|
1360 | + /** |
|
1361 | + * Searches for needle in the specified string, and returns a list |
|
1362 | + * of all occurrences, including the matched string. The matched |
|
1363 | + * string is useful when doing a case insensitive search, as it |
|
1364 | + * shows the exact matched case of needle. |
|
1365 | + * |
|
1366 | + * @param string $needle |
|
1367 | + * @param string $haystack |
|
1368 | + * @param bool $caseInsensitive |
|
1369 | + * @return ConvertHelper_StringMatch[] |
|
1370 | + */ |
|
1371 | 1371 | public static function findString(string $needle, string $haystack, bool $caseInsensitive=false) |
1372 | 1372 | { |
1373 | 1373 | if($needle === '') { |
@@ -1393,14 +1393,14 @@ discard block |
||
1393 | 1393 | return $positions; |
1394 | 1394 | } |
1395 | 1395 | |
1396 | - /** |
|
1397 | - * Like explode, but trims all entries, and removes |
|
1398 | - * empty entries from the resulting array. |
|
1399 | - * |
|
1400 | - * @param string $delimiter |
|
1401 | - * @param string $string |
|
1402 | - * @return string[] |
|
1403 | - */ |
|
1396 | + /** |
|
1397 | + * Like explode, but trims all entries, and removes |
|
1398 | + * empty entries from the resulting array. |
|
1399 | + * |
|
1400 | + * @param string $delimiter |
|
1401 | + * @param string $string |
|
1402 | + * @return string[] |
|
1403 | + */ |
|
1404 | 1404 | public static function explodeTrim(string $delimiter, string $string) : array |
1405 | 1405 | { |
1406 | 1406 | if(empty($string) || empty($delimiter)) { |
@@ -1422,12 +1422,12 @@ discard block |
||
1422 | 1422 | |
1423 | 1423 | protected static $eolChars; |
1424 | 1424 | |
1425 | - /** |
|
1426 | - * Detects the most used end-of-line character in the subject string. |
|
1427 | - * |
|
1428 | - * @param string $str The string to check. |
|
1429 | - * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected. |
|
1430 | - */ |
|
1425 | + /** |
|
1426 | + * Detects the most used end-of-line character in the subject string. |
|
1427 | + * |
|
1428 | + * @param string $str The string to check. |
|
1429 | + * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected. |
|
1430 | + */ |
|
1431 | 1431 | public static function detectEOLCharacter(string $subjectString) : ?ConvertHelper_EOL |
1432 | 1432 | { |
1433 | 1433 | if(empty($subjectString)) { |
@@ -1439,27 +1439,27 @@ discard block |
||
1439 | 1439 | $cr = chr((int)hexdec('0d')); |
1440 | 1440 | $lf = chr((int)hexdec('0a')); |
1441 | 1441 | |
1442 | - self::$eolChars = array( |
|
1443 | - array( |
|
1444 | - 'char' => $cr.$lf, |
|
1445 | - 'type' => ConvertHelper_EOL::TYPE_CRLF, |
|
1446 | - 'description' => t('Carriage return followed by a line feed'), |
|
1447 | - ), |
|
1448 | - array( |
|
1449 | - 'char' => $lf.$cr, |
|
1450 | - 'type' => ConvertHelper_EOL::TYPE_LFCR, |
|
1451 | - 'description' => t('Line feed followed by a carriage return'), |
|
1452 | - ), |
|
1453 | - array( |
|
1454 | - 'char' => $lf, |
|
1455 | - 'type' => ConvertHelper_EOL::TYPE_LF, |
|
1456 | - 'description' => t('Line feed'), |
|
1457 | - ), |
|
1458 | - array( |
|
1459 | - 'char' => $cr, |
|
1460 | - 'type' => ConvertHelper_EOL::TYPE_CR, |
|
1461 | - 'description' => t('Carriage Return'), |
|
1462 | - ), |
|
1442 | + self::$eolChars = array( |
|
1443 | + array( |
|
1444 | + 'char' => $cr.$lf, |
|
1445 | + 'type' => ConvertHelper_EOL::TYPE_CRLF, |
|
1446 | + 'description' => t('Carriage return followed by a line feed'), |
|
1447 | + ), |
|
1448 | + array( |
|
1449 | + 'char' => $lf.$cr, |
|
1450 | + 'type' => ConvertHelper_EOL::TYPE_LFCR, |
|
1451 | + 'description' => t('Line feed followed by a carriage return'), |
|
1452 | + ), |
|
1453 | + array( |
|
1454 | + 'char' => $lf, |
|
1455 | + 'type' => ConvertHelper_EOL::TYPE_LF, |
|
1456 | + 'description' => t('Line feed'), |
|
1457 | + ), |
|
1458 | + array( |
|
1459 | + 'char' => $cr, |
|
1460 | + 'type' => ConvertHelper_EOL::TYPE_CR, |
|
1461 | + 'description' => t('Carriage Return'), |
|
1462 | + ), |
|
1463 | 1463 | ); |
1464 | 1464 | } |
1465 | 1465 | |
@@ -1487,13 +1487,13 @@ discard block |
||
1487 | 1487 | ); |
1488 | 1488 | } |
1489 | 1489 | |
1490 | - /** |
|
1491 | - * Removes the specified keys from the target array, |
|
1492 | - * if they exist. |
|
1493 | - * |
|
1494 | - * @param array $array |
|
1495 | - * @param array $keys |
|
1496 | - */ |
|
1490 | + /** |
|
1491 | + * Removes the specified keys from the target array, |
|
1492 | + * if they exist. |
|
1493 | + * |
|
1494 | + * @param array $array |
|
1495 | + * @param array $keys |
|
1496 | + */ |
|
1497 | 1497 | public static function arrayRemoveKeys(array &$array, array $keys) : void |
1498 | 1498 | { |
1499 | 1499 | foreach($keys as $key) |
@@ -1504,13 +1504,13 @@ discard block |
||
1504 | 1504 | } |
1505 | 1505 | } |
1506 | 1506 | |
1507 | - /** |
|
1508 | - * Checks if the specified variable is an integer or a string containing an integer. |
|
1509 | - * Accepts both positive and negative integers. |
|
1510 | - * |
|
1511 | - * @param mixed $value |
|
1512 | - * @return bool |
|
1513 | - */ |
|
1507 | + /** |
|
1508 | + * Checks if the specified variable is an integer or a string containing an integer. |
|
1509 | + * Accepts both positive and negative integers. |
|
1510 | + * |
|
1511 | + * @param mixed $value |
|
1512 | + * @return bool |
|
1513 | + */ |
|
1514 | 1514 | public static function isInteger($value) : bool |
1515 | 1515 | { |
1516 | 1516 | if(is_int($value)) { |
@@ -1530,15 +1530,15 @@ discard block |
||
1530 | 1530 | return false; |
1531 | 1531 | } |
1532 | 1532 | |
1533 | - /** |
|
1534 | - * Converts an amount of seconds to a DateInterval object. |
|
1535 | - * |
|
1536 | - * @param int $seconds |
|
1537 | - * @return \DateInterval |
|
1538 | - * @throws ConvertHelper_Exception If the date interval cannot be created. |
|
1539 | - * |
|
1540 | - * @see ConvertHelper::ERROR_CANNOT_GET_DATE_DIFF |
|
1541 | - */ |
|
1533 | + /** |
|
1534 | + * Converts an amount of seconds to a DateInterval object. |
|
1535 | + * |
|
1536 | + * @param int $seconds |
|
1537 | + * @return \DateInterval |
|
1538 | + * @throws ConvertHelper_Exception If the date interval cannot be created. |
|
1539 | + * |
|
1540 | + * @see ConvertHelper::ERROR_CANNOT_GET_DATE_DIFF |
|
1541 | + */ |
|
1542 | 1542 | public static function seconds2interval(int $seconds) : \DateInterval |
1543 | 1543 | { |
1544 | 1544 | return ConvertHelper_DateInterval::fromSeconds($seconds)->getInterval(); |
@@ -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); |
@@ -249,22 +249,22 @@ discard block |
||
249 | 249 | $terabyte = $gigabyte * 1024; |
250 | 250 | |
251 | 251 | if (($bytes >= 0) && ($bytes < $kilobyte)) { |
252 | - return $bytes . ' ' . t('B'); |
|
252 | + return $bytes.' '.t('B'); |
|
253 | 253 | |
254 | 254 | } elseif (($bytes >= $kilobyte) && ($bytes < $megabyte)) { |
255 | - return round($bytes / $kilobyte, $precision) . ' ' . t('Kb'); |
|
255 | + return round($bytes / $kilobyte, $precision).' '.t('Kb'); |
|
256 | 256 | |
257 | 257 | } elseif (($bytes >= $megabyte) && ($bytes < $gigabyte)) { |
258 | - return round($bytes / $megabyte, $precision) . ' ' . t('Mb'); |
|
258 | + return round($bytes / $megabyte, $precision).' '.t('Mb'); |
|
259 | 259 | |
260 | 260 | } elseif (($bytes >= $gigabyte) && ($bytes < $terabyte)) { |
261 | - return round($bytes / $gigabyte, $precision) . ' ' . t('Gb'); |
|
261 | + return round($bytes / $gigabyte, $precision).' '.t('Gb'); |
|
262 | 262 | |
263 | 263 | } elseif ($bytes >= $terabyte) { |
264 | - return round($bytes / $gigabyte, $precision) . ' ' . t('Tb'); |
|
264 | + return round($bytes / $gigabyte, $precision).' '.t('Tb'); |
|
265 | 265 | } |
266 | 266 | |
267 | - return $bytes . ' ' . t('B'); |
|
267 | + return $bytes.' '.t('B'); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
@@ -284,34 +284,34 @@ discard block |
||
284 | 284 | return $text; |
285 | 285 | } |
286 | 286 | |
287 | - $text = trim(mb_substr($text, 0, $targetLength)) . $append; |
|
287 | + $text = trim(mb_substr($text, 0, $targetLength)).$append; |
|
288 | 288 | |
289 | 289 | return $text; |
290 | 290 | } |
291 | 291 | |
292 | - public static function var_dump($var, $html=true) |
|
292 | + public static function var_dump($var, $html = true) |
|
293 | 293 | { |
294 | 294 | $info = parseVariable($var); |
295 | 295 | |
296 | - if($html) { |
|
296 | + if ($html) { |
|
297 | 297 | return $info->toHTML(); |
298 | 298 | } |
299 | 299 | |
300 | 300 | return $info->toString(); |
301 | 301 | } |
302 | 302 | |
303 | - public static function print_r($var, $return=false, $html=true) |
|
303 | + public static function print_r($var, $return = false, $html = true) |
|
304 | 304 | { |
305 | 305 | $result = self::var_dump($var, $html); |
306 | 306 | |
307 | - if($html) { |
|
307 | + if ($html) { |
|
308 | 308 | $result = |
309 | 309 | '<pre style="background:#fff;color:#333;padding:16px;border:solid 1px #bbb;border-radius:4px">'. |
310 | 310 | $result. |
311 | 311 | '</pre>'; |
312 | 312 | } |
313 | 313 | |
314 | - if($return) { |
|
314 | + if ($return) { |
|
315 | 315 | return $result; |
316 | 316 | } |
317 | 317 | |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | |
332 | 332 | public static function string2bool($string) |
333 | 333 | { |
334 | - if($string === '' || $string === null) { |
|
334 | + if ($string === '' || $string === null) { |
|
335 | 335 | return false; |
336 | 336 | } |
337 | 337 | |
@@ -386,10 +386,10 @@ discard block |
||
386 | 386 | public static function date2listLabel(\DateTime $date, $includeTime = false, $shortMonth = false) |
387 | 387 | { |
388 | 388 | $today = new \DateTime(); |
389 | - if($date->format('d.m.Y') == $today->format('d.m.Y')) { |
|
389 | + if ($date->format('d.m.Y') == $today->format('d.m.Y')) { |
|
390 | 390 | $label = t('Today'); |
391 | 391 | } else { |
392 | - $label = $date->format('d') . '. ' . self::month2string((int)$date->format('m'), $shortMonth) . ' '; |
|
392 | + $label = $date->format('d').'. '.self::month2string((int)$date->format('m'), $shortMonth).' '; |
|
393 | 393 | if ($date->format('Y') != date('Y')) { |
394 | 394 | $label .= $date->format('Y'); |
395 | 395 | } |
@@ -480,28 +480,28 @@ discard block |
||
480 | 480 | $hexAlphabet = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); |
481 | 481 | |
482 | 482 | $stack = array(); |
483 | - foreach(self::$controlChars as $char) |
|
483 | + foreach (self::$controlChars as $char) |
|
484 | 484 | { |
485 | 485 | $tokens = explode('-', $char); |
486 | 486 | $start = $tokens[0]; |
487 | 487 | $end = $tokens[1]; |
488 | 488 | $prefix = substr($start, 0, 3); |
489 | 489 | $range = array(); |
490 | - foreach($hexAlphabet as $number) { |
|
490 | + foreach ($hexAlphabet as $number) { |
|
491 | 491 | $range[] = $prefix.$number; |
492 | 492 | } |
493 | 493 | |
494 | 494 | $use = false; |
495 | - foreach($range as $number) { |
|
496 | - if($number == $start) { |
|
495 | + foreach ($range as $number) { |
|
496 | + if ($number == $start) { |
|
497 | 497 | $use = true; |
498 | 498 | } |
499 | 499 | |
500 | - if($use) { |
|
500 | + if ($use) { |
|
501 | 501 | $stack[] = $number; |
502 | 502 | } |
503 | 503 | |
504 | - if($number == $end) { |
|
504 | + if ($number == $end) { |
|
505 | 505 | break; |
506 | 506 | } |
507 | 507 | } |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | $chars = self::getControlCharactersAsHex(); |
523 | 523 | |
524 | 524 | $result = array(); |
525 | - foreach($chars as $char) { |
|
525 | + foreach ($chars as $char) { |
|
526 | 526 | $result[] = hex2bin($char); |
527 | 527 | } |
528 | 528 | |
@@ -540,14 +540,14 @@ discard block |
||
540 | 540 | $chars = self::getControlCharactersAsHex(); |
541 | 541 | |
542 | 542 | $result = array(); |
543 | - foreach($chars as $char) { |
|
543 | + foreach ($chars as $char) { |
|
544 | 544 | $result[] = '\u'.strtolower($char); |
545 | 545 | } |
546 | 546 | |
547 | 547 | return $result; |
548 | 548 | } |
549 | 549 | |
550 | - protected static $controlChars = array( |
|
550 | + protected static $controlChars = array( |
|
551 | 551 | '0000-0008', // control chars |
552 | 552 | '000E-000F', // control chars |
553 | 553 | '0010-001F', // control chars |
@@ -569,19 +569,19 @@ discard block |
||
569 | 569 | */ |
570 | 570 | public static function stripControlCharacters(string $string) : string |
571 | 571 | { |
572 | - if(empty($string)) { |
|
572 | + if (empty($string)) { |
|
573 | 573 | return $string; |
574 | 574 | } |
575 | 575 | |
576 | 576 | // create the regex from the unicode characters list |
577 | - if(!isset(self::$controlCharsRegex)) |
|
577 | + if (!isset(self::$controlCharsRegex)) |
|
578 | 578 | { |
579 | 579 | $chars = self::getControlCharactersAsHex(); |
580 | 580 | |
581 | 581 | // we use the notation \x{0000} to specify the unicode character key |
582 | 582 | // in the regular expression. |
583 | 583 | $stack = array(); |
584 | - foreach($chars as $char) { |
|
584 | + foreach ($chars as $char) { |
|
585 | 585 | $stack[] = '\x{'.$char.'}'; |
586 | 586 | } |
587 | 587 | |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | $ordInt = ord($octet); |
616 | 616 | // Convert from int (base 10) to hex (base 16), for PHP \x syntax |
617 | 617 | $ordHex = base_convert($ordInt, 10, 16); |
618 | - $output .= '\x' . $ordHex; |
|
618 | + $output .= '\x'.$ordHex; |
|
619 | 619 | } |
620 | 620 | return $output; |
621 | 621 | } |
@@ -647,19 +647,19 @@ discard block |
||
647 | 647 | |
648 | 648 | protected static function convertScalarForComparison($scalar) |
649 | 649 | { |
650 | - if($scalar === '' || is_null($scalar)) { |
|
650 | + if ($scalar === '' || is_null($scalar)) { |
|
651 | 651 | return null; |
652 | 652 | } |
653 | 653 | |
654 | - if(is_bool($scalar)) { |
|
654 | + if (is_bool($scalar)) { |
|
655 | 655 | return self::bool2string($scalar); |
656 | 656 | } |
657 | 657 | |
658 | - if(is_array($scalar)) { |
|
658 | + if (is_array($scalar)) { |
|
659 | 659 | $scalar = md5(serialize($scalar)); |
660 | 660 | } |
661 | 661 | |
662 | - if($scalar !== null && !is_scalar($scalar)) { |
|
662 | + if ($scalar !== null && !is_scalar($scalar)) { |
|
663 | 663 | throw new ConvertHelper_Exception( |
664 | 664 | 'Not a scalar value in comparison', |
665 | 665 | null, |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | public static function bool2string($boolean, bool $yesno = false) : string |
709 | 709 | { |
710 | 710 | // allow 'yes', 'true', 'no', 'false' string notations as well |
711 | - if(!is_bool($boolean)) { |
|
711 | + if (!is_bool($boolean)) { |
|
712 | 712 | $boolean = self::string2bool($boolean); |
713 | 713 | } |
714 | 714 | |
@@ -749,15 +749,15 @@ discard block |
||
749 | 749 | public static function array2attributeString($array) |
750 | 750 | { |
751 | 751 | $tokens = array(); |
752 | - foreach($array as $attr => $value) { |
|
753 | - if($value == '' || $value == null) { |
|
752 | + foreach ($array as $attr => $value) { |
|
753 | + if ($value == '' || $value == null) { |
|
754 | 754 | continue; |
755 | 755 | } |
756 | 756 | |
757 | 757 | $tokens[] = $attr.'="'.$value.'"'; |
758 | 758 | } |
759 | 759 | |
760 | - if(empty($tokens)) { |
|
760 | + if (empty($tokens)) { |
|
761 | 761 | return ''; |
762 | 762 | } |
763 | 763 | |
@@ -772,10 +772,10 @@ discard block |
||
772 | 772 | * @param string $string |
773 | 773 | * @return string |
774 | 774 | */ |
775 | - public static function string2attributeJS($string, $quoted=true) |
|
775 | + public static function string2attributeJS($string, $quoted = true) |
|
776 | 776 | { |
777 | 777 | $converted = addslashes(htmlspecialchars(strip_tags($string), ENT_QUOTES, 'UTF-8')); |
778 | - if($quoted) { |
|
778 | + if ($quoted) { |
|
779 | 779 | $converted = "'".$converted."'"; |
780 | 780 | } |
781 | 781 | |
@@ -793,11 +793,11 @@ discard block |
||
793 | 793 | */ |
794 | 794 | public static function isBoolean($value) : bool |
795 | 795 | { |
796 | - if(is_bool($value)) { |
|
796 | + if (is_bool($value)) { |
|
797 | 797 | return true; |
798 | 798 | } |
799 | 799 | |
800 | - if(!is_scalar($value)) { |
|
800 | + if (!is_scalar($value)) { |
|
801 | 801 | return false; |
802 | 802 | } |
803 | 803 | |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | public static function array2styleString(array $subject) : string |
814 | 814 | { |
815 | 815 | $tokens = array(); |
816 | - foreach($subject as $name => $value) { |
|
816 | + foreach ($subject as $name => $value) { |
|
817 | 817 | $tokens[] = $name.':'.$value; |
818 | 818 | } |
819 | 819 | |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | * |
872 | 872 | * @see JSHelper::buildRegexStatement() |
873 | 873 | */ |
874 | - public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT) |
|
874 | + public static function regex2js(string $regex, string $statementType = JSHelper::JS_REGEX_OBJECT) |
|
875 | 875 | { |
876 | 876 | return JSHelper::buildRegexStatement($regex, $statementType); |
877 | 877 | } |
@@ -888,11 +888,11 @@ discard block |
||
888 | 888 | * @throws ConvertHelper_Exception |
889 | 889 | * @return string |
890 | 890 | */ |
891 | - public static function var2json($variable, int $options=0, int $depth=512) : string |
|
891 | + public static function var2json($variable, int $options = 0, int $depth = 512) : string |
|
892 | 892 | { |
893 | 893 | $result = json_encode($variable, $options, $depth); |
894 | 894 | |
895 | - if($result !== false) { |
|
895 | + if ($result !== false) { |
|
896 | 896 | return $result; |
897 | 897 | } |
898 | 898 | |
@@ -917,10 +917,10 @@ discard block |
||
917 | 917 | public static function stripUTFBom($string) |
918 | 918 | { |
919 | 919 | $boms = FileHelper::getUTFBOMs(); |
920 | - foreach($boms as $bomChars) { |
|
920 | + foreach ($boms as $bomChars) { |
|
921 | 921 | $length = mb_strlen($bomChars); |
922 | 922 | $text = mb_substr($string, 0, $length); |
923 | - if($text==$bomChars) { |
|
923 | + if ($text == $bomChars) { |
|
924 | 924 | return mb_substr($string, $length); |
925 | 925 | } |
926 | 926 | } |
@@ -937,7 +937,7 @@ discard block |
||
937 | 937 | */ |
938 | 938 | public static function string2utf8($string) |
939 | 939 | { |
940 | - if(!self::isStringASCII($string)) { |
|
940 | + if (!self::isStringASCII($string)) { |
|
941 | 941 | return \ForceUTF8\Encoding::toUTF8($string); |
942 | 942 | } |
943 | 943 | |
@@ -955,11 +955,11 @@ discard block |
||
955 | 955 | */ |
956 | 956 | public static function isStringASCII($string) : bool |
957 | 957 | { |
958 | - if($string === '' || $string === NULL) { |
|
958 | + if ($string === '' || $string === NULL) { |
|
959 | 959 | return true; |
960 | 960 | } |
961 | 961 | |
962 | - if(!is_string($string)) { |
|
962 | + if (!is_string($string)) { |
|
963 | 963 | return false; |
964 | 964 | } |
965 | 965 | |
@@ -993,7 +993,7 @@ discard block |
||
993 | 993 | * @param array $options |
994 | 994 | * @return float |
995 | 995 | */ |
996 | - public static function matchString($source, $target, $options=array()) |
|
996 | + public static function matchString($source, $target, $options = array()) |
|
997 | 997 | { |
998 | 998 | $defaults = array( |
999 | 999 | 'maxLevenshtein' => 10, |
@@ -1003,12 +1003,12 @@ discard block |
||
1003 | 1003 | $options = array_merge($defaults, $options); |
1004 | 1004 | |
1005 | 1005 | // avoid doing this via levenshtein |
1006 | - if($source == $target) { |
|
1006 | + if ($source == $target) { |
|
1007 | 1007 | return 100; |
1008 | 1008 | } |
1009 | 1009 | |
1010 | 1010 | $diff = levenshtein($source, $target); |
1011 | - if($diff > $options['maxLevenshtein']) { |
|
1011 | + if ($diff > $options['maxLevenshtein']) { |
|
1012 | 1012 | return 0; |
1013 | 1013 | } |
1014 | 1014 | |
@@ -1092,24 +1092,24 @@ discard block |
||
1092 | 1092 | * @see ConvertHelper::INTERVAL_HOURS |
1093 | 1093 | * @see ConvertHelper::INTERVAL_DAYS |
1094 | 1094 | */ |
1095 | - public static function interval2total(\DateInterval $interval, $unit=self::INTERVAL_SECONDS) : int |
|
1095 | + public static function interval2total(\DateInterval $interval, $unit = self::INTERVAL_SECONDS) : int |
|
1096 | 1096 | { |
1097 | 1097 | $total = (int)$interval->format('%a'); |
1098 | 1098 | if ($unit == self::INTERVAL_DAYS) { |
1099 | 1099 | return $total; |
1100 | 1100 | } |
1101 | 1101 | |
1102 | - $total = ($total * 24) + ((int)$interval->h ); |
|
1102 | + $total = ($total * 24) + ((int)$interval->h); |
|
1103 | 1103 | if ($unit == self::INTERVAL_HOURS) { |
1104 | 1104 | return $total; |
1105 | 1105 | } |
1106 | 1106 | |
1107 | - $total = ($total * 60) + ((int)$interval->i ); |
|
1107 | + $total = ($total * 60) + ((int)$interval->i); |
|
1108 | 1108 | if ($unit == self::INTERVAL_MINUTES) { |
1109 | 1109 | return $total; |
1110 | 1110 | } |
1111 | 1111 | |
1112 | - $total = ($total * 60) + ((int)$interval->s ); |
|
1112 | + $total = ($total * 60) + ((int)$interval->s); |
|
1113 | 1113 | if ($unit == self::INTERVAL_SECONDS) { |
1114 | 1114 | return $total; |
1115 | 1115 | } |
@@ -1138,13 +1138,13 @@ discard block |
||
1138 | 1138 | * @param bool $short |
1139 | 1139 | * @return string|NULL |
1140 | 1140 | */ |
1141 | - public static function date2dayName(\DateTime $date, bool $short=false) |
|
1141 | + public static function date2dayName(\DateTime $date, bool $short = false) |
|
1142 | 1142 | { |
1143 | 1143 | $day = $date->format('l'); |
1144 | 1144 | $invariant = self::getDayNamesInvariant(); |
1145 | 1145 | |
1146 | 1146 | $idx = array_search($day, $invariant); |
1147 | - if($idx !== false) { |
|
1147 | + if ($idx !== false) { |
|
1148 | 1148 | $localized = self::getDayNames($short); |
1149 | 1149 | return $localized[$idx]; |
1150 | 1150 | } |
@@ -1167,10 +1167,10 @@ discard block |
||
1167 | 1167 | * @param bool $short |
1168 | 1168 | * @return array |
1169 | 1169 | */ |
1170 | - public static function getDayNames(bool $short=false) : array |
|
1170 | + public static function getDayNames(bool $short = false) : array |
|
1171 | 1171 | { |
1172 | - if($short) { |
|
1173 | - if(!isset(self::$daysShort)) { |
|
1172 | + if ($short) { |
|
1173 | + if (!isset(self::$daysShort)) { |
|
1174 | 1174 | self::$daysShort = array( |
1175 | 1175 | t('Mon'), |
1176 | 1176 | t('Tue'), |
@@ -1185,7 +1185,7 @@ discard block |
||
1185 | 1185 | return self::$daysShort; |
1186 | 1186 | } |
1187 | 1187 | |
1188 | - if(!isset(self::$days)) { |
|
1188 | + if (!isset(self::$days)) { |
|
1189 | 1189 | self::$days = array( |
1190 | 1190 | t('Monday'), |
1191 | 1191 | t('Tuesday'), |
@@ -1210,17 +1210,17 @@ discard block |
||
1210 | 1210 | */ |
1211 | 1211 | public static function implodeWithAnd(array $list, $sep = ', ', $conjunction = null) |
1212 | 1212 | { |
1213 | - if(empty($list)) { |
|
1213 | + if (empty($list)) { |
|
1214 | 1214 | return ''; |
1215 | 1215 | } |
1216 | 1216 | |
1217 | - if(empty($conjunction)) { |
|
1217 | + if (empty($conjunction)) { |
|
1218 | 1218 | $conjunction = t('and'); |
1219 | 1219 | } |
1220 | 1220 | |
1221 | 1221 | $last = array_pop($list); |
1222 | - if($list) { |
|
1223 | - return implode($sep, $list) . $conjunction . ' ' . $last; |
|
1222 | + if ($list) { |
|
1223 | + return implode($sep, $list).$conjunction.' '.$last; |
|
1224 | 1224 | } |
1225 | 1225 | |
1226 | 1226 | return $last; |
@@ -1239,7 +1239,7 @@ discard block |
||
1239 | 1239 | public static function string2array(string $string) : array |
1240 | 1240 | { |
1241 | 1241 | $result = preg_split('//u', $string, null, PREG_SPLIT_NO_EMPTY); |
1242 | - if($result !== false) { |
|
1242 | + if ($result !== false) { |
|
1243 | 1243 | return $result; |
1244 | 1244 | } |
1245 | 1245 | |
@@ -1254,12 +1254,12 @@ discard block |
||
1254 | 1254 | */ |
1255 | 1255 | public static function isStringHTML(string $string) : bool |
1256 | 1256 | { |
1257 | - if(preg_match('%<[a-z/][\s\S]*>%siU', $string)) { |
|
1257 | + if (preg_match('%<[a-z/][\s\S]*>%siU', $string)) { |
|
1258 | 1258 | return true; |
1259 | 1259 | } |
1260 | 1260 | |
1261 | 1261 | $decoded = html_entity_decode($string); |
1262 | - if($decoded !== $string) { |
|
1262 | + if ($decoded !== $string) { |
|
1263 | 1263 | return true; |
1264 | 1264 | } |
1265 | 1265 | |
@@ -1368,14 +1368,14 @@ discard block |
||
1368 | 1368 | * @param bool $caseInsensitive |
1369 | 1369 | * @return ConvertHelper_StringMatch[] |
1370 | 1370 | */ |
1371 | - public static function findString(string $needle, string $haystack, bool $caseInsensitive=false) |
|
1371 | + public static function findString(string $needle, string $haystack, bool $caseInsensitive = false) |
|
1372 | 1372 | { |
1373 | - if($needle === '') { |
|
1373 | + if ($needle === '') { |
|
1374 | 1374 | return array(); |
1375 | 1375 | } |
1376 | 1376 | |
1377 | 1377 | $function = 'mb_strpos'; |
1378 | - if($caseInsensitive) { |
|
1378 | + if ($caseInsensitive) { |
|
1379 | 1379 | $function = 'mb_stripos'; |
1380 | 1380 | } |
1381 | 1381 | |
@@ -1383,7 +1383,7 @@ discard block |
||
1383 | 1383 | $positions = array(); |
1384 | 1384 | $length = mb_strlen($needle); |
1385 | 1385 | |
1386 | - while( ($pos = $function($haystack, $needle, $pos)) !== false) |
|
1386 | + while (($pos = $function($haystack, $needle, $pos)) !== false) |
|
1387 | 1387 | { |
1388 | 1388 | $match = mb_substr($haystack, $pos, $length); |
1389 | 1389 | $positions[] = new ConvertHelper_StringMatch($pos, $match); |
@@ -1403,7 +1403,7 @@ discard block |
||
1403 | 1403 | */ |
1404 | 1404 | public static function explodeTrim(string $delimiter, string $string) : array |
1405 | 1405 | { |
1406 | - if(empty($string) || empty($delimiter)) { |
|
1406 | + if (empty($string) || empty($delimiter)) { |
|
1407 | 1407 | return array(); |
1408 | 1408 | } |
1409 | 1409 | |
@@ -1411,8 +1411,8 @@ discard block |
||
1411 | 1411 | $tokens = array_map('trim', $tokens); |
1412 | 1412 | |
1413 | 1413 | $keep = array(); |
1414 | - foreach($tokens as $token) { |
|
1415 | - if($token !== '') { |
|
1414 | + foreach ($tokens as $token) { |
|
1415 | + if ($token !== '') { |
|
1416 | 1416 | $keep[] = $token; |
1417 | 1417 | } |
1418 | 1418 | } |
@@ -1430,11 +1430,11 @@ discard block |
||
1430 | 1430 | */ |
1431 | 1431 | public static function detectEOLCharacter(string $subjectString) : ?ConvertHelper_EOL |
1432 | 1432 | { |
1433 | - if(empty($subjectString)) { |
|
1433 | + if (empty($subjectString)) { |
|
1434 | 1434 | return null; |
1435 | 1435 | } |
1436 | 1436 | |
1437 | - if(!isset(self::$eolChars)) |
|
1437 | + if (!isset(self::$eolChars)) |
|
1438 | 1438 | { |
1439 | 1439 | $cr = chr((int)hexdec('0d')); |
1440 | 1440 | $lf = chr((int)hexdec('0a')); |
@@ -1465,18 +1465,18 @@ discard block |
||
1465 | 1465 | |
1466 | 1466 | $max = 0; |
1467 | 1467 | $results = array(); |
1468 | - foreach(self::$eolChars as $def) |
|
1468 | + foreach (self::$eolChars as $def) |
|
1469 | 1469 | { |
1470 | 1470 | $amount = substr_count($subjectString, $def['char']); |
1471 | 1471 | |
1472 | - if($amount > $max) |
|
1472 | + if ($amount > $max) |
|
1473 | 1473 | { |
1474 | 1474 | $max = $amount; |
1475 | 1475 | $results[] = $def; |
1476 | 1476 | } |
1477 | 1477 | } |
1478 | 1478 | |
1479 | - if(empty($results)) { |
|
1479 | + if (empty($results)) { |
|
1480 | 1480 | return null; |
1481 | 1481 | } |
1482 | 1482 | |
@@ -1496,9 +1496,9 @@ discard block |
||
1496 | 1496 | */ |
1497 | 1497 | public static function arrayRemoveKeys(array &$array, array $keys) : void |
1498 | 1498 | { |
1499 | - foreach($keys as $key) |
|
1499 | + foreach ($keys as $key) |
|
1500 | 1500 | { |
1501 | - if(array_key_exists($key, $array)) { |
|
1501 | + if (array_key_exists($key, $array)) { |
|
1502 | 1502 | unset($array[$key]); |
1503 | 1503 | } |
1504 | 1504 | } |
@@ -1513,17 +1513,17 @@ discard block |
||
1513 | 1513 | */ |
1514 | 1514 | public static function isInteger($value) : bool |
1515 | 1515 | { |
1516 | - if(is_int($value)) { |
|
1516 | + if (is_int($value)) { |
|
1517 | 1517 | return true; |
1518 | 1518 | } |
1519 | 1519 | |
1520 | 1520 | // booleans get converted to numbers, so they would |
1521 | 1521 | // actually match the regex. |
1522 | - if(is_bool($value)) { |
|
1522 | + if (is_bool($value)) { |
|
1523 | 1523 | return false; |
1524 | 1524 | } |
1525 | 1525 | |
1526 | - if(is_string($value) && $value !== '') { |
|
1526 | + if (is_string($value) && $value !== '') { |
|
1527 | 1527 | return preg_match('/\A-?\d+\z/', $value) === 1; |
1528 | 1528 | } |
1529 | 1529 |
@@ -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; |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | const TOKEN_MONTHS = 'm'; |
38 | 38 | const TOKEN_YEARS = 'y'; |
39 | 39 | |
40 | - /** |
|
41 | - * @var \DateInterval |
|
42 | - */ |
|
40 | + /** |
|
41 | + * @var \DateInterval |
|
42 | + */ |
|
43 | 43 | protected $interval; |
44 | 44 | |
45 | - /** |
|
46 | - * @var int |
|
47 | - */ |
|
45 | + /** |
|
46 | + * @var int |
|
47 | + */ |
|
48 | 48 | protected $seconds; |
49 | 49 | |
50 | 50 | protected function __construct(int $seconds) |
@@ -69,33 +69,33 @@ discard block |
||
69 | 69 | $this->interval = $interval; |
70 | 70 | } |
71 | 71 | |
72 | - /** |
|
73 | - * Creates the interval from a specific amount of seconds. |
|
74 | - * |
|
75 | - * @param int $seconds |
|
76 | - * @return \AppUtils\ConvertHelper_DateInterval |
|
77 | - */ |
|
72 | + /** |
|
73 | + * Creates the interval from a specific amount of seconds. |
|
74 | + * |
|
75 | + * @param int $seconds |
|
76 | + * @return \AppUtils\ConvertHelper_DateInterval |
|
77 | + */ |
|
78 | 78 | public static function fromSeconds(int $seconds) |
79 | 79 | { |
80 | 80 | return new ConvertHelper_DateInterval($seconds); |
81 | 81 | } |
82 | 82 | |
83 | - /** |
|
84 | - * Creates the interval from an existing regular interval instance. |
|
85 | - * |
|
86 | - * @param \DateInterval $interval |
|
87 | - * @return \AppUtils\ConvertHelper_DateInterval |
|
88 | - */ |
|
83 | + /** |
|
84 | + * Creates the interval from an existing regular interval instance. |
|
85 | + * |
|
86 | + * @param \DateInterval $interval |
|
87 | + * @return \AppUtils\ConvertHelper_DateInterval |
|
88 | + */ |
|
89 | 89 | public static function fromInterval(\DateInterval $interval) |
90 | 90 | { |
91 | 91 | return self::fromSeconds(ConvertHelper::interval2seconds($interval)); |
92 | 92 | } |
93 | 93 | |
94 | - /** |
|
95 | - * Retrieves the PHP native date interval. |
|
96 | - * |
|
97 | - * @return \DateInterval |
|
98 | - */ |
|
94 | + /** |
|
95 | + * Retrieves the PHP native date interval. |
|
96 | + * |
|
97 | + * @return \DateInterval |
|
98 | + */ |
|
99 | 99 | public function getInterval() : \DateInterval |
100 | 100 | { |
101 | 101 | return $this->interval; |
@@ -131,31 +131,31 @@ discard block |
||
131 | 131 | return $this->getToken(self::TOKEN_YEARS); |
132 | 132 | } |
133 | 133 | |
134 | - /** |
|
135 | - * Retrieves a specific time token, e.g. "h" (for hours). |
|
136 | - * Using the constants to specifiy the tokens is recommended. |
|
137 | - * |
|
138 | - * @param string $token |
|
139 | - * @return int |
|
140 | - * |
|
141 | - * @see ConvertHelper_DateInterval::TOKEN_SECONDS |
|
142 | - * @see ConvertHelper_DateInterval::TOKEN_MINUTES |
|
143 | - * @see ConvertHelper_DateInterval::TOKEN_HOURS |
|
144 | - * @see ConvertHelper_DateInterval::TOKEN_DAYS |
|
145 | - * @see ConvertHelper_DateInterval::TOKEN_MONTHS |
|
146 | - * @see ConvertHelper_DateInterval::TOKEN_YEARS |
|
147 | - */ |
|
134 | + /** |
|
135 | + * Retrieves a specific time token, e.g. "h" (for hours). |
|
136 | + * Using the constants to specifiy the tokens is recommended. |
|
137 | + * |
|
138 | + * @param string $token |
|
139 | + * @return int |
|
140 | + * |
|
141 | + * @see ConvertHelper_DateInterval::TOKEN_SECONDS |
|
142 | + * @see ConvertHelper_DateInterval::TOKEN_MINUTES |
|
143 | + * @see ConvertHelper_DateInterval::TOKEN_HOURS |
|
144 | + * @see ConvertHelper_DateInterval::TOKEN_DAYS |
|
145 | + * @see ConvertHelper_DateInterval::TOKEN_MONTHS |
|
146 | + * @see ConvertHelper_DateInterval::TOKEN_YEARS |
|
147 | + */ |
|
148 | 148 | public function getToken(string $token) : int |
149 | 149 | { |
150 | 150 | return (int)$this->interval->$token; |
151 | 151 | } |
152 | 152 | |
153 | - /** |
|
154 | - * The total amount of seconds in the interval (including |
|
155 | - * everything, from seconds to days, months, years...). |
|
156 | - * |
|
157 | - * @return int |
|
158 | - */ |
|
153 | + /** |
|
154 | + * The total amount of seconds in the interval (including |
|
155 | + * everything, from seconds to days, months, years...). |
|
156 | + * |
|
157 | + * @return int |
|
158 | + */ |
|
159 | 159 | public function getTotalSeconds() : int |
160 | 160 | { |
161 | 161 | return $this->seconds; |
@@ -57,7 +57,7 @@ |
||
57 | 57 | |
58 | 58 | $interval = $d2->diff($d1); |
59 | 59 | |
60 | - if($interval === false) |
|
60 | + if ($interval === false) |
|
61 | 61 | { |
62 | 62 | throw new ConvertHelper_Exception( |
63 | 63 | 'Cannot create interval', |
@@ -26,39 +26,39 @@ discard block |
||
26 | 26 | const ERROR_NO_DATE_FROM_SET = 43401; |
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * @var int |
|
31 | - */ |
|
29 | + /** |
|
30 | + * @var int |
|
31 | + */ |
|
32 | 32 | protected $dateFrom; |
33 | 33 | |
34 | - /** |
|
35 | - * @var int |
|
36 | - */ |
|
34 | + /** |
|
35 | + * @var int |
|
36 | + */ |
|
37 | 37 | protected $dateTo; |
38 | 38 | |
39 | - /** |
|
40 | - * @var bool |
|
41 | - */ |
|
39 | + /** |
|
40 | + * @var bool |
|
41 | + */ |
|
42 | 42 | protected $future = false; |
43 | 43 | |
44 | - /** |
|
45 | - * @var string |
|
46 | - */ |
|
44 | + /** |
|
45 | + * @var string |
|
46 | + */ |
|
47 | 47 | protected $interval = ''; |
48 | 48 | |
49 | - /** |
|
50 | - * @var int |
|
51 | - */ |
|
49 | + /** |
|
50 | + * @var int |
|
51 | + */ |
|
52 | 52 | protected $difference = 0; |
53 | 53 | |
54 | - /** |
|
55 | - * @var int |
|
56 | - */ |
|
54 | + /** |
|
55 | + * @var int |
|
56 | + */ |
|
57 | 57 | protected $dateDiff = 0; |
58 | 58 | |
59 | - /** |
|
60 | - * @var array |
|
61 | - */ |
|
59 | + /** |
|
60 | + * @var array |
|
61 | + */ |
|
62 | 62 | protected static $texts; |
63 | 63 | |
64 | 64 | public function __construct() |
@@ -78,17 +78,17 @@ discard block |
||
78 | 78 | unset(self::$texts); |
79 | 79 | } |
80 | 80 | |
81 | - /** |
|
82 | - * Sets the origin date to calculate from. |
|
83 | - * |
|
84 | - * NOTE: if this is further in the future than |
|
85 | - * the to: date, it will be considered as a |
|
86 | - * calculation for something to come, i.e. |
|
87 | - * "In two days". |
|
88 | - * |
|
89 | - * @param \DateTime $date |
|
90 | - * @return ConvertHelper_DurationConverter |
|
91 | - */ |
|
81 | + /** |
|
82 | + * Sets the origin date to calculate from. |
|
83 | + * |
|
84 | + * NOTE: if this is further in the future than |
|
85 | + * the to: date, it will be considered as a |
|
86 | + * calculation for something to come, i.e. |
|
87 | + * "In two days". |
|
88 | + * |
|
89 | + * @param \DateTime $date |
|
90 | + * @return ConvertHelper_DurationConverter |
|
91 | + */ |
|
92 | 92 | public function setDateFrom(\DateTime $date) : ConvertHelper_DurationConverter |
93 | 93 | { |
94 | 94 | $this->dateFrom = ConvertHelper::date2timestamp($date); |
@@ -96,13 +96,13 @@ discard block |
||
96 | 96 | return $this; |
97 | 97 | } |
98 | 98 | |
99 | - /** |
|
100 | - * Sets the date to calculate to. Defaults to |
|
101 | - * the current time if not set. |
|
102 | - * |
|
103 | - * @param \DateTime $date |
|
104 | - * @return ConvertHelper_DurationConverter |
|
105 | - */ |
|
99 | + /** |
|
100 | + * Sets the date to calculate to. Defaults to |
|
101 | + * the current time if not set. |
|
102 | + * |
|
103 | + * @param \DateTime $date |
|
104 | + * @return ConvertHelper_DurationConverter |
|
105 | + */ |
|
106 | 106 | public function setDateTo(\DateTime $date) : ConvertHelper_DurationConverter |
107 | 107 | { |
108 | 108 | $this->dateTo = ConvertHelper::date2timestamp($date); |
@@ -110,14 +110,14 @@ discard block |
||
110 | 110 | return $this; |
111 | 111 | } |
112 | 112 | |
113 | - /** |
|
114 | - * Converts the specified dates to a human readable string. |
|
115 | - * |
|
116 | - * @throws ConvertHelper_Exception |
|
117 | - * @return string |
|
118 | - * |
|
119 | - * @see ConvertHelper_DurationConverter::ERROR_NO_DATE_FROM_SET |
|
120 | - */ |
|
113 | + /** |
|
114 | + * Converts the specified dates to a human readable string. |
|
115 | + * |
|
116 | + * @throws ConvertHelper_Exception |
|
117 | + * @return string |
|
118 | + * |
|
119 | + * @see ConvertHelper_DurationConverter::ERROR_NO_DATE_FROM_SET |
|
120 | + */ |
|
121 | 121 | public function convert() : string |
122 | 122 | { |
123 | 123 | $this->initTexts(); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | public function __construct() |
65 | 65 | { |
66 | - if(class_exists('\AppLocalize\Localization')) { |
|
66 | + if (class_exists('\AppLocalize\Localization')) { |
|
67 | 67 | \AppLocalize\Localization::onLocaleChanged(array($this, 'handle_localeChanged')); |
68 | 68 | } |
69 | 69 | } |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | |
126 | 126 | $epoch = 'past'; |
127 | 127 | $key = 'singular'; |
128 | - if($this->dateDiff > 1) { |
|
128 | + if ($this->dateDiff > 1) { |
|
129 | 129 | $key = 'plural'; |
130 | 130 | } |
131 | 131 | |
132 | - if($this->future) { |
|
132 | + if ($this->future) { |
|
133 | 133 | $epoch = 'future'; |
134 | 134 | } |
135 | 135 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | |
143 | 143 | protected function initTexts() |
144 | 144 | { |
145 | - if(isset(self::$texts)) { |
|
145 | + if (isset(self::$texts)) { |
|
146 | 146 | return; |
147 | 147 | } |
148 | 148 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | $day = (int)date("j", $this->dateTo); |
229 | 229 | $year = (int)date("Y", $this->dateFrom); |
230 | 230 | |
231 | - while(mktime($hour, $min, $sec, $month + ($months_difference), $day, $year) < $this->dateTo) |
|
231 | + while (mktime($hour, $min, $sec, $month + ($months_difference), $day, $year) < $this->dateTo) |
|
232 | 232 | { |
233 | 233 | $months_difference++; |
234 | 234 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | |
249 | 249 | protected function resolveCalculations() : void |
250 | 250 | { |
251 | - if(!isset($this->dateFrom)) |
|
251 | + if (!isset($this->dateFrom)) |
|
252 | 252 | { |
253 | 253 | throw new ConvertHelper_Exception( |
254 | 254 | 'No date from has been specified.', |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | } |
259 | 259 | |
260 | 260 | // no date to set? Assume we want to use today. |
261 | - if(!isset($this->dateTo)) |
|
261 | + if (!isset($this->dateTo)) |
|
262 | 262 | { |
263 | 263 | $this->dateTo = time(); |
264 | 264 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | |
338 | 338 | $difference = $this->dateTo - $this->dateFrom; |
339 | 339 | |
340 | - if($difference < 0) |
|
340 | + if ($difference < 0) |
|
341 | 341 | { |
342 | 342 | $difference = $difference * -1; |
343 | 343 | $this->future = true; |
@@ -17,21 +17,20 @@ discard block |
||
17 | 17 | * @package Application Utils |
18 | 18 | * @subpackage ConvertHelper |
19 | 19 | * @author Sebastian Mordziol <[email protected]> |
20 | - |
|
21 | 20 | * @see ConvertHelper::interval2string() |
22 | 21 | */ |
23 | 22 | class ConvertHelper_IntervalConverter |
24 | 23 | { |
25 | 24 | const ERROR_MISSING_TRANSLATION = 43501; |
26 | 25 | |
27 | - /** |
|
28 | - * @var array |
|
29 | - */ |
|
26 | + /** |
|
27 | + * @var array |
|
28 | + */ |
|
30 | 29 | protected static $texts; |
31 | 30 | |
32 | - /** |
|
33 | - * @var array |
|
34 | - */ |
|
31 | + /** |
|
32 | + * @var array |
|
33 | + */ |
|
35 | 34 | protected $tokens = array('y', 'm', 'd', 'h', 'i', 's'); |
36 | 35 | |
37 | 36 | public function __construct() |
@@ -41,25 +40,25 @@ discard block |
||
41 | 40 | } |
42 | 41 | } |
43 | 42 | |
44 | - /** |
|
45 | - * Called whenever the application locale has changed, |
|
46 | - * to reset the internal translation cache. |
|
47 | - */ |
|
43 | + /** |
|
44 | + * Called whenever the application locale has changed, |
|
45 | + * to reset the internal translation cache. |
|
46 | + */ |
|
48 | 47 | public function handle_localeChanged() |
49 | 48 | { |
50 | 49 | unset(self::$texts); |
51 | 50 | } |
52 | 51 | |
53 | - /** |
|
54 | - * Converts the specified interval to a human readable |
|
55 | - * string, e.g. "2 hours and 4 minutes". |
|
56 | - * |
|
57 | - * @param \DateInterval $interval |
|
58 | - * @return string |
|
59 | - * @throws ConvertHelper_Exception |
|
60 | - * |
|
61 | - * @see ConvertHelper_IntervalConverter::ERROR_MISSING_TRANSLATION |
|
62 | - */ |
|
52 | + /** |
|
53 | + * Converts the specified interval to a human readable |
|
54 | + * string, e.g. "2 hours and 4 minutes". |
|
55 | + * |
|
56 | + * @param \DateInterval $interval |
|
57 | + * @return string |
|
58 | + * @throws ConvertHelper_Exception |
|
59 | + * |
|
60 | + * @see ConvertHelper_IntervalConverter::ERROR_MISSING_TRANSLATION |
|
61 | + */ |
|
63 | 62 | public function toString(\DateInterval $interval) : string |
64 | 63 | { |
65 | 64 | $this->initTexts(); |
@@ -88,14 +87,14 @@ discard block |
||
88 | 87 | return t('%1$s and %2$s', implode(', ', $parts), $last); |
89 | 88 | } |
90 | 89 | |
91 | - /** |
|
92 | - * Translates the selected time token, e.g. "y" (for year). |
|
93 | - * |
|
94 | - * @param string $token |
|
95 | - * @param ConvertHelper_DateInterval $interval |
|
96 | - * @throws ConvertHelper_Exception |
|
97 | - * @return string |
|
98 | - */ |
|
90 | + /** |
|
91 | + * Translates the selected time token, e.g. "y" (for year). |
|
92 | + * |
|
93 | + * @param string $token |
|
94 | + * @param ConvertHelper_DateInterval $interval |
|
95 | + * @throws ConvertHelper_Exception |
|
96 | + * @return string |
|
97 | + */ |
|
99 | 98 | protected function translateToken(string $token, ConvertHelper_DateInterval $interval) : string |
100 | 99 | { |
101 | 100 | $value = $interval->getToken($token); |
@@ -123,13 +122,13 @@ discard block |
||
123 | 122 | ); |
124 | 123 | } |
125 | 124 | |
126 | - /** |
|
127 | - * Resolves all time tokens that need to be translated in |
|
128 | - * the subject interval, depending on its length. |
|
129 | - * |
|
130 | - * @param ConvertHelper_DateInterval $interval |
|
131 | - * @return array |
|
132 | - */ |
|
125 | + /** |
|
126 | + * Resolves all time tokens that need to be translated in |
|
127 | + * the subject interval, depending on its length. |
|
128 | + * |
|
129 | + * @param ConvertHelper_DateInterval $interval |
|
130 | + * @return array |
|
131 | + */ |
|
133 | 132 | protected function resolveTokens(ConvertHelper_DateInterval $interval) : array |
134 | 133 | { |
135 | 134 | $offset = 0; |
@@ -147,9 +146,9 @@ discard block |
||
147 | 146 | return array(); |
148 | 147 | } |
149 | 148 | |
150 | - /** |
|
151 | - * Initializes the translateable strings. |
|
152 | - */ |
|
149 | + /** |
|
150 | + * Initializes the translateable strings. |
|
151 | + */ |
|
153 | 152 | protected function initTexts() : void |
154 | 153 | { |
155 | 154 | if(isset(self::$texts)) { |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | public function __construct() |
38 | 38 | { |
39 | - if(class_exists('\AppLocalize\Localization')) { |
|
39 | + if (class_exists('\AppLocalize\Localization')) { |
|
40 | 40 | \AppLocalize\Localization::onLocaleChanged(array($this, 'handle_localeChanged')); |
41 | 41 | } |
42 | 42 | } |
@@ -69,17 +69,17 @@ discard block |
||
69 | 69 | $keep = $this->resolveTokens($interval); |
70 | 70 | |
71 | 71 | $parts = array(); |
72 | - foreach($keep as $token) |
|
72 | + foreach ($keep as $token) |
|
73 | 73 | { |
74 | 74 | $value = $interval->getToken($token); |
75 | - if($value === 0) { |
|
75 | + if ($value === 0) { |
|
76 | 76 | continue; |
77 | 77 | } |
78 | 78 | |
79 | 79 | $parts[] = $this->translateToken($token, $interval); |
80 | 80 | } |
81 | 81 | |
82 | - if(count($parts) == 1) { |
|
82 | + if (count($parts) == 1) { |
|
83 | 83 | return $parts[0]; |
84 | 84 | } |
85 | 85 | |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | $value = $interval->getToken($token); |
102 | 102 | |
103 | 103 | $suffix = 'p'; |
104 | - if($value == 1) { $suffix = 's'; } |
|
104 | + if ($value == 1) { $suffix = 's'; } |
|
105 | 105 | $token .= $suffix; |
106 | 106 | |
107 | - if(!isset(self::$texts[$token])) |
|
107 | + if (!isset(self::$texts[$token])) |
|
108 | 108 | { |
109 | 109 | throw new ConvertHelper_Exception( |
110 | 110 | 'Missing interval translation', |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | { |
135 | 135 | $offset = 0; |
136 | 136 | |
137 | - foreach($this->tokens as $token) |
|
137 | + foreach ($this->tokens as $token) |
|
138 | 138 | { |
139 | - if($interval->getToken($token) > 0) |
|
139 | + if ($interval->getToken($token) > 0) |
|
140 | 140 | { |
141 | 141 | return array_slice($this->tokens, $offset); |
142 | 142 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | protected function initTexts() : void |
154 | 154 | { |
155 | - if(isset(self::$texts)) { |
|
155 | + if (isset(self::$texts)) { |
|
156 | 156 | return; |
157 | 157 | } |
158 | 158 |