Passed
Pull Request — master (#2)
by
unknown
03:40
created
src/ConvertHelper.php 1 patch
Indentation   +497 added lines, -497 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);
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 
319 319
         $labelHtml = '<span title="'.$date->format('d.m.Y H:i:s').'">'.
320 320
                         trim($label).
321
-                     '</span>';
321
+                        '</span>';
322 322
 
323 323
         return $labelHtml;
324 324
     }
@@ -383,36 +383,36 @@  discard block
 block discarded – undo
383 383
         return ConvertHelper_String::transliterate($string, $spaceChar, $lowercase);
384 384
     }
385 385
     
386
-   /**
387
-    * Retrieves the HEX character codes for all control
388
-    * characters that the {@link stripControlCharacters()} 
389
-    * method will remove.
390
-    * 
391
-    * @return string[]
392
-    */
386
+    /**
387
+     * Retrieves the HEX character codes for all control
388
+     * characters that the {@link stripControlCharacters()} 
389
+     * method will remove.
390
+     * 
391
+     * @return string[]
392
+     */
393 393
     public static function getControlCharactersAsHex()
394 394
     {
395 395
         return self::createControlCharacters()->getCharsAsHex();
396 396
     }
397 397
     
398
-   /**
399
-    * Retrieves an array of all control characters that
400
-    * the {@link stripControlCharacters()} method will 
401
-    * remove, as the actual UTF-8 characters.
402
-    * 
403
-    * @return string[]
404
-    */
398
+    /**
399
+     * Retrieves an array of all control characters that
400
+     * the {@link stripControlCharacters()} method will 
401
+     * remove, as the actual UTF-8 characters.
402
+     * 
403
+     * @return string[]
404
+     */
405 405
     public static function getControlCharactersAsUTF8()
406 406
     {
407 407
         return self::createControlCharacters()->getCharsAsUTF8();
408 408
     }
409 409
     
410
-   /**
411
-    * Retrieves all control characters as JSON encoded
412
-    * characters, e.g. "\u200b".
413
-    * 
414
-    * @return string[]
415
-    */
410
+    /**
411
+     * Retrieves all control characters as JSON encoded
412
+     * characters, e.g. "\u200b".
413
+     * 
414
+     * @return string[]
415
+     */
416 416
     public static function getControlCharactersAsJSON()
417 417
     {
418 418
         return self::createControlCharacters()->getCharsAsJSON();
@@ -433,31 +433,31 @@  discard block
 block discarded – undo
433 433
         return self::createControlCharacters()->stripControlCharacters($string);
434 434
     }
435 435
     
436
-   /**
437
-    * Creates the control characters class, used to 
438
-    * work with control characters in strings.
439
-    * 
440
-    * @return ConvertHelper_ControlCharacters
441
-    */
436
+    /**
437
+     * Creates the control characters class, used to 
438
+     * work with control characters in strings.
439
+     * 
440
+     * @return ConvertHelper_ControlCharacters
441
+     */
442 442
     public static function createControlCharacters() : ConvertHelper_ControlCharacters
443 443
     {
444 444
         return new ConvertHelper_ControlCharacters();
445 445
     }
446 446
 
447
-   /**
448
-    * Converts a unicode character to the PHPO notation.
449
-    * 
450
-    * Example:
451
-    * 
452
-    * <pre>unicodeChar2php('"\u0000"')</pre>
453
-    * 
454
-    * Returns
455
-    * 
456
-    * <pre>\x0</pre>
457
-    * 
458
-    * @param string $unicodeChar
459
-    * @return string
460
-    */
447
+    /**
448
+     * Converts a unicode character to the PHPO notation.
449
+     * 
450
+     * Example:
451
+     * 
452
+     * <pre>unicodeChar2php('"\u0000"')</pre>
453
+     * 
454
+     * Returns
455
+     * 
456
+     * <pre>\x0</pre>
457
+     * 
458
+     * @param string $unicodeChar
459
+     * @return string
460
+     */
461 461
     public static function unicodeChar2php(string $unicodeChar) : string 
462 462
     {
463 463
         $unicodeChar = json_decode($unicodeChar);
@@ -567,87 +567,87 @@  discard block
 block discarded – undo
567 567
         return ConvertHelper_Bool::toString($boolean, $yesno);
568 568
     }
569 569
     
570
-   /**
571
-    * Converts an associative array with attribute name > value pairs
572
-    * to an attribute string that can be used in an HTML tag. Empty 
573
-    * attribute values are ignored.
574
-    * 
575
-    * Example:
576
-    * 
577
-    * array2attributeString(array(
578
-    *     'id' => 45,
579
-    *     'href' => 'http://www.mistralys.com'
580
-    * ));
581
-    * 
582
-    * Result:
583
-    * 
584
-    * id="45" href="http://www.mistralys.com"
585
-    * 
586
-    * @param array<string,mixed> $array
587
-    * @return string
588
-    */
570
+    /**
571
+     * Converts an associative array with attribute name > value pairs
572
+     * to an attribute string that can be used in an HTML tag. Empty 
573
+     * attribute values are ignored.
574
+     * 
575
+     * Example:
576
+     * 
577
+     * array2attributeString(array(
578
+     *     'id' => 45,
579
+     *     'href' => 'http://www.mistralys.com'
580
+     * ));
581
+     * 
582
+     * Result:
583
+     * 
584
+     * id="45" href="http://www.mistralys.com"
585
+     * 
586
+     * @param array<string,mixed> $array
587
+     * @return string
588
+     */
589 589
     public static function array2attributeString(array $array) : string
590 590
     {
591 591
         return ConvertHelper_Array::toAttributeString($array);
592 592
     }
593 593
     
594
-   /**
595
-    * Converts a string so it can safely be used in a javascript
596
-    * statement in an HTML tag: uses single quotes around the string
597
-    * and encodes all special characters as needed.
598
-    * 
599
-    * @param string $string
600
-    * @return string
601
-    * @deprecated Use the JSHelper class instead.
602
-    * @see JSHelper::phpVariable2AttributeJS()
603
-    */
594
+    /**
595
+     * Converts a string so it can safely be used in a javascript
596
+     * statement in an HTML tag: uses single quotes around the string
597
+     * and encodes all special characters as needed.
598
+     * 
599
+     * @param string $string
600
+     * @return string
601
+     * @deprecated Use the JSHelper class instead.
602
+     * @see JSHelper::phpVariable2AttributeJS()
603
+     */
604 604
     public static function string2attributeJS(string $string) : string
605 605
     {
606 606
         return JSHelper::phpVariable2AttributeJS($string);
607 607
     }
608 608
     
609
-   /**
610
-    * Checks if the specified string is a boolean value, which
611
-    * includes string representations of boolean values, like 
612
-    * <code>yes</code> or <code>no</code>, and <code>true</code>
613
-    * or <code>false</code>.
614
-    * 
615
-    * @param mixed $value
616
-    * @return boolean
617
-    */
609
+    /**
610
+     * Checks if the specified string is a boolean value, which
611
+     * includes string representations of boolean values, like 
612
+     * <code>yes</code> or <code>no</code>, and <code>true</code>
613
+     * or <code>false</code>.
614
+     * 
615
+     * @param mixed $value
616
+     * @return boolean
617
+     */
618 618
     public static function isBoolean($value) : bool
619 619
     {
620 620
         return ConvertHelper_Bool::isBoolean($value);
621 621
     }
622 622
     
623
-   /**
624
-    * Converts an associative array to an HTML style attribute value string.
625
-    * 
626
-    * @param array<string,mixed> $subject
627
-    * @return string
628
-    */
623
+    /**
624
+     * Converts an associative array to an HTML style attribute value string.
625
+     * 
626
+     * @param array<string,mixed> $subject
627
+     * @return string
628
+     */
629 629
     public static function array2styleString(array $subject) : string
630 630
     {
631 631
         return ConvertHelper_Array::toStyleString($subject);
632 632
     }
633 633
     
634
-   /**
635
-    * Converts a DateTime object to a timestamp, which
636
-    * is PHP 5.2 compatible.
637
-    * 
638
-    * @param DateTime $date
639
-    * @return integer
640
-    */
634
+    /**
635
+     * Converts a DateTime object to a timestamp, which
636
+     * is PHP 5.2 compatible.
637
+     * 
638
+     * @param DateTime $date
639
+     * @return integer
640
+     */
641 641
     public static function date2timestamp(DateTime $date) : int
642 642
     {
643 643
         return (int)$date->format('U');
644 644
     }
645 645
     
646
-   /**
647
-    * Converts a timestamp into a DateTime instance.
648
-    * @param int $timestamp
649
-    * @return DateTime
650
-    */
646
+    /**
647
+     * Converts a timestamp into a DateTime instance.
648
+     * @param int $timestamp
649
+     * @return DateTime
650
+     */
651 651
     public static function timestamp2date(int $timestamp) : DateTime
652 652
     {
653 653
         $date = new DateTime();
@@ -655,50 +655,50 @@  discard block
 block discarded – undo
655 655
         return $date;
656 656
     }
657 657
     
658
-   /**
659
-    * Strips an absolute path to a file within the application
660
-    * to make the path relative to the application root path.
661
-    * 
662
-    * @param string $path
663
-    * @return string
664
-    * 
665
-    * @see FileHelper::relativizePath()
666
-    * @see FileHelper::relativizePathByDepth()
667
-    */
658
+    /**
659
+     * Strips an absolute path to a file within the application
660
+     * to make the path relative to the application root path.
661
+     * 
662
+     * @param string $path
663
+     * @return string
664
+     * 
665
+     * @see FileHelper::relativizePath()
666
+     * @see FileHelper::relativizePathByDepth()
667
+     */
668 668
     public static function fileRelativize(string $path) : string
669 669
     {
670 670
         return FileHelper::relativizePathByDepth($path);
671 671
     }
672 672
     
673 673
     /**
674
-    * Converts a PHP regex to a javascript RegExp object statement.
675
-    * 
676
-    * NOTE: This is an alias for the JSHelper's `convertRegex` method. 
677
-    * More details are available on its usage there.
678
-    *
679
-    * @param string $regex A PHP preg regex
680
-    * @param string $statementType The type of statement to return: Defaults to a statement to create a RegExp object.
681
-    * @return array|string Depending on the specified return type.
682
-    * 
683
-    * @see JSHelper::buildRegexStatement()
684
-    */
674
+     * Converts a PHP regex to a javascript RegExp object statement.
675
+     * 
676
+     * NOTE: This is an alias for the JSHelper's `convertRegex` method. 
677
+     * More details are available on its usage there.
678
+     *
679
+     * @param string $regex A PHP preg regex
680
+     * @param string $statementType The type of statement to return: Defaults to a statement to create a RegExp object.
681
+     * @return array|string Depending on the specified return type.
682
+     * 
683
+     * @see JSHelper::buildRegexStatement()
684
+     */
685 685
     public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT)
686 686
     {
687 687
         return JSHelper::buildRegexStatement($regex, $statementType);
688 688
     }
689 689
     
690
-   /**
691
-    * Converts the specified variable to JSON. Works just
692
-    * like the native `json_encode` method, except that it
693
-    * will trigger an exception on failure, which has the 
694
-    * json error details included in its developer details.
695
-    * 
696
-    * @param mixed $variable
697
-    * @param int $options JSON encode options.
698
-    * @param int $depth 
699
-    * @throws ConvertHelper_Exception
700
-    * @return string
701
-    */
690
+    /**
691
+     * Converts the specified variable to JSON. Works just
692
+     * like the native `json_encode` method, except that it
693
+     * will trigger an exception on failure, which has the 
694
+     * json error details included in its developer details.
695
+     * 
696
+     * @param mixed $variable
697
+     * @param int $options JSON encode options.
698
+     * @param int $depth 
699
+     * @throws ConvertHelper_Exception
700
+     * @return string
701
+     */
702 702
     public static function var2json($variable, int $options=0, int $depth=512) : string
703 703
     {
704 704
         $result = json_encode($variable, $options, $depth);
@@ -733,12 +733,12 @@  discard block
 block discarded – undo
733 733
             ->toString();
734 734
     }
735 735
     
736
-   /**
737
-    * Strips all known UTF byte order marks from the specified string.
738
-    * 
739
-    * @param string $string
740
-    * @return string
741
-    */
736
+    /**
737
+     * Strips all known UTF byte order marks from the specified string.
738
+     * 
739
+     * @param string $string
740
+     * @return string
741
+     */
742 742
     public static function stripUTFBom($string)
743 743
     {
744 744
         $boms = FileHelper::getUTFBOMs();
@@ -753,65 +753,65 @@  discard block
 block discarded – undo
753 753
         return $string;
754 754
     }
755 755
 
756
-   /**
757
-    * Converts a string to valid utf8, regardless
758
-    * of the string's encoding(s).
759
-    * 
760
-    * @param string $string
761
-    * @return string
762
-    */
756
+    /**
757
+     * Converts a string to valid utf8, regardless
758
+     * of the string's encoding(s).
759
+     * 
760
+     * @param string $string
761
+     * @return string
762
+     */
763 763
     public static function string2utf8(string $string) : string
764 764
     {
765 765
         return ConvertHelper_String::toUtf8($string);
766 766
     }
767 767
     
768
-   /**
769
-    * Checks whether the specified string is an ASCII
770
-    * string, without any special or UTF8 characters.
771
-    * Note: empty strings and NULL are considered ASCII.
772
-    * Any variable types other than strings are not.
773
-    * 
774
-    * @param string|float|int|NULL $string
775
-    * @return boolean
776
-    */
768
+    /**
769
+     * Checks whether the specified string is an ASCII
770
+     * string, without any special or UTF8 characters.
771
+     * Note: empty strings and NULL are considered ASCII.
772
+     * Any variable types other than strings are not.
773
+     * 
774
+     * @param string|float|int|NULL $string
775
+     * @return boolean
776
+     */
777 777
     public static function isStringASCII($string) : bool
778 778
     {
779 779
         return ConvertHelper_String::isASCII(strval($string));
780 780
     }
781 781
     
782
-   /**
783
-    * Adds HTML syntax highlighting to an URL.
784
-    * 
785
-    * NOTE: Includes the necessary CSS styles. When
786
-    * highlighting several URLs in the same page,
787
-    * prefer using the `parseURL` function instead.
788
-    * 
789
-    * @param string $url
790
-    * @return string
791
-    * @deprecated Use the Highlighter class directly instead.
792
-    * @see Highlighter
793
-    */
782
+    /**
783
+     * Adds HTML syntax highlighting to an URL.
784
+     * 
785
+     * NOTE: Includes the necessary CSS styles. When
786
+     * highlighting several URLs in the same page,
787
+     * prefer using the `parseURL` function instead.
788
+     * 
789
+     * @param string $url
790
+     * @return string
791
+     * @deprecated Use the Highlighter class directly instead.
792
+     * @see Highlighter
793
+     */
794 794
     public static function highlight_url(string $url) : string
795 795
     {
796 796
         return Highlighter::url($url);
797 797
     }
798 798
 
799
-   /**
800
-    * Calculates a percentage match of the source string with the target string.
801
-    * 
802
-    * Options are:
803
-    * 
804
-    * - maxLevenshtein, default: 10
805
-    *   Any levenshtein results above this value are ignored.
806
-    *   
807
-    * - precision, default: 1
808
-    *   The precision of the percentage float value
809
-    * 
810
-    * @param string $source
811
-    * @param string $target
812
-    * @param array $options
813
-    * @return float
814
-    */
799
+    /**
800
+     * Calculates a percentage match of the source string with the target string.
801
+     * 
802
+     * Options are:
803
+     * 
804
+     * - maxLevenshtein, default: 10
805
+     *   Any levenshtein results above this value are ignored.
806
+     *   
807
+     * - precision, default: 1
808
+     *   The precision of the percentage float value
809
+     * 
810
+     * @param string $source
811
+     * @param string $target
812
+     * @param array $options
813
+     * @return float
814
+     */
815 815
     public static function matchString($source, $target, $options=array())
816 816
     {
817 817
         $defaults = array(
@@ -835,14 +835,14 @@  discard block
 block discarded – undo
835 835
         return round(100 - $percent, $options['precision']);
836 836
     }
837 837
     
838
-   /**
839
-    * Converts a date interval to a human readable string with
840
-    * all necessary time components, e.g. "1 year, 2 months and 4 days".
841
-    * 
842
-    * @param \DateInterval $interval
843
-    * @return string
844
-    * @see ConvertHelper_IntervalConverter
845
-    */
838
+    /**
839
+     * Converts a date interval to a human readable string with
840
+     * all necessary time components, e.g. "1 year, 2 months and 4 days".
841
+     * 
842
+     * @param \DateInterval $interval
843
+     * @return string
844
+     * @see ConvertHelper_IntervalConverter
845
+     */
846 846
     public static function interval2string(\DateInterval $interval) : string
847 847
     {
848 848
         $converter = new ConvertHelper_IntervalConverter();
@@ -857,60 +857,60 @@  discard block
 block discarded – undo
857 857
     
858 858
     const INTERVAL_SECONDS = 'seconds';
859 859
     
860
-   /**
861
-    * Converts an interval to its total amount of days.
862
-    * @param \DateInterval $interval
863
-    * @return int
864
-    */
860
+    /**
861
+     * Converts an interval to its total amount of days.
862
+     * @param \DateInterval $interval
863
+     * @return int
864
+     */
865 865
     public static function interval2days(\DateInterval $interval) : int
866 866
     {
867 867
         return self::interval2total($interval, self::INTERVAL_DAYS);
868 868
     }
869 869
 
870
-   /**
871
-    * Converts an interval to its total amount of hours.
872
-    * @param \DateInterval $interval
873
-    * @return int
874
-    */
870
+    /**
871
+     * Converts an interval to its total amount of hours.
872
+     * @param \DateInterval $interval
873
+     * @return int
874
+     */
875 875
     public static function interval2hours(\DateInterval $interval) : int
876 876
     {
877 877
         return self::interval2total($interval, self::INTERVAL_HOURS);
878 878
     }
879 879
     
880
-   /**
881
-    * Converts an interval to its total amount of minutes. 
882
-    * @param \DateInterval $interval
883
-    * @return int
884
-    */
880
+    /**
881
+     * Converts an interval to its total amount of minutes. 
882
+     * @param \DateInterval $interval
883
+     * @return int
884
+     */
885 885
     public static function interval2minutes(\DateInterval $interval) : int
886 886
     {
887 887
         return self::interval2total($interval, self::INTERVAL_MINUTES);
888 888
     }
889 889
     
890
-   /**
891
-    * Converts an interval to its total amount of seconds.
892
-    * @param \DateInterval $interval
893
-    * @return int
894
-    */    
890
+    /**
891
+     * Converts an interval to its total amount of seconds.
892
+     * @param \DateInterval $interval
893
+     * @return int
894
+     */    
895 895
     public static function interval2seconds(\DateInterval $interval) : int
896 896
     {
897 897
         return self::interval2total($interval, self::INTERVAL_SECONDS);
898 898
     }
899 899
     
900
-   /**
901
-    * Calculates the total amount of days / hours / minutes or seconds
902
-    * of a date interval object (depending in the specified units), and 
903
-    * returns the total amount.
904
-    * 
905
-    * @param \DateInterval $interval
906
-    * @param string $unit What total value to calculate.
907
-    * @return integer
908
-    * 
909
-    * @see ConvertHelper::INTERVAL_SECONDS
910
-    * @see ConvertHelper::INTERVAL_MINUTES
911
-    * @see ConvertHelper::INTERVAL_HOURS
912
-    * @see ConvertHelper::INTERVAL_DAYS
913
-    */
900
+    /**
901
+     * Calculates the total amount of days / hours / minutes or seconds
902
+     * of a date interval object (depending in the specified units), and 
903
+     * returns the total amount.
904
+     * 
905
+     * @param \DateInterval $interval
906
+     * @param string $unit What total value to calculate.
907
+     * @return integer
908
+     * 
909
+     * @see ConvertHelper::INTERVAL_SECONDS
910
+     * @see ConvertHelper::INTERVAL_MINUTES
911
+     * @see ConvertHelper::INTERVAL_HOURS
912
+     * @see ConvertHelper::INTERVAL_DAYS
913
+     */
914 914
     public static function interval2total(\DateInterval $interval, $unit=self::INTERVAL_SECONDS) : int
915 915
     {
916 916
         $total = (int)$interval->format('%a');
@@ -950,13 +950,13 @@  discard block
 block discarded – undo
950 950
         'Sunday'
951 951
     );
952 952
     
953
-   /**
954
-    * Converts a date to the corresponding day name.
955
-    * 
956
-    * @param DateTime $date
957
-    * @param bool $short
958
-    * @return string|NULL
959
-    */
953
+    /**
954
+     * Converts a date to the corresponding day name.
955
+     * 
956
+     * @param DateTime $date
957
+     * @param bool $short
958
+     * @return string|NULL
959
+     */
960 960
     public static function date2dayName(DateTime $date, bool $short=false)
961 961
     {
962 962
         $day = $date->format('l');
@@ -971,21 +971,21 @@  discard block
 block discarded – undo
971 971
         return null;
972 972
     }
973 973
     
974
-   /**
975
-    * Retrieves a list of english day names.
976
-    * @return string[]
977
-    */
974
+    /**
975
+     * Retrieves a list of english day names.
976
+     * @return string[]
977
+     */
978 978
     public static function getDayNamesInvariant()
979 979
     {
980 980
         return self::$daysInvariant;
981 981
     }
982 982
     
983
-   /**
984
-    * Retrieves the day names list for the current locale.
985
-    * 
986
-    * @param bool $short
987
-    * @return array
988
-    */
983
+    /**
984
+     * Retrieves the day names list for the current locale.
985
+     * 
986
+     * @param bool $short
987
+     * @return array
988
+     */
989 989
     public static function getDayNames(bool $short=false) : array
990 990
     {
991 991
         if($short) {
@@ -1032,68 +1032,68 @@  discard block
 block discarded – undo
1032 1032
         return ConvertHelper_Array::implodeWithAnd($list, $sep, $conjunction);
1033 1033
     }
1034 1034
     
1035
-   /**
1036
-    * Splits a string into an array of all characters it is composed of.
1037
-    * Unicode character safe.
1038
-    * 
1039
-    * NOTE: Spaces and newlines (both \r and \n) are also considered single
1040
-    * characters.
1041
-    * 
1042
-    * @param string $string
1043
-    * @return string[]
1044
-    */
1035
+    /**
1036
+     * Splits a string into an array of all characters it is composed of.
1037
+     * Unicode character safe.
1038
+     * 
1039
+     * NOTE: Spaces and newlines (both \r and \n) are also considered single
1040
+     * characters.
1041
+     * 
1042
+     * @param string $string
1043
+     * @return string[]
1044
+     */
1045 1045
     public static function string2array(string $string) : array
1046 1046
     {
1047 1047
         return ConvertHelper_String::toArray($string);
1048 1048
     }
1049 1049
     
1050
-   /**
1051
-    * Checks whether the specified string contains HTML code.
1052
-    * 
1053
-    * @param string $string
1054
-    * @return boolean
1055
-    */
1050
+    /**
1051
+     * Checks whether the specified string contains HTML code.
1052
+     * 
1053
+     * @param string $string
1054
+     * @return boolean
1055
+     */
1056 1056
     public static function isStringHTML(string $string) : bool
1057 1057
     {
1058 1058
         return ConvertHelper_String::isHTML($string);
1059 1059
     }
1060 1060
     
1061
-   /**
1062
-    * UTF8-safe wordwrap method: works like the regular wordwrap
1063
-    * PHP function but compatible with UTF8. Otherwise the lengths
1064
-    * are not calculated correctly.
1065
-    * 
1066
-    * @param string $str
1067
-    * @param int $width
1068
-    * @param string $break
1069
-    * @param bool $cut
1070
-    * @return string
1071
-    */
1061
+    /**
1062
+     * UTF8-safe wordwrap method: works like the regular wordwrap
1063
+     * PHP function but compatible with UTF8. Otherwise the lengths
1064
+     * are not calculated correctly.
1065
+     * 
1066
+     * @param string $str
1067
+     * @param int $width
1068
+     * @param string $break
1069
+     * @param bool $cut
1070
+     * @return string
1071
+     */
1072 1072
     public static function wordwrap(string $str, int $width = 75, string $break = "\n", bool $cut = false) : string 
1073 1073
     {
1074 1074
         return ConvertHelper_String::wordwrap($str, $width, $break, $cut);
1075 1075
     }
1076 1076
     
1077
-   /**
1078
-    * Calculates the byte length of a string, taking into 
1079
-    * account any unicode characters.
1080
-    * 
1081
-    * @param string $string
1082
-    * @return int
1083
-    */
1077
+    /**
1078
+     * Calculates the byte length of a string, taking into 
1079
+     * account any unicode characters.
1080
+     * 
1081
+     * @param string $string
1082
+     * @return int
1083
+     */
1084 1084
     public static function string2bytes(string $string): int
1085 1085
     {
1086 1086
         return ConvertHelper_String::toBytes($string);
1087 1087
     }
1088 1088
     
1089
-   /**
1090
-    * Creates a short, 8-character long hash for the specified string.
1091
-    * 
1092
-    * WARNING: Not cryptographically safe.
1093
-    * 
1094
-    * @param string $string
1095
-    * @return string
1096
-    */
1089
+    /**
1090
+     * Creates a short, 8-character long hash for the specified string.
1091
+     * 
1092
+     * WARNING: Not cryptographically safe.
1093
+     * 
1094
+     * @param string $string
1095
+     * @return string
1096
+     */
1097 1097
     public static function string2shortHash(string $string) : string
1098 1098
     {
1099 1099
         return ConvertHelper_String::toShortHash($string);
@@ -1139,88 +1139,88 @@  discard block
 block discarded – undo
1139 1139
         return ConvertHelper_ThrowableInfo::fromThrowable($e);
1140 1140
     }
1141 1141
     
1142
-   /**
1143
-    * Parses the specified query string like the native 
1144
-    * function <code>parse_str</code>, without the key
1145
-    * naming limitations.
1146
-    * 
1147
-    * Using parse_str, dots or spaces in key names are 
1148
-    * replaced by underscores. This method keeps all names
1149
-    * intact.
1150
-    * 
1151
-    * It still uses the parse_str implementation as it 
1152
-    * is tested and tried, but fixes the parameter names
1153
-    * after parsing, as needed.
1154
-    * 
1155
-    * @param string $queryString
1156
-    * @return array
1157
-    * @see ConvertHelper_QueryParser
1158
-    */
1142
+    /**
1143
+     * Parses the specified query string like the native 
1144
+     * function <code>parse_str</code>, without the key
1145
+     * naming limitations.
1146
+     * 
1147
+     * Using parse_str, dots or spaces in key names are 
1148
+     * replaced by underscores. This method keeps all names
1149
+     * intact.
1150
+     * 
1151
+     * It still uses the parse_str implementation as it 
1152
+     * is tested and tried, but fixes the parameter names
1153
+     * after parsing, as needed.
1154
+     * 
1155
+     * @param string $queryString
1156
+     * @return array
1157
+     * @see ConvertHelper_QueryParser
1158
+     */
1159 1159
     public static function parseQueryString(string $queryString) : array
1160 1160
     {
1161 1161
         $parser = new ConvertHelper_QueryParser();
1162 1162
         return $parser->parse($queryString);
1163 1163
     }
1164 1164
 
1165
-   /**
1166
-    * Searches for needle in the specified string, and returns a list
1167
-    * of all occurrences, including the matched string. The matched 
1168
-    * string is useful when doing a case insensitive search, as it 
1169
-    * shows the exact matched case of needle.
1170
-    *   
1171
-    * @param string $needle
1172
-    * @param string $haystack
1173
-    * @param bool $caseInsensitive
1174
-    * @return ConvertHelper_StringMatch[]
1175
-    */
1165
+    /**
1166
+     * Searches for needle in the specified string, and returns a list
1167
+     * of all occurrences, including the matched string. The matched 
1168
+     * string is useful when doing a case insensitive search, as it 
1169
+     * shows the exact matched case of needle.
1170
+     *   
1171
+     * @param string $needle
1172
+     * @param string $haystack
1173
+     * @param bool $caseInsensitive
1174
+     * @return ConvertHelper_StringMatch[]
1175
+     */
1176 1176
     public static function findString(string $needle, string $haystack, bool $caseInsensitive=false): array
1177 1177
     {
1178 1178
         return ConvertHelper_String::findString($needle, $haystack, $caseInsensitive);
1179 1179
     }
1180 1180
     
1181
-   /**
1182
-    * Like explode, but trims all entries, and removes 
1183
-    * empty entries from the resulting array.
1184
-    * 
1185
-    * @param string $delimiter
1186
-    * @param string $string
1187
-    * @return string[]
1188
-    */
1181
+    /**
1182
+     * Like explode, but trims all entries, and removes 
1183
+     * empty entries from the resulting array.
1184
+     * 
1185
+     * @param string $delimiter
1186
+     * @param string $string
1187
+     * @return string[]
1188
+     */
1189 1189
     public static function explodeTrim(string $delimiter, string $string) : array
1190 1190
     {
1191 1191
         return ConvertHelper_String::explodeTrim($delimiter, $string);
1192 1192
     }
1193 1193
     
1194
-   /**
1195
-    * Detects the most used end-of-line character in the subject string.
1196
-    * 
1197
-    * @param string $subjectString The string to check.
1198
-    * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected.
1199
-    */
1194
+    /**
1195
+     * Detects the most used end-of-line character in the subject string.
1196
+     * 
1197
+     * @param string $subjectString The string to check.
1198
+     * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected.
1199
+     */
1200 1200
     public static function detectEOLCharacter(string $subjectString) : ?ConvertHelper_EOL
1201 1201
     {
1202 1202
         return ConvertHelper_EOL::detect($subjectString);
1203 1203
     }
1204 1204
 
1205
-   /**
1206
-    * Removes the specified keys from the target array,
1207
-    * if they exist.
1208
-    * 
1209
-    * @param array $array
1210
-    * @param array $keys
1211
-    */
1205
+    /**
1206
+     * Removes the specified keys from the target array,
1207
+     * if they exist.
1208
+     * 
1209
+     * @param array $array
1210
+     * @param array $keys
1211
+     */
1212 1212
     public static function arrayRemoveKeys(array &$array, array $keys) : void
1213 1213
     {
1214 1214
         ConvertHelper_Array::removeKeys($array, $keys);
1215 1215
     }
1216 1216
     
1217
-   /**
1218
-    * Checks if the specified variable is an integer or a string containing an integer.
1219
-    * Accepts both positive and negative integers.
1220
-    * 
1221
-    * @param mixed $value
1222
-    * @return bool
1223
-    */
1217
+    /**
1218
+     * Checks if the specified variable is an integer or a string containing an integer.
1219
+     * Accepts both positive and negative integers.
1220
+     * 
1221
+     * @param mixed $value
1222
+     * @return bool
1223
+     */
1224 1224
     public static function isInteger($value) : bool
1225 1225
     {
1226 1226
         if(is_int($value)) {
@@ -1240,52 +1240,52 @@  discard block
 block discarded – undo
1240 1240
         return false;    
1241 1241
     }
1242 1242
     
1243
-   /**
1244
-    * Converts an amount of seconds to a DateInterval object.
1245
-    * 
1246
-    * @param int $seconds
1247
-    * @return \DateInterval
1248
-    * @throws ConvertHelper_Exception If the date interval cannot be created.
1249
-    * 
1250
-    * @see ConvertHelper::ERROR_CANNOT_GET_DATE_DIFF
1251
-    */
1243
+    /**
1244
+     * Converts an amount of seconds to a DateInterval object.
1245
+     * 
1246
+     * @param int $seconds
1247
+     * @return \DateInterval
1248
+     * @throws ConvertHelper_Exception If the date interval cannot be created.
1249
+     * 
1250
+     * @see ConvertHelper::ERROR_CANNOT_GET_DATE_DIFF
1251
+     */
1252 1252
     public static function seconds2interval(int $seconds) : \DateInterval
1253 1253
     {
1254 1254
         return ConvertHelper_DateInterval::fromSeconds($seconds)->getInterval();
1255 1255
     }
1256 1256
     
1257
-   /**
1258
-    * Converts a size string like "50 MB" to the corresponding byte size.
1259
-    * It is case insensitive, ignores spaces, and supports both traditional
1260
-    * "MB" and "MiB" notations.
1261
-    * 
1262
-    * @param string $size
1263
-    * @return int
1264
-    */
1257
+    /**
1258
+     * Converts a size string like "50 MB" to the corresponding byte size.
1259
+     * It is case insensitive, ignores spaces, and supports both traditional
1260
+     * "MB" and "MiB" notations.
1261
+     * 
1262
+     * @param string $size
1263
+     * @return int
1264
+     */
1265 1265
     public static function size2bytes(string $size) : int
1266 1266
     {
1267 1267
         return self::parseSize($size)->toBytes();
1268 1268
     }
1269 1269
     
1270
-   /**
1271
-    * Parses a size string like "50 MB" and returns a size notation instance
1272
-    * that has utility methods to access information on it, and convert it.
1273
-    * 
1274
-    * @param string $size
1275
-    * @return ConvertHelper_SizeNotation
1276
-    */
1270
+    /**
1271
+     * Parses a size string like "50 MB" and returns a size notation instance
1272
+     * that has utility methods to access information on it, and convert it.
1273
+     * 
1274
+     * @param string $size
1275
+     * @return ConvertHelper_SizeNotation
1276
+     */
1277 1277
     public static function parseSize(string $size) : ConvertHelper_SizeNotation
1278 1278
     {
1279 1279
         return new ConvertHelper_SizeNotation($size);
1280 1280
     }
1281 1281
     
1282
-   /**
1283
-    * Creates a URL finder instance, which can be used to find
1284
-    * URLs in a string - be it plain text, or HTML.
1285
-    * 
1286
-    * @param string $subject
1287
-    * @return ConvertHelper_URLFinder
1288
-    */
1282
+    /**
1283
+     * Creates a URL finder instance, which can be used to find
1284
+     * URLs in a string - be it plain text, or HTML.
1285
+     * 
1286
+     * @param string $subject
1287
+     * @return ConvertHelper_URLFinder
1288
+     */
1289 1289
     public static function createURLFinder(string $subject) : ConvertHelper_URLFinder
1290 1290
     {
1291 1291
         return new ConvertHelper_URLFinder($subject);
Please login to merge, or discard this patch.