Passed
Push — master ( 900633...b5002d )
by Sebastian
03:40
created
src/ConvertHelper.php 1 patch
Indentation   +496 added lines, -496 removed lines patch added patch discarded remove patch
@@ -54,13 +54,13 @@  discard block
 block discarded – undo
54 54
         return ConvertHelper_String::tabs2spaces($string, $tabSize);
55 55
     }
56 56
     
57
-   /**
58
-    * Converts spaces to tabs in the specified string.
59
-    * 
60
-    * @param string $string
61
-    * @param int $tabSize The amount of spaces per tab in the source string.
62
-    * @return string
63
-    */
57
+    /**
58
+     * Converts spaces to tabs in the specified string.
59
+     * 
60
+     * @param string $string
61
+     * @param int $tabSize The amount of spaces per tab in the source string.
62
+     * @return string
63
+     */
64 64
     public static function spaces2tabs(string $string, int $tabSize=4) : string
65 65
     {
66 66
         return ConvertHelper_String::spaces2tabs($string, $tabSize);
@@ -78,133 +78,133 @@  discard block
 block discarded – undo
78 78
         return ConvertHelper_String::hidden2visible($string);
79 79
     }
80 80
     
81
-   /**
82
-    * Converts the specified amount of seconds into
83
-    * a human readable string split in months, weeks,
84
-    * days, hours, minutes and seconds.
85
-    *
86
-    * @param float $seconds
87
-    * @return string
88
-    */
81
+    /**
82
+     * Converts the specified amount of seconds into
83
+     * a human readable string split in months, weeks,
84
+     * days, hours, minutes and seconds.
85
+     *
86
+     * @param float $seconds
87
+     * @return string
88
+     */
89 89
     public static function time2string($seconds) : string
90 90
     {
91 91
         $converter = new ConvertHelper_TimeConverter($seconds);
92 92
         return $converter->toString();
93 93
     }
94 94
 
95
-   /**
96
-    * Converts a timestamp into an easily understandable
97
-    * format, e.g. "2 hours", "1 day", "3 months"
98
-    *
99
-    * If you set the date to parameter, the difference
100
-    * will be calculated between the two dates and not
101
-    * the current time.
102
-    *
103
-    * @param integer|DateTime $datefrom
104
-    * @param integer|DateTime $dateto
105
-    * @return string
106
-    */
95
+    /**
96
+     * Converts a timestamp into an easily understandable
97
+     * format, e.g. "2 hours", "1 day", "3 months"
98
+     *
99
+     * If you set the date to parameter, the difference
100
+     * will be calculated between the two dates and not
101
+     * the current time.
102
+     *
103
+     * @param integer|DateTime $datefrom
104
+     * @param integer|DateTime $dateto
105
+     * @return string
106
+     */
107 107
     public static function duration2string($datefrom, $dateto = -1) : string
108 108
     {
109
-         $converter = new ConvertHelper_DurationConverter();
109
+            $converter = new ConvertHelper_DurationConverter();
110 110
          
111
-         if($datefrom instanceof DateTime)
112
-         {
113
-             $converter->setDateFrom($datefrom);
114
-         }
115
-         else
116
-         {
117
-             $converter->setDateFrom(self::timestamp2date($datefrom)); 
118
-         }
111
+            if($datefrom instanceof DateTime)
112
+            {
113
+                $converter->setDateFrom($datefrom);
114
+            }
115
+            else
116
+            {
117
+                $converter->setDateFrom(self::timestamp2date($datefrom)); 
118
+            }
119 119
 
120
-         if($dateto instanceof DateTime)
121
-         {
122
-             $converter->setDateTo($dateto);
123
-         }
124
-         else if($dateto > 0)
125
-         {
126
-             $converter->setDateTo(self::timestamp2date($dateto));
127
-         }
120
+            if($dateto instanceof DateTime)
121
+            {
122
+                $converter->setDateTo($dateto);
123
+            }
124
+            else if($dateto > 0)
125
+            {
126
+                $converter->setDateTo(self::timestamp2date($dateto));
127
+            }
128 128
 
129
-         return $converter->convert();
129
+            return $converter->convert();
130 130
     }
131 131
 
132
-   /**
133
-    * Adds HTML syntax highlighting to the specified SQL string.
134
-    * 
135
-    * @param string $sql
136
-    * @return string
137
-    * @deprecated Use the Highlighter class directly instead.
138
-    * @see Highlighter::sql()
139
-    */
132
+    /**
133
+     * Adds HTML syntax highlighting to the specified SQL string.
134
+     * 
135
+     * @param string $sql
136
+     * @return string
137
+     * @deprecated Use the Highlighter class directly instead.
138
+     * @see Highlighter::sql()
139
+     */
140 140
     public static function highlight_sql(string $sql) : string
141 141
     {
142 142
         return Highlighter::sql($sql);
143 143
     }
144 144
 
145
-   /**
146
-    * Adds HTML syntax highlighting to the specified XML code.
147
-    * 
148
-    * @param string $xml The XML to highlight.
149
-    * @param bool $formatSource Whether to format the source with indentation to make it readable.
150
-    * @return string
151
-    * @deprecated Use the Highlighter class directly instead.
152
-    * @see Highlighter::xml()
153
-    */
145
+    /**
146
+     * Adds HTML syntax highlighting to the specified XML code.
147
+     * 
148
+     * @param string $xml The XML to highlight.
149
+     * @param bool $formatSource Whether to format the source with indentation to make it readable.
150
+     * @return string
151
+     * @deprecated Use the Highlighter class directly instead.
152
+     * @see Highlighter::xml()
153
+     */
154 154
     public static function highlight_xml(string $xml, bool $formatSource=false) : string
155 155
     {
156 156
         return Highlighter::xml($xml, $formatSource);
157 157
     }
158 158
 
159
-   /**
160
-    * @param string $phpCode
161
-    * @return string
162
-    * @deprecated Use the Highlighter class directly instead.
163
-    * @see Highlighter::php()
164
-    */
159
+    /**
160
+     * @param string $phpCode
161
+     * @return string
162
+     * @deprecated Use the Highlighter class directly instead.
163
+     * @see Highlighter::php()
164
+     */
165 165
     public static function highlight_php(string $phpCode) : string
166 166
     {
167 167
         return Highlighter::php($phpCode);
168 168
     }
169 169
     
170
-   /**
171
-    * Converts a number of bytes to a human readable form,
172
-    * e.g. xx Kb / xx Mb / xx Gb
173
-    *
174
-    * @param int $bytes The amount of bytes to convert.
175
-    * @param int $precision The amount of decimals
176
-    * @param int $base The base to calculate with: Base 10 is default (=1000 Bytes in a KB), Base 2 is mainly used for Windows memory (=1024 Bytes in a KB).
177
-    * @return string
178
-    * 
179
-    * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions
180
-    */
170
+    /**
171
+     * Converts a number of bytes to a human readable form,
172
+     * e.g. xx Kb / xx Mb / xx Gb
173
+     *
174
+     * @param int $bytes The amount of bytes to convert.
175
+     * @param int $precision The amount of decimals
176
+     * @param int $base The base to calculate with: Base 10 is default (=1000 Bytes in a KB), Base 2 is mainly used for Windows memory (=1024 Bytes in a KB).
177
+     * @return string
178
+     * 
179
+     * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions
180
+     */
181 181
     public static function bytes2readable(int $bytes, int $precision = 1, int $base = ConvertHelper_StorageSizeEnum::BASE_10) : string
182 182
     {
183 183
         return self::parseBytes($bytes)->toString($precision, $base);
184 184
     }
185 185
     
186
-   /**
187
-    * Parses a number of bytes, and creates a converter instance which
188
-    * allows doing common operations with it.
189
-    * 
190
-    * @param int $bytes
191
-    * @return ConvertHelper_ByteConverter
192
-    */
186
+    /**
187
+     * Parses a number of bytes, and creates a converter instance which
188
+     * allows doing common operations with it.
189
+     * 
190
+     * @param int $bytes
191
+     * @return ConvertHelper_ByteConverter
192
+     */
193 193
     public static function parseBytes(int $bytes) : ConvertHelper_ByteConverter
194 194
     {
195 195
         return new ConvertHelper_ByteConverter($bytes);
196 196
     }
197 197
 
198
-   /**
199
-    * Cuts a text to the specified length if it is longer than the
200
-    * target length. Appends a text to signify it has been cut at 
201
-    * the end of the string.
202
-    * 
203
-    * @param string $text
204
-    * @param int $targetLength
205
-    * @param string $append
206
-    * @return string
207
-    */
198
+    /**
199
+     * Cuts a text to the specified length if it is longer than the
200
+     * target length. Appends a text to signify it has been cut at 
201
+     * the end of the string.
202
+     * 
203
+     * @param string $text
204
+     * @param int $targetLength
205
+     * @param string $append
206
+     * @return string
207
+     */
208 208
     public static function text_cut(string $text, int $targetLength, string $append = '...') : string
209 209
     {
210 210
         return ConvertHelper_String::cutText($text, $targetLength, $append);
@@ -221,14 +221,14 @@  discard block
 block discarded – undo
221 221
         return $info->toString();
222 222
     }
223 223
     
224
-   /**
225
-    * Pretty print_r.
226
-    * 
227
-    * @param mixed $var The variable to dump.
228
-    * @param bool $return Whether to return the dumped code.
229
-    * @param bool $html Whether to style the dump as HTML.
230
-    * @return string
231
-    */
224
+    /**
225
+     * Pretty print_r.
226
+     * 
227
+     * @param mixed $var The variable to dump.
228
+     * @param bool $return Whether to return the dumped code.
229
+     * @param bool $html Whether to style the dump as HTML.
230
+     * @return string
231
+     */
232 232
     public static function print_r($var, bool $return=false, bool $html=true) : string
233 233
     {
234 234
         $result = parseVariable($var)->enableType()->toString();
@@ -249,41 +249,41 @@  discard block
 block discarded – undo
249 249
         return $result;
250 250
     }
251 251
     
252
-   /**
253
-    * Converts a string, number or boolean value to a boolean value.
254
-    *
255
-    * @param mixed $string
256
-    * @throws ConvertHelper_Exception
257
-    * @return bool
258
-    *
259
-    * @see ConvertHelper::ERROR_INVALID_BOOLEAN_STRING
260
-    */
252
+    /**
253
+     * Converts a string, number or boolean value to a boolean value.
254
+     *
255
+     * @param mixed $string
256
+     * @throws ConvertHelper_Exception
257
+     * @return bool
258
+     *
259
+     * @see ConvertHelper::ERROR_INVALID_BOOLEAN_STRING
260
+     */
261 261
     public static function string2bool($string) : bool
262 262
     {
263 263
         return ConvertHelper_Bool::fromString($string);
264 264
     }
265 265
 
266
-   /**
267
-    * Whether the specified string is a boolean string or boolean value.
268
-    * Alias for {@link ConvertHelper::isBoolean()}.
269
-    *
270
-    * @param mixed $string
271
-    * @return bool
272
-    * @deprecated
273
-    * @see ConvertHelper::isBoolean()
274
-    */
266
+    /**
267
+     * Whether the specified string is a boolean string or boolean value.
268
+     * Alias for {@link ConvertHelper::isBoolean()}.
269
+     *
270
+     * @param mixed $string
271
+     * @return bool
272
+     * @deprecated
273
+     * @see ConvertHelper::isBoolean()
274
+     */
275 275
     public static function isBooleanString($string) : bool
276 276
     {
277 277
         return self::isBoolean($string);
278 278
     }
279 279
 
280
-   /**
281
-    * Alias for the {@\AppUtils\XMLHelper::string2xml()} method.
282
-    * 
283
-    * @param string $text
284
-    * @return string
285
-    * @deprecated
286
-    */
280
+    /**
281
+     * Alias for the {@\AppUtils\XMLHelper::string2xml()} method.
282
+     * 
283
+     * @param string $text
284
+     * @return string
285
+     * @deprecated
286
+     */
287 287
     public static function text_makeXMLCompliant($text)
288 288
     {
289 289
         return XMLHelper::string2xml($text);
@@ -379,36 +379,36 @@  discard block
 block discarded – undo
379 379
         return ConvertHelper_String::transliterate($string, $spaceChar, $lowercase);
380 380
     }
381 381
     
382
-   /**
383
-    * Retrieves the HEX character codes for all control
384
-    * characters that the {@link stripControlCharacters()} 
385
-    * method will remove.
386
-    * 
387
-    * @return string[]
388
-    */
382
+    /**
383
+     * Retrieves the HEX character codes for all control
384
+     * characters that the {@link stripControlCharacters()} 
385
+     * method will remove.
386
+     * 
387
+     * @return string[]
388
+     */
389 389
     public static function getControlCharactersAsHex()
390 390
     {
391 391
         return self::createControlCharacters()->getCharsAsHex();
392 392
     }
393 393
     
394
-   /**
395
-    * Retrieves an array of all control characters that
396
-    * the {@link stripControlCharacters()} method will 
397
-    * remove, as the actual UTF-8 characters.
398
-    * 
399
-    * @return string[]
400
-    */
394
+    /**
395
+     * Retrieves an array of all control characters that
396
+     * the {@link stripControlCharacters()} method will 
397
+     * remove, as the actual UTF-8 characters.
398
+     * 
399
+     * @return string[]
400
+     */
401 401
     public static function getControlCharactersAsUTF8()
402 402
     {
403 403
         return self::createControlCharacters()->getCharsAsUTF8();
404 404
     }
405 405
     
406
-   /**
407
-    * Retrieves all control characters as JSON encoded
408
-    * characters, e.g. "\u200b".
409
-    * 
410
-    * @return string[]
411
-    */
406
+    /**
407
+     * Retrieves all control characters as JSON encoded
408
+     * characters, e.g. "\u200b".
409
+     * 
410
+     * @return string[]
411
+     */
412 412
     public static function getControlCharactersAsJSON()
413 413
     {
414 414
         return self::createControlCharacters()->getCharsAsJSON();
@@ -429,31 +429,31 @@  discard block
 block discarded – undo
429 429
         return self::createControlCharacters()->stripControlCharacters($string);
430 430
     }
431 431
     
432
-   /**
433
-    * Creates the control characters class, used to 
434
-    * work with control characters in strings.
435
-    * 
436
-    * @return ConvertHelper_ControlCharacters
437
-    */
432
+    /**
433
+     * Creates the control characters class, used to 
434
+     * work with control characters in strings.
435
+     * 
436
+     * @return ConvertHelper_ControlCharacters
437
+     */
438 438
     public static function createControlCharacters() : ConvertHelper_ControlCharacters
439 439
     {
440 440
         return new ConvertHelper_ControlCharacters();
441 441
     }
442 442
 
443
-   /**
444
-    * Converts a unicode character to the PHPO notation.
445
-    * 
446
-    * Example:
447
-    * 
448
-    * <pre>unicodeChar2php('"\u0000"')</pre>
449
-    * 
450
-    * Returns
451
-    * 
452
-    * <pre>\x0</pre>
453
-    * 
454
-    * @param string $unicodeChar
455
-    * @return string
456
-    */
443
+    /**
444
+     * Converts a unicode character to the PHPO notation.
445
+     * 
446
+     * Example:
447
+     * 
448
+     * <pre>unicodeChar2php('"\u0000"')</pre>
449
+     * 
450
+     * Returns
451
+     * 
452
+     * <pre>\x0</pre>
453
+     * 
454
+     * @param string $unicodeChar
455
+     * @return string
456
+     */
457 457
     public static function unicodeChar2php(string $unicodeChar) : string 
458 458
     {
459 459
         $unicodeChar = json_decode($unicodeChar);
@@ -563,87 +563,87 @@  discard block
 block discarded – undo
563 563
         return ConvertHelper_Bool::toString($boolean, $yesno);
564 564
     }
565 565
     
566
-   /**
567
-    * Converts an associative array with attribute name > value pairs
568
-    * to an attribute string that can be used in an HTML tag. Empty 
569
-    * attribute values are ignored.
570
-    * 
571
-    * Example:
572
-    * 
573
-    * array2attributeString(array(
574
-    *     'id' => 45,
575
-    *     'href' => 'http://www.mistralys.com'
576
-    * ));
577
-    * 
578
-    * Result:
579
-    * 
580
-    * id="45" href="http://www.mistralys.com"
581
-    * 
582
-    * @param array<string,mixed> $array
583
-    * @return string
584
-    */
566
+    /**
567
+     * Converts an associative array with attribute name > value pairs
568
+     * to an attribute string that can be used in an HTML tag. Empty 
569
+     * attribute values are ignored.
570
+     * 
571
+     * Example:
572
+     * 
573
+     * array2attributeString(array(
574
+     *     'id' => 45,
575
+     *     'href' => 'http://www.mistralys.com'
576
+     * ));
577
+     * 
578
+     * Result:
579
+     * 
580
+     * id="45" href="http://www.mistralys.com"
581
+     * 
582
+     * @param array<string,mixed> $array
583
+     * @return string
584
+     */
585 585
     public static function array2attributeString(array $array) : string
586 586
     {
587 587
         return ConvertHelper_Array::toAttributeString($array);
588 588
     }
589 589
     
590
-   /**
591
-    * Converts a string so it can safely be used in a javascript
592
-    * statement in an HTML tag: uses single quotes around the string
593
-    * and encodes all special characters as needed.
594
-    * 
595
-    * @param string $string
596
-    * @return string
597
-    * @deprecated Use the JSHelper class instead.
598
-    * @see JSHelper::phpVariable2AttributeJS()
599
-    */
590
+    /**
591
+     * Converts a string so it can safely be used in a javascript
592
+     * statement in an HTML tag: uses single quotes around the string
593
+     * and encodes all special characters as needed.
594
+     * 
595
+     * @param string $string
596
+     * @return string
597
+     * @deprecated Use the JSHelper class instead.
598
+     * @see JSHelper::phpVariable2AttributeJS()
599
+     */
600 600
     public static function string2attributeJS(string $string) : string
601 601
     {
602 602
         return JSHelper::phpVariable2AttributeJS($string);
603 603
     }
604 604
     
605
-   /**
606
-    * Checks if the specified string is a boolean value, which
607
-    * includes string representations of boolean values, like 
608
-    * <code>yes</code> or <code>no</code>, and <code>true</code>
609
-    * or <code>false</code>.
610
-    * 
611
-    * @param mixed $value
612
-    * @return boolean
613
-    */
605
+    /**
606
+     * Checks if the specified string is a boolean value, which
607
+     * includes string representations of boolean values, like 
608
+     * <code>yes</code> or <code>no</code>, and <code>true</code>
609
+     * or <code>false</code>.
610
+     * 
611
+     * @param mixed $value
612
+     * @return boolean
613
+     */
614 614
     public static function isBoolean($value) : bool
615 615
     {
616 616
         return ConvertHelper_Bool::isBoolean($value);
617 617
     }
618 618
     
619
-   /**
620
-    * Converts an associative array to an HTML style attribute value string.
621
-    * 
622
-    * @param array<string,mixed> $subject
623
-    * @return string
624
-    */
619
+    /**
620
+     * Converts an associative array to an HTML style attribute value string.
621
+     * 
622
+     * @param array<string,mixed> $subject
623
+     * @return string
624
+     */
625 625
     public static function array2styleString(array $subject) : string
626 626
     {
627 627
         return ConvertHelper_Array::toStyleString($subject);
628 628
     }
629 629
     
630
-   /**
631
-    * Converts a DateTime object to a timestamp, which
632
-    * is PHP 5.2 compatible.
633
-    * 
634
-    * @param DateTime $date
635
-    * @return integer
636
-    */
630
+    /**
631
+     * Converts a DateTime object to a timestamp, which
632
+     * is PHP 5.2 compatible.
633
+     * 
634
+     * @param DateTime $date
635
+     * @return integer
636
+     */
637 637
     public static function date2timestamp(DateTime $date) : int
638 638
     {
639 639
         return (int)$date->format('U');
640 640
     }
641 641
     
642
-   /**
643
-    * Converts a timestamp into a DateTime instance.
644
-    * @param int $timestamp
645
-    * @return DateTime
646
-    */
642
+    /**
643
+     * Converts a timestamp into a DateTime instance.
644
+     * @param int $timestamp
645
+     * @return DateTime
646
+     */
647 647
     public static function timestamp2date(int $timestamp) : DateTime
648 648
     {
649 649
         $date = new DateTime();
@@ -651,50 +651,50 @@  discard block
 block discarded – undo
651 651
         return $date;
652 652
     }
653 653
     
654
-   /**
655
-    * Strips an absolute path to a file within the application
656
-    * to make the path relative to the application root path.
657
-    * 
658
-    * @param string $path
659
-    * @return string
660
-    * 
661
-    * @see FileHelper::relativizePath()
662
-    * @see FileHelper::relativizePathByDepth()
663
-    */
654
+    /**
655
+     * Strips an absolute path to a file within the application
656
+     * to make the path relative to the application root path.
657
+     * 
658
+     * @param string $path
659
+     * @return string
660
+     * 
661
+     * @see FileHelper::relativizePath()
662
+     * @see FileHelper::relativizePathByDepth()
663
+     */
664 664
     public static function fileRelativize(string $path) : string
665 665
     {
666 666
         return FileHelper::relativizePathByDepth($path);
667 667
     }
668 668
     
669 669
     /**
670
-    * Converts a PHP regex to a javascript RegExp object statement.
671
-    * 
672
-    * NOTE: This is an alias for the JSHelper's `convertRegex` method. 
673
-    * More details are available on its usage there.
674
-    *
675
-    * @param string $regex A PHP preg regex
676
-    * @param string $statementType The type of statement to return: Defaults to a statement to create a RegExp object.
677
-    * @return array|string Depending on the specified return type.
678
-    * 
679
-    * @see JSHelper::buildRegexStatement()
680
-    */
670
+     * Converts a PHP regex to a javascript RegExp object statement.
671
+     * 
672
+     * NOTE: This is an alias for the JSHelper's `convertRegex` method. 
673
+     * More details are available on its usage there.
674
+     *
675
+     * @param string $regex A PHP preg regex
676
+     * @param string $statementType The type of statement to return: Defaults to a statement to create a RegExp object.
677
+     * @return array|string Depending on the specified return type.
678
+     * 
679
+     * @see JSHelper::buildRegexStatement()
680
+     */
681 681
     public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT)
682 682
     {
683 683
         return JSHelper::buildRegexStatement($regex, $statementType);
684 684
     }
685 685
     
686
-   /**
687
-    * Converts the specified variable to JSON. Works just
688
-    * like the native `json_encode` method, except that it
689
-    * will trigger an exception on failure, which has the 
690
-    * json error details included in its developer details.
691
-    * 
692
-    * @param mixed $variable
693
-    * @param int $options JSON encode options.
694
-    * @param int $depth 
695
-    * @throws ConvertHelper_Exception
696
-    * @return string
697
-    */
686
+    /**
687
+     * Converts the specified variable to JSON. Works just
688
+     * like the native `json_encode` method, except that it
689
+     * will trigger an exception on failure, which has the 
690
+     * json error details included in its developer details.
691
+     * 
692
+     * @param mixed $variable
693
+     * @param int $options JSON encode options.
694
+     * @param int $depth 
695
+     * @throws ConvertHelper_Exception
696
+     * @return string
697
+     */
698 698
     public static function var2json($variable, int $options=0, int $depth=512) : string
699 699
     {
700 700
         $result = json_encode($variable, $options, $depth);
@@ -729,12 +729,12 @@  discard block
 block discarded – undo
729 729
             ->toString();
730 730
     }
731 731
     
732
-   /**
733
-    * Strips all known UTF byte order marks from the specified string.
734
-    * 
735
-    * @param string $string
736
-    * @return string
737
-    */
732
+    /**
733
+     * Strips all known UTF byte order marks from the specified string.
734
+     * 
735
+     * @param string $string
736
+     * @return string
737
+     */
738 738
     public static function stripUTFBom($string)
739 739
     {
740 740
         $boms = FileHelper::getUTFBOMs();
@@ -749,65 +749,65 @@  discard block
 block discarded – undo
749 749
         return $string;
750 750
     }
751 751
 
752
-   /**
753
-    * Converts a string to valid utf8, regardless
754
-    * of the string's encoding(s).
755
-    * 
756
-    * @param string $string
757
-    * @return string
758
-    */
752
+    /**
753
+     * Converts a string to valid utf8, regardless
754
+     * of the string's encoding(s).
755
+     * 
756
+     * @param string $string
757
+     * @return string
758
+     */
759 759
     public static function string2utf8(string $string) : string
760 760
     {
761 761
         return ConvertHelper_String::toUtf8($string);
762 762
     }
763 763
     
764
-   /**
765
-    * Checks whether the specified string is an ASCII
766
-    * string, without any special or UTF8 characters.
767
-    * Note: empty strings and NULL are considered ASCII.
768
-    * Any variable types other than strings are not.
769
-    * 
770
-    * @param string|float|int|NULL $string
771
-    * @return boolean
772
-    */
764
+    /**
765
+     * Checks whether the specified string is an ASCII
766
+     * string, without any special or UTF8 characters.
767
+     * Note: empty strings and NULL are considered ASCII.
768
+     * Any variable types other than strings are not.
769
+     * 
770
+     * @param string|float|int|NULL $string
771
+     * @return boolean
772
+     */
773 773
     public static function isStringASCII($string) : bool
774 774
     {
775 775
         return ConvertHelper_String::isASCII(strval($string));
776 776
     }
777 777
     
778
-   /**
779
-    * Adds HTML syntax highlighting to an URL.
780
-    * 
781
-    * NOTE: Includes the necessary CSS styles. When
782
-    * highlighting several URLs in the same page,
783
-    * prefer using the `parseURL` function instead.
784
-    * 
785
-    * @param string $url
786
-    * @return string
787
-    * @deprecated Use the Highlighter class directly instead.
788
-    * @see Highlighter
789
-    */
778
+    /**
779
+     * Adds HTML syntax highlighting to an URL.
780
+     * 
781
+     * NOTE: Includes the necessary CSS styles. When
782
+     * highlighting several URLs in the same page,
783
+     * prefer using the `parseURL` function instead.
784
+     * 
785
+     * @param string $url
786
+     * @return string
787
+     * @deprecated Use the Highlighter class directly instead.
788
+     * @see Highlighter
789
+     */
790 790
     public static function highlight_url(string $url) : string
791 791
     {
792 792
         return Highlighter::url($url);
793 793
     }
794 794
 
795
-   /**
796
-    * Calculates a percentage match of the source string with the target string.
797
-    * 
798
-    * Options are:
799
-    * 
800
-    * - maxLevenshtein, default: 10
801
-    *   Any levenshtein results above this value are ignored.
802
-    *   
803
-    * - precision, default: 1
804
-    *   The precision of the percentage float value
805
-    * 
806
-    * @param string $source
807
-    * @param string $target
808
-    * @param array $options
809
-    * @return float
810
-    */
795
+    /**
796
+     * Calculates a percentage match of the source string with the target string.
797
+     * 
798
+     * Options are:
799
+     * 
800
+     * - maxLevenshtein, default: 10
801
+     *   Any levenshtein results above this value are ignored.
802
+     *   
803
+     * - precision, default: 1
804
+     *   The precision of the percentage float value
805
+     * 
806
+     * @param string $source
807
+     * @param string $target
808
+     * @param array $options
809
+     * @return float
810
+     */
811 811
     public static function matchString($source, $target, $options=array())
812 812
     {
813 813
         $defaults = array(
@@ -831,14 +831,14 @@  discard block
 block discarded – undo
831 831
         return round(100 - $percent, $options['precision']);
832 832
     }
833 833
     
834
-   /**
835
-    * Converts a date interval to a human readable string with
836
-    * all necessary time components, e.g. "1 year, 2 months and 4 days".
837
-    * 
838
-    * @param \DateInterval $interval
839
-    * @return string
840
-    * @see ConvertHelper_IntervalConverter
841
-    */
834
+    /**
835
+     * Converts a date interval to a human readable string with
836
+     * all necessary time components, e.g. "1 year, 2 months and 4 days".
837
+     * 
838
+     * @param \DateInterval $interval
839
+     * @return string
840
+     * @see ConvertHelper_IntervalConverter
841
+     */
842 842
     public static function interval2string(\DateInterval $interval) : string
843 843
     {
844 844
         $converter = new ConvertHelper_IntervalConverter();
@@ -853,60 +853,60 @@  discard block
 block discarded – undo
853 853
     
854 854
     const INTERVAL_SECONDS = 'seconds';
855 855
     
856
-   /**
857
-    * Converts an interval to its total amount of days.
858
-    * @param \DateInterval $interval
859
-    * @return int
860
-    */
856
+    /**
857
+     * Converts an interval to its total amount of days.
858
+     * @param \DateInterval $interval
859
+     * @return int
860
+     */
861 861
     public static function interval2days(\DateInterval $interval) : int
862 862
     {
863 863
         return self::interval2total($interval, self::INTERVAL_DAYS);
864 864
     }
865 865
 
866
-   /**
867
-    * Converts an interval to its total amount of hours.
868
-    * @param \DateInterval $interval
869
-    * @return int
870
-    */
866
+    /**
867
+     * Converts an interval to its total amount of hours.
868
+     * @param \DateInterval $interval
869
+     * @return int
870
+     */
871 871
     public static function interval2hours(\DateInterval $interval) : int
872 872
     {
873 873
         return self::interval2total($interval, self::INTERVAL_HOURS);
874 874
     }
875 875
     
876
-   /**
877
-    * Converts an interval to its total amount of minutes. 
878
-    * @param \DateInterval $interval
879
-    * @return int
880
-    */
876
+    /**
877
+     * Converts an interval to its total amount of minutes. 
878
+     * @param \DateInterval $interval
879
+     * @return int
880
+     */
881 881
     public static function interval2minutes(\DateInterval $interval) : int
882 882
     {
883 883
         return self::interval2total($interval, self::INTERVAL_MINUTES);
884 884
     }
885 885
     
886
-   /**
887
-    * Converts an interval to its total amount of seconds.
888
-    * @param \DateInterval $interval
889
-    * @return int
890
-    */    
886
+    /**
887
+     * Converts an interval to its total amount of seconds.
888
+     * @param \DateInterval $interval
889
+     * @return int
890
+     */    
891 891
     public static function interval2seconds(\DateInterval $interval) : int
892 892
     {
893 893
         return self::interval2total($interval, self::INTERVAL_SECONDS);
894 894
     }
895 895
     
896
-   /**
897
-    * Calculates the total amount of days / hours / minutes or seconds
898
-    * of a date interval object (depending in the specified units), and 
899
-    * returns the total amount.
900
-    * 
901
-    * @param \DateInterval $interval
902
-    * @param string $unit What total value to calculate.
903
-    * @return integer
904
-    * 
905
-    * @see ConvertHelper::INTERVAL_SECONDS
906
-    * @see ConvertHelper::INTERVAL_MINUTES
907
-    * @see ConvertHelper::INTERVAL_HOURS
908
-    * @see ConvertHelper::INTERVAL_DAYS
909
-    */
896
+    /**
897
+     * Calculates the total amount of days / hours / minutes or seconds
898
+     * of a date interval object (depending in the specified units), and 
899
+     * returns the total amount.
900
+     * 
901
+     * @param \DateInterval $interval
902
+     * @param string $unit What total value to calculate.
903
+     * @return integer
904
+     * 
905
+     * @see ConvertHelper::INTERVAL_SECONDS
906
+     * @see ConvertHelper::INTERVAL_MINUTES
907
+     * @see ConvertHelper::INTERVAL_HOURS
908
+     * @see ConvertHelper::INTERVAL_DAYS
909
+     */
910 910
     public static function interval2total(\DateInterval $interval, $unit=self::INTERVAL_SECONDS) : int
911 911
     {
912 912
         $total = (int)$interval->format('%a');
@@ -946,13 +946,13 @@  discard block
 block discarded – undo
946 946
         'Sunday'
947 947
     );
948 948
     
949
-   /**
950
-    * Converts a date to the corresponding day name.
951
-    * 
952
-    * @param DateTime $date
953
-    * @param bool $short
954
-    * @return string|NULL
955
-    */
949
+    /**
950
+     * Converts a date to the corresponding day name.
951
+     * 
952
+     * @param DateTime $date
953
+     * @param bool $short
954
+     * @return string|NULL
955
+     */
956 956
     public static function date2dayName(DateTime $date, bool $short=false)
957 957
     {
958 958
         $day = $date->format('l');
@@ -967,21 +967,21 @@  discard block
 block discarded – undo
967 967
         return null;
968 968
     }
969 969
     
970
-   /**
971
-    * Retrieves a list of english day names.
972
-    * @return string[]
973
-    */
970
+    /**
971
+     * Retrieves a list of english day names.
972
+     * @return string[]
973
+     */
974 974
     public static function getDayNamesInvariant()
975 975
     {
976 976
         return self::$daysInvariant;
977 977
     }
978 978
     
979
-   /**
980
-    * Retrieves the day names list for the current locale.
981
-    * 
982
-    * @param bool $short
983
-    * @return array
984
-    */
979
+    /**
980
+     * Retrieves the day names list for the current locale.
981
+     * 
982
+     * @param bool $short
983
+     * @return array
984
+     */
985 985
     public static function getDayNames(bool $short=false) : array
986 986
     {
987 987
         if($short) {
@@ -1028,68 +1028,68 @@  discard block
 block discarded – undo
1028 1028
         return ConvertHelper_Array::implodeWithAnd($list, $sep, $conjunction);
1029 1029
     }
1030 1030
     
1031
-   /**
1032
-    * Splits a string into an array of all characters it is composed of.
1033
-    * Unicode character safe.
1034
-    * 
1035
-    * NOTE: Spaces and newlines (both \r and \n) are also considered single
1036
-    * characters.
1037
-    * 
1038
-    * @param string $string
1039
-    * @return string[]
1040
-    */
1031
+    /**
1032
+     * Splits a string into an array of all characters it is composed of.
1033
+     * Unicode character safe.
1034
+     * 
1035
+     * NOTE: Spaces and newlines (both \r and \n) are also considered single
1036
+     * characters.
1037
+     * 
1038
+     * @param string $string
1039
+     * @return string[]
1040
+     */
1041 1041
     public static function string2array(string $string) : array
1042 1042
     {
1043 1043
         return ConvertHelper_String::toArray($string);
1044 1044
     }
1045 1045
     
1046
-   /**
1047
-    * Checks whether the specified string contains HTML code.
1048
-    * 
1049
-    * @param string $string
1050
-    * @return boolean
1051
-    */
1046
+    /**
1047
+     * Checks whether the specified string contains HTML code.
1048
+     * 
1049
+     * @param string $string
1050
+     * @return boolean
1051
+     */
1052 1052
     public static function isStringHTML(string $string) : bool
1053 1053
     {
1054 1054
         return ConvertHelper_String::isHTML($string);
1055 1055
     }
1056 1056
     
1057
-   /**
1058
-    * UTF8-safe wordwrap method: works like the regular wordwrap
1059
-    * PHP function but compatible with UTF8. Otherwise the lengths
1060
-    * are not calculated correctly.
1061
-    * 
1062
-    * @param string $str
1063
-    * @param int $width
1064
-    * @param string $break
1065
-    * @param bool $cut
1066
-    * @return string
1067
-    */
1057
+    /**
1058
+     * UTF8-safe wordwrap method: works like the regular wordwrap
1059
+     * PHP function but compatible with UTF8. Otherwise the lengths
1060
+     * are not calculated correctly.
1061
+     * 
1062
+     * @param string $str
1063
+     * @param int $width
1064
+     * @param string $break
1065
+     * @param bool $cut
1066
+     * @return string
1067
+     */
1068 1068
     public static function wordwrap(string $str, int $width = 75, string $break = "\n", bool $cut = false) : string 
1069 1069
     {
1070 1070
         return ConvertHelper_String::wordwrap($str, $width, $break, $cut);
1071 1071
     }
1072 1072
     
1073
-   /**
1074
-    * Calculates the byte length of a string, taking into 
1075
-    * account any unicode characters.
1076
-    * 
1077
-    * @param string $string
1078
-    * @return int
1079
-    */
1073
+    /**
1074
+     * Calculates the byte length of a string, taking into 
1075
+     * account any unicode characters.
1076
+     * 
1077
+     * @param string $string
1078
+     * @return int
1079
+     */
1080 1080
     public static function string2bytes(string $string): int
1081 1081
     {
1082 1082
         return ConvertHelper_String::toBytes($string);
1083 1083
     }
1084 1084
     
1085
-   /**
1086
-    * Creates a short, 8-character long hash for the specified string.
1087
-    * 
1088
-    * WARNING: Not cryptographically safe.
1089
-    * 
1090
-    * @param string $string
1091
-    * @return string
1092
-    */
1085
+    /**
1086
+     * Creates a short, 8-character long hash for the specified string.
1087
+     * 
1088
+     * WARNING: Not cryptographically safe.
1089
+     * 
1090
+     * @param string $string
1091
+     * @return string
1092
+     */
1093 1093
     public static function string2shortHash(string $string) : string
1094 1094
     {
1095 1095
         return ConvertHelper_String::toShortHash($string);
@@ -1135,88 +1135,88 @@  discard block
 block discarded – undo
1135 1135
         return ConvertHelper_ThrowableInfo::fromThrowable($e);
1136 1136
     }
1137 1137
     
1138
-   /**
1139
-    * Parses the specified query string like the native 
1140
-    * function <code>parse_str</code>, without the key
1141
-    * naming limitations.
1142
-    * 
1143
-    * Using parse_str, dots or spaces in key names are 
1144
-    * replaced by underscores. This method keeps all names
1145
-    * intact.
1146
-    * 
1147
-    * It still uses the parse_str implementation as it 
1148
-    * is tested and tried, but fixes the parameter names
1149
-    * after parsing, as needed.
1150
-    * 
1151
-    * @param string $queryString
1152
-    * @return array
1153
-    * @see ConvertHelper_QueryParser
1154
-    */
1138
+    /**
1139
+     * Parses the specified query string like the native 
1140
+     * function <code>parse_str</code>, without the key
1141
+     * naming limitations.
1142
+     * 
1143
+     * Using parse_str, dots or spaces in key names are 
1144
+     * replaced by underscores. This method keeps all names
1145
+     * intact.
1146
+     * 
1147
+     * It still uses the parse_str implementation as it 
1148
+     * is tested and tried, but fixes the parameter names
1149
+     * after parsing, as needed.
1150
+     * 
1151
+     * @param string $queryString
1152
+     * @return array
1153
+     * @see ConvertHelper_QueryParser
1154
+     */
1155 1155
     public static function parseQueryString(string $queryString) : array
1156 1156
     {
1157 1157
         $parser = new ConvertHelper_QueryParser();
1158 1158
         return $parser->parse($queryString);
1159 1159
     }
1160 1160
 
1161
-   /**
1162
-    * Searches for needle in the specified string, and returns a list
1163
-    * of all occurrences, including the matched string. The matched 
1164
-    * string is useful when doing a case insensitive search, as it 
1165
-    * shows the exact matched case of needle.
1166
-    *   
1167
-    * @param string $needle
1168
-    * @param string $haystack
1169
-    * @param bool $caseInsensitive
1170
-    * @return ConvertHelper_StringMatch[]
1171
-    */
1161
+    /**
1162
+     * Searches for needle in the specified string, and returns a list
1163
+     * of all occurrences, including the matched string. The matched 
1164
+     * string is useful when doing a case insensitive search, as it 
1165
+     * shows the exact matched case of needle.
1166
+     *   
1167
+     * @param string $needle
1168
+     * @param string $haystack
1169
+     * @param bool $caseInsensitive
1170
+     * @return ConvertHelper_StringMatch[]
1171
+     */
1172 1172
     public static function findString(string $needle, string $haystack, bool $caseInsensitive=false): array
1173 1173
     {
1174 1174
         return ConvertHelper_String::findString($needle, $haystack, $caseInsensitive);
1175 1175
     }
1176 1176
     
1177
-   /**
1178
-    * Like explode, but trims all entries, and removes 
1179
-    * empty entries from the resulting array.
1180
-    * 
1181
-    * @param string $delimiter
1182
-    * @param string $string
1183
-    * @return string[]
1184
-    */
1177
+    /**
1178
+     * Like explode, but trims all entries, and removes 
1179
+     * empty entries from the resulting array.
1180
+     * 
1181
+     * @param string $delimiter
1182
+     * @param string $string
1183
+     * @return string[]
1184
+     */
1185 1185
     public static function explodeTrim(string $delimiter, string $string) : array
1186 1186
     {
1187 1187
         return ConvertHelper_String::explodeTrim($delimiter, $string);
1188 1188
     }
1189 1189
     
1190
-   /**
1191
-    * Detects the most used end-of-line character in the subject string.
1192
-    * 
1193
-    * @param string $subjectString The string to check.
1194
-    * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected.
1195
-    */
1190
+    /**
1191
+     * Detects the most used end-of-line character in the subject string.
1192
+     * 
1193
+     * @param string $subjectString The string to check.
1194
+     * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected.
1195
+     */
1196 1196
     public static function detectEOLCharacter(string $subjectString) : ?ConvertHelper_EOL
1197 1197
     {
1198 1198
         return ConvertHelper_EOL::detect($subjectString);
1199 1199
     }
1200 1200
 
1201
-   /**
1202
-    * Removes the specified keys from the target array,
1203
-    * if they exist.
1204
-    * 
1205
-    * @param array $array
1206
-    * @param array $keys
1207
-    */
1201
+    /**
1202
+     * Removes the specified keys from the target array,
1203
+     * if they exist.
1204
+     * 
1205
+     * @param array $array
1206
+     * @param array $keys
1207
+     */
1208 1208
     public static function arrayRemoveKeys(array &$array, array $keys) : void
1209 1209
     {
1210 1210
         ConvertHelper_Array::removeKeys($array, $keys);
1211 1211
     }
1212 1212
     
1213
-   /**
1214
-    * Checks if the specified variable is an integer or a string containing an integer.
1215
-    * Accepts both positive and negative integers.
1216
-    * 
1217
-    * @param mixed $value
1218
-    * @return bool
1219
-    */
1213
+    /**
1214
+     * Checks if the specified variable is an integer or a string containing an integer.
1215
+     * Accepts both positive and negative integers.
1216
+     * 
1217
+     * @param mixed $value
1218
+     * @return bool
1219
+     */
1220 1220
     public static function isInteger($value) : bool
1221 1221
     {
1222 1222
         if(is_int($value)) {
@@ -1236,52 +1236,52 @@  discard block
 block discarded – undo
1236 1236
         return false;    
1237 1237
     }
1238 1238
     
1239
-   /**
1240
-    * Converts an amount of seconds to a DateInterval object.
1241
-    * 
1242
-    * @param int $seconds
1243
-    * @return \DateInterval
1244
-    * @throws ConvertHelper_Exception If the date interval cannot be created.
1245
-    * 
1246
-    * @see ConvertHelper::ERROR_CANNOT_GET_DATE_DIFF
1247
-    */
1239
+    /**
1240
+     * Converts an amount of seconds to a DateInterval object.
1241
+     * 
1242
+     * @param int $seconds
1243
+     * @return \DateInterval
1244
+     * @throws ConvertHelper_Exception If the date interval cannot be created.
1245
+     * 
1246
+     * @see ConvertHelper::ERROR_CANNOT_GET_DATE_DIFF
1247
+     */
1248 1248
     public static function seconds2interval(int $seconds) : \DateInterval
1249 1249
     {
1250 1250
         return ConvertHelper_DateInterval::fromSeconds($seconds)->getInterval();
1251 1251
     }
1252 1252
     
1253
-   /**
1254
-    * Converts a size string like "50 MB" to the corresponding byte size.
1255
-    * It is case insensitive, ignores spaces, and supports both traditional
1256
-    * "MB" and "MiB" notations.
1257
-    * 
1258
-    * @param string $size
1259
-    * @return int
1260
-    */
1253
+    /**
1254
+     * Converts a size string like "50 MB" to the corresponding byte size.
1255
+     * It is case insensitive, ignores spaces, and supports both traditional
1256
+     * "MB" and "MiB" notations.
1257
+     * 
1258
+     * @param string $size
1259
+     * @return int
1260
+     */
1261 1261
     public static function size2bytes(string $size) : int
1262 1262
     {
1263 1263
         return self::parseSize($size)->toBytes();
1264 1264
     }
1265 1265
     
1266
-   /**
1267
-    * Parses a size string like "50 MB" and returns a size notation instance
1268
-    * that has utility methods to access information on it, and convert it.
1269
-    * 
1270
-    * @param string $size
1271
-    * @return ConvertHelper_SizeNotation
1272
-    */
1266
+    /**
1267
+     * Parses a size string like "50 MB" and returns a size notation instance
1268
+     * that has utility methods to access information on it, and convert it.
1269
+     * 
1270
+     * @param string $size
1271
+     * @return ConvertHelper_SizeNotation
1272
+     */
1273 1273
     public static function parseSize(string $size) : ConvertHelper_SizeNotation
1274 1274
     {
1275 1275
         return new ConvertHelper_SizeNotation($size);
1276 1276
     }
1277 1277
     
1278
-   /**
1279
-    * Creates a URL finder instance, which can be used to find
1280
-    * URLs in a string - be it plain text, or HTML.
1281
-    * 
1282
-    * @param string $subject
1283
-    * @return ConvertHelper_URLFinder
1284
-    */
1278
+    /**
1279
+     * Creates a URL finder instance, which can be used to find
1280
+     * URLs in a string - be it plain text, or HTML.
1281
+     * 
1282
+     * @param string $subject
1283
+     * @return ConvertHelper_URLFinder
1284
+     */
1285 1285
     public static function createURLFinder(string $subject) : ConvertHelper_URLFinder
1286 1286
     {
1287 1287
         return new ConvertHelper_URLFinder($subject);
Please login to merge, or discard this patch.