Passed
Push — master ( 8c9a09...69f647 )
by Sebastian
04:19
created
src/ConvertHelper.php 2 patches
Indentation   +469 added lines, -469 removed lines patch added patch discarded remove patch
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
         return ConvertHelper_String::tabs2spaces($string, $tabSize);
61 61
     }
62 62
     
63
-   /**
64
-    * Converts spaces to tabs in the specified string.
65
-    * 
66
-    * @param string $string
67
-    * @param int $tabSize The amount of spaces per tab in the source string.
68
-    * @return string
69
-    */
63
+    /**
64
+     * Converts spaces to tabs in the specified string.
65
+     * 
66
+     * @param string $string
67
+     * @param int $tabSize The amount of spaces per tab in the source string.
68
+     * @return string
69
+     */
70 70
     public static function spaces2tabs(string $string, int $tabSize=4) : string
71 71
     {
72 72
         return ConvertHelper_String::spaces2tabs($string, $tabSize);
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
         return ConvertHelper_String::hidden2visible($string);
85 85
     }
86 86
     
87
-   /**
88
-    * Converts the specified amount of seconds into
89
-    * a human-readable string split in months, weeks,
90
-    * days, hours, minutes and seconds.
91
-    *
92
-    * @param float $seconds
93
-    * @return string
94
-    */
87
+    /**
88
+     * Converts the specified amount of seconds into
89
+     * a human-readable string split in months, weeks,
90
+     * days, hours, minutes and seconds.
91
+     *
92
+     * @param float $seconds
93
+     * @return string
94
+     */
95 95
     public static function time2string($seconds) : string
96 96
     {
97 97
         $converter = new ConvertHelper_TimeConverter($seconds);
@@ -115,85 +115,85 @@  discard block
 block discarded – undo
115 115
      */
116 116
     public static function duration2string($datefrom, $dateto = -1) : string
117 117
     {
118
-         return ConvertHelper_DurationConverter::toString($datefrom, $dateto);
118
+            return ConvertHelper_DurationConverter::toString($datefrom, $dateto);
119 119
     }
120 120
 
121
-   /**
122
-    * Adds HTML syntax highlighting to the specified SQL string.
123
-    * 
124
-    * @param string $sql
125
-    * @return string
126
-    * @deprecated Use the Highlighter class directly instead.
127
-    * @see Highlighter::sql()
128
-    */
121
+    /**
122
+     * Adds HTML syntax highlighting to the specified SQL string.
123
+     * 
124
+     * @param string $sql
125
+     * @return string
126
+     * @deprecated Use the Highlighter class directly instead.
127
+     * @see Highlighter::sql()
128
+     */
129 129
     public static function highlight_sql(string $sql) : string
130 130
     {
131 131
         return Highlighter::sql($sql);
132 132
     }
133 133
 
134
-   /**
135
-    * Adds HTML syntax highlighting to the specified XML code.
136
-    * 
137
-    * @param string $xml The XML to highlight.
138
-    * @param bool $formatSource Whether to format the source with indentation to make it readable.
139
-    * @return string
140
-    * @deprecated Use the Highlighter class directly instead.
141
-    * @see Highlighter::xml()
142
-    */
134
+    /**
135
+     * Adds HTML syntax highlighting to the specified XML code.
136
+     * 
137
+     * @param string $xml The XML to highlight.
138
+     * @param bool $formatSource Whether to format the source with indentation to make it readable.
139
+     * @return string
140
+     * @deprecated Use the Highlighter class directly instead.
141
+     * @see Highlighter::xml()
142
+     */
143 143
     public static function highlight_xml(string $xml, bool $formatSource=false) : string
144 144
     {
145 145
         return Highlighter::xml($xml, $formatSource);
146 146
     }
147 147
 
148
-   /**
149
-    * @param string $phpCode
150
-    * @return string
151
-    * @deprecated Use the Highlighter class directly instead.
152
-    * @see Highlighter::php()
153
-    */
148
+    /**
149
+     * @param string $phpCode
150
+     * @return string
151
+     * @deprecated Use the Highlighter class directly instead.
152
+     * @see Highlighter::php()
153
+     */
154 154
     public static function highlight_php(string $phpCode) : string
155 155
     {
156 156
         return Highlighter::php($phpCode);
157 157
     }
158 158
     
159
-   /**
160
-    * Converts a number of bytes to a human-readable form,
161
-    * e.g. xx Kb / xx Mb / xx Gb
162
-    *
163
-    * @param int $bytes The amount of bytes to convert.
164
-    * @param int $precision The amount of decimals
165
-    * @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).
166
-    * @return string
167
-    * 
168
-    * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions
169
-    */
159
+    /**
160
+     * Converts a number of bytes to a human-readable form,
161
+     * e.g. xx Kb / xx Mb / xx Gb
162
+     *
163
+     * @param int $bytes The amount of bytes to convert.
164
+     * @param int $precision The amount of decimals
165
+     * @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).
166
+     * @return string
167
+     * 
168
+     * @see https://en.m.wikipedia.org/wiki/Megabyte#Definitions
169
+     */
170 170
     public static function bytes2readable(int $bytes, int $precision = 1, int $base = ConvertHelper_StorageSizeEnum::BASE_10) : string
171 171
     {
172 172
         return self::parseBytes($bytes)->toString($precision, $base);
173 173
     }
174 174
     
175
-   /**
176
-    * Parses a number of bytes, and creates a converter instance which
177
-    * allows doing common operations with it.
178
-    * 
179
-    * @param int $bytes
180
-    * @return ConvertHelper_ByteConverter
181
-    */
175
+    /**
176
+     * Parses a number of bytes, and creates a converter instance which
177
+     * allows doing common operations with it.
178
+     * 
179
+     * @param int $bytes
180
+     * @return ConvertHelper_ByteConverter
181
+     */
182 182
     public static function parseBytes(int $bytes) : ConvertHelper_ByteConverter
183 183
     {
184 184
         return new ConvertHelper_ByteConverter($bytes);
185 185
     }
186 186
 
187
-   /**
188
-    * Cuts a text to the specified length if it is longer than the
189
-    * target length. Appends a text to signify it has been cut at 
190
-    * the end of the string.
191
-    * 
192
-    * @param string $text
193
-    * @param int $targetLength
194
-    * @param string $append
195
-    * @return string
196
-    */
187
+    /**
188
+     * Cuts a text to the specified length if it is longer than the
189
+     * target length. Appends a text to signify it has been cut at 
190
+     * the end of the string.
191
+     * 
192
+     * @param string $text
193
+     * @param int $targetLength
194
+     * @param string $append
195
+     * @return string
196
+     */
197 197
     public static function text_cut(string $text, int $targetLength, string $append = '...') : string
198 198
     {
199 199
         return ConvertHelper_String::cutText($text, $targetLength, $append);
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
         return $info->toString();
218 218
     }
219 219
     
220
-   /**
221
-    * Pretty `print_r`.
222
-    * 
223
-    * @param mixed $var The variable to dump.
224
-    * @param bool $return Whether to return the dumped code.
225
-    * @param bool $html Whether to style the dump as HTML.
226
-    * @return string
227
-    */
220
+    /**
221
+     * Pretty `print_r`.
222
+     * 
223
+     * @param mixed $var The variable to dump.
224
+     * @param bool $return Whether to return the dumped code.
225
+     * @param bool $html Whether to style the dump as HTML.
226
+     * @return string
227
+     */
228 228
     public static function print_r($var, bool $return=false, bool $html=true) : string
229 229
     {
230 230
         $result = parseVariable($var)->enableType()->toString();
@@ -245,29 +245,29 @@  discard block
 block discarded – undo
245 245
         return $result;
246 246
     }
247 247
     
248
-   /**
249
-    * Converts a string, number or boolean value to a boolean value.
250
-    *
251
-    * @param mixed $string
252
-    * @throws ConvertHelper_Exception
253
-    * @return bool
254
-    *
255
-    * @see ConvertHelper::ERROR_INVALID_BOOLEAN_STRING
256
-    */
248
+    /**
249
+     * Converts a string, number or boolean value to a boolean value.
250
+     *
251
+     * @param mixed $string
252
+     * @throws ConvertHelper_Exception
253
+     * @return bool
254
+     *
255
+     * @see ConvertHelper::ERROR_INVALID_BOOLEAN_STRING
256
+     */
257 257
     public static function string2bool($string) : bool
258 258
     {
259 259
         return ConvertHelper_Bool::fromString($string);
260 260
     }
261 261
 
262
-   /**
263
-    * Whether the specified string is a boolean string or boolean value.
264
-    * Alias for {@link ConvertHelper::isBoolean()}.
265
-    *
266
-    * @param mixed $string
267
-    * @return bool
268
-    * @deprecated
269
-    * @see ConvertHelper::isBoolean()
270
-    */
262
+    /**
263
+     * Whether the specified string is a boolean string or boolean value.
264
+     * Alias for {@link ConvertHelper::isBoolean()}.
265
+     *
266
+     * @param mixed $string
267
+     * @return bool
268
+     * @deprecated
269
+     * @see ConvertHelper::isBoolean()
270
+     */
271 271
     public static function isBooleanString($string) : bool
272 272
     {
273 273
         return self::isBoolean($string);
@@ -337,36 +337,36 @@  discard block
 block discarded – undo
337 337
         return ConvertHelper_String::transliterate($string, $spaceChar, $lowercase);
338 338
     }
339 339
     
340
-   /**
341
-    * Retrieves the HEX character codes for all control
342
-    * characters that the {@link stripControlCharacters()} 
343
-    * method will remove.
344
-    * 
345
-    * @return string[]
346
-    */
340
+    /**
341
+     * Retrieves the HEX character codes for all control
342
+     * characters that the {@link stripControlCharacters()} 
343
+     * method will remove.
344
+     * 
345
+     * @return string[]
346
+     */
347 347
     public static function getControlCharactersAsHex() : array
348 348
     {
349 349
         return self::createControlCharacters()->getCharsAsHex();
350 350
     }
351 351
     
352
-   /**
353
-    * Retrieves an array of all control characters that
354
-    * the {@link stripControlCharacters()} method will 
355
-    * remove, as the actual UTF-8 characters.
356
-    * 
357
-    * @return string[]
358
-    */
352
+    /**
353
+     * Retrieves an array of all control characters that
354
+     * the {@link stripControlCharacters()} method will 
355
+     * remove, as the actual UTF-8 characters.
356
+     * 
357
+     * @return string[]
358
+     */
359 359
     public static function getControlCharactersAsUTF8() : array
360 360
     {
361 361
         return self::createControlCharacters()->getCharsAsUTF8();
362 362
     }
363 363
     
364
-   /**
365
-    * Retrieves all control characters as JSON encoded
366
-    * characters, e.g. "\u200b".
367
-    * 
368
-    * @return string[]
369
-    */
364
+    /**
365
+     * Retrieves all control characters as JSON encoded
366
+     * characters, e.g. "\u200b".
367
+     * 
368
+     * @return string[]
369
+     */
370 370
     public static function getControlCharactersAsJSON() : array
371 371
     {
372 372
         return self::createControlCharacters()->getCharsAsJSON();
@@ -387,31 +387,31 @@  discard block
 block discarded – undo
387 387
         return self::createControlCharacters()->stripControlCharacters($string);
388 388
     }
389 389
     
390
-   /**
391
-    * Creates the control characters class, used to 
392
-    * work with control characters in strings.
393
-    * 
394
-    * @return ConvertHelper_ControlCharacters
395
-    */
390
+    /**
391
+     * Creates the control characters class, used to 
392
+     * work with control characters in strings.
393
+     * 
394
+     * @return ConvertHelper_ControlCharacters
395
+     */
396 396
     public static function createControlCharacters() : ConvertHelper_ControlCharacters
397 397
     {
398 398
         return new ConvertHelper_ControlCharacters();
399 399
     }
400 400
 
401
-   /**
402
-    * Converts a unicode character to the PHP notation.
403
-    * 
404
-    * Example:
405
-    * 
406
-    * <pre>unicodeChar2php('"\u0000"')</pre>
407
-    * 
408
-    * Returns
409
-    * 
410
-    * <pre>\x0</pre>
411
-    * 
412
-    * @param string $unicodeChar
413
-    * @return string
414
-    */
401
+    /**
402
+     * Converts a unicode character to the PHP notation.
403
+     * 
404
+     * Example:
405
+     * 
406
+     * <pre>unicodeChar2php('"\u0000"')</pre>
407
+     * 
408
+     * Returns
409
+     * 
410
+     * <pre>\x0</pre>
411
+     * 
412
+     * @param string $unicodeChar
413
+     * @return string
414
+     */
415 415
     public static function unicodeChar2php(string $unicodeChar) : string 
416 416
     {
417 417
         $unicodeChar = json_decode($unicodeChar);
@@ -525,138 +525,138 @@  discard block
 block discarded – undo
525 525
         return ConvertHelper_Bool::toStringStrict($boolean, $yesNo);
526 526
     }
527 527
 
528
-   /**
529
-    * Converts an associative array with attribute name > value pairs
530
-    * to an attribute string that can be used in an HTML tag. Empty 
531
-    * attribute values are ignored.
532
-    * 
533
-    * Example:
534
-    * 
535
-    * array2attributeString(array(
536
-    *     'id' => 45,
537
-    *     'href' => 'http://www.mistralys.com'
538
-    * ));
539
-    * 
540
-    * Result:
541
-    * 
542
-    * id="45" href="http://www.mistralys.com"
543
-    * 
544
-    * @param array<string,mixed> $array
545
-    * @return string
546
-    */
528
+    /**
529
+     * Converts an associative array with attribute name > value pairs
530
+     * to an attribute string that can be used in an HTML tag. Empty 
531
+     * attribute values are ignored.
532
+     * 
533
+     * Example:
534
+     * 
535
+     * array2attributeString(array(
536
+     *     'id' => 45,
537
+     *     'href' => 'http://www.mistralys.com'
538
+     * ));
539
+     * 
540
+     * Result:
541
+     * 
542
+     * id="45" href="http://www.mistralys.com"
543
+     * 
544
+     * @param array<string,mixed> $array
545
+     * @return string
546
+     */
547 547
     public static function array2attributeString(array $array) : string
548 548
     {
549 549
         return ConvertHelper_Array::toAttributeString($array);
550 550
     }
551 551
     
552
-   /**
553
-    * Converts a string, so it can safely be used in a javascript
554
-    * statement in an HTML tag: uses single quotes around the string
555
-    * and encodes all special characters as needed.
556
-    * 
557
-    * @param string $string
558
-    * @return string
559
-    * @deprecated Use the JSHelper class instead.
560
-    * @see JSHelper::phpVariable2AttributeJS()
561
-    */
552
+    /**
553
+     * Converts a string, so it can safely be used in a javascript
554
+     * statement in an HTML tag: uses single quotes around the string
555
+     * and encodes all special characters as needed.
556
+     * 
557
+     * @param string $string
558
+     * @return string
559
+     * @deprecated Use the JSHelper class instead.
560
+     * @see JSHelper::phpVariable2AttributeJS()
561
+     */
562 562
     public static function string2attributeJS(string $string) : string
563 563
     {
564 564
         return JSHelper::phpVariable2AttributeJS($string);
565 565
     }
566 566
     
567
-   /**
568
-    * Checks if the specified string is a boolean value, which
569
-    * includes string representations of boolean values, like 
570
-    * <code>yes</code> or <code>no</code>, and <code>true</code>
571
-    * or <code>false</code>.
572
-    * 
573
-    * @param mixed $value
574
-    * @return boolean
575
-    */
567
+    /**
568
+     * Checks if the specified string is a boolean value, which
569
+     * includes string representations of boolean values, like 
570
+     * <code>yes</code> or <code>no</code>, and <code>true</code>
571
+     * or <code>false</code>.
572
+     * 
573
+     * @param mixed $value
574
+     * @return boolean
575
+     */
576 576
     public static function isBoolean($value) : bool
577 577
     {
578 578
         return ConvertHelper_Bool::isBoolean($value);
579 579
     }
580 580
     
581
-   /**
582
-    * Converts an associative array to an HTML style attribute value string.
583
-    * 
584
-    * @param array<string,mixed> $subject
585
-    * @return string
586
-    */
581
+    /**
582
+     * Converts an associative array to an HTML style attribute value string.
583
+     * 
584
+     * @param array<string,mixed> $subject
585
+     * @return string
586
+     */
587 587
     public static function array2styleString(array $subject) : string
588 588
     {
589 589
         return ConvertHelper_Array::toStyleString($subject);
590 590
     }
591 591
     
592
-   /**
593
-    * Converts a DateTime object to a timestamp, which
594
-    * is PHP 5.2 compatible.
595
-    * 
596
-    * @param DateTime $date
597
-    * @return integer
598
-    */
592
+    /**
593
+     * Converts a DateTime object to a timestamp, which
594
+     * is PHP 5.2 compatible.
595
+     * 
596
+     * @param DateTime $date
597
+     * @return integer
598
+     */
599 599
     public static function date2timestamp(DateTime $date) : int
600 600
     {
601 601
         return ConvertHelper_Date::toTimestamp($date);
602 602
     }
603 603
     
604
-   /**
605
-    * Converts a timestamp into a DateTime instance.
606
-    * @param int $timestamp
607
-    * @return DateTime
608
-    */
604
+    /**
605
+     * Converts a timestamp into a DateTime instance.
606
+     * @param int $timestamp
607
+     * @return DateTime
608
+     */
609 609
     public static function timestamp2date(int $timestamp) : DateTime
610 610
     {
611 611
         return ConvertHelper_Date::fromTimestamp($timestamp);
612 612
     }
613 613
     
614
-   /**
615
-    * Strips an absolute path to a file within the application
616
-    * to make the path relative to the application root path.
617
-    * 
618
-    * @param string $path
619
-    * @return string
620
-    * 
621
-    * @see FileHelper::relativizePath()
622
-    * @see FileHelper::relativizePathByDepth()
623
-    */
614
+    /**
615
+     * Strips an absolute path to a file within the application
616
+     * to make the path relative to the application root path.
617
+     * 
618
+     * @param string $path
619
+     * @return string
620
+     * 
621
+     * @see FileHelper::relativizePath()
622
+     * @see FileHelper::relativizePathByDepth()
623
+     */
624 624
     public static function fileRelativize(string $path) : string
625 625
     {
626 626
         return FileHelper::relativizePathByDepth($path);
627 627
     }
628 628
     
629 629
     /**
630
-    * Converts a PHP regex to a javascript RegExp object statement.
631
-    * 
632
-    * NOTE: This is an alias for the JSHelper's `convertRegex` method. 
633
-    * More details are available on its usage there.
634
-    *
635
-    * @param string $regex A PHP preg regex
636
-    * @param string $statementType The type of statement to return: Defaults to a statement to create a RegExp object.
637
-    * @return string Depending on the specified return type.
638
-    * 
639
-    * @see JSHelper::buildRegexStatement()
640
-    */
630
+     * Converts a PHP regex to a javascript RegExp object statement.
631
+     * 
632
+     * NOTE: This is an alias for the JSHelper's `convertRegex` method. 
633
+     * More details are available on its usage there.
634
+     *
635
+     * @param string $regex A PHP preg regex
636
+     * @param string $statementType The type of statement to return: Defaults to a statement to create a RegExp object.
637
+     * @return string Depending on the specified return type.
638
+     * 
639
+     * @see JSHelper::buildRegexStatement()
640
+     */
641 641
     public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT) : string
642 642
     {
643 643
         return JSHelper::buildRegexStatement($regex, $statementType);
644 644
     }
645 645
     
646
-   /**
647
-    * Converts the specified variable to JSON. Works just
648
-    * like the native `json_encode` method, except that it
649
-    * will trigger an exception on failure, which has the 
650
-    * json error details included in its developer details.
651
-    * 
652
-    * @param mixed $variable
653
-    * @param int $options JSON encode options.
654
-    * @param int $depth 
655
-    * @return string
656
-    *
657
-    * @throws ConvertHelper_Exception
658
-    * @see ConvertHelper::ERROR_JSON_ENCODE_FAILED
659
-    */
646
+    /**
647
+     * Converts the specified variable to JSON. Works just
648
+     * like the native `json_encode` method, except that it
649
+     * will trigger an exception on failure, which has the 
650
+     * json error details included in its developer details.
651
+     * 
652
+     * @param mixed $variable
653
+     * @param int $options JSON encode options.
654
+     * @param int $depth 
655
+     * @return string
656
+     *
657
+     * @throws ConvertHelper_Exception
658
+     * @see ConvertHelper::ERROR_JSON_ENCODE_FAILED
659
+     */
660 660
     public static function var2json($variable, int $options=0, int $depth=512) : string
661 661
     {
662 662
         $result = json_encode($variable, $options, $depth);
@@ -691,12 +691,12 @@  discard block
 block discarded – undo
691 691
             ->toString();
692 692
     }
693 693
     
694
-   /**
695
-    * Strips all known UTF byte order marks from the specified string.
696
-    * 
697
-    * @param string $string
698
-    * @return string
699
-    */
694
+    /**
695
+     * Strips all known UTF byte order marks from the specified string.
696
+     * 
697
+     * @param string $string
698
+     * @return string
699
+     */
700 700
     public static function stripUTFBom(string $string) : string
701 701
     {
702 702
         $boms = FileHelper::getUTFBOMs();
@@ -715,69 +715,69 @@  discard block
 block discarded – undo
715 715
         return $string;
716 716
     }
717 717
 
718
-   /**
719
-    * Converts a string to valid utf8, regardless
720
-    * of the string's encoding(s).
721
-    * 
722
-    * @param string $string
723
-    * @return string
724
-    */
718
+    /**
719
+     * Converts a string to valid utf8, regardless
720
+     * of the string's encoding(s).
721
+     * 
722
+     * @param string $string
723
+     * @return string
724
+     */
725 725
     public static function string2utf8(string $string) : string
726 726
     {
727 727
         return ConvertHelper_String::toUtf8($string);
728 728
     }
729 729
     
730
-   /**
731
-    * Checks whether the specified string is an ASCII
732
-    * string, without any special or UTF8 characters.
733
-    * Note: empty strings and NULL are considered ASCII.
734
-    * Any variable types other than strings are not.
735
-    * 
736
-    * @param string|float|int|NULL $string
737
-    * @return boolean
738
-    */
730
+    /**
731
+     * Checks whether the specified string is an ASCII
732
+     * string, without any special or UTF8 characters.
733
+     * Note: empty strings and NULL are considered ASCII.
734
+     * Any variable types other than strings are not.
735
+     * 
736
+     * @param string|float|int|NULL $string
737
+     * @return boolean
738
+     */
739 739
     public static function isStringASCII($string) : bool
740 740
     {
741 741
         return ConvertHelper_String::isASCII(strval($string));
742 742
     }
743 743
     
744
-   /**
745
-    * Adds HTML syntax highlighting to an URL.
746
-    * 
747
-    * NOTE: Includes the necessary CSS styles. When
748
-    * highlighting several URLs in the same page,
749
-    * prefer using the `parseURL` function instead.
750
-    * 
751
-    * @param string $url
752
-    * @return string
753
-    * @deprecated Use the Highlighter class directly instead.
754
-    * @see Highlighter
755
-    */
744
+    /**
745
+     * Adds HTML syntax highlighting to an URL.
746
+     * 
747
+     * NOTE: Includes the necessary CSS styles. When
748
+     * highlighting several URLs in the same page,
749
+     * prefer using the `parseURL` function instead.
750
+     * 
751
+     * @param string $url
752
+     * @return string
753
+     * @deprecated Use the Highlighter class directly instead.
754
+     * @see Highlighter
755
+     */
756 756
     public static function highlight_url(string $url) : string
757 757
     {
758 758
         return Highlighter::url($url);
759 759
     }
760 760
 
761
-   /**
762
-    * Calculates a percentage match of the source string with the target string.
763
-    * 
764
-    * Options are:
765
-    * 
766
-    * - maxLevenshtein, default: 10
767
-    *   Any levenshtein results above this value are ignored.
768
-    *   
769
-    * - precision, default: 1
770
-    *   The precision of the percentage float value
771
-    * 
772
-    * @param string $source
773
-    * @param string $target
774
-    * @param array<string,mixed> $options
775
-    * @return float
776
-    *
777
-    * @see ConvertHelper_TextComparer
778
-    * @see ConvertHelper_TextComparer::OPTION_MAX_LEVENSHTEIN_DISTANCE
779
-    * @see ConvertHelper_TextComparer::OPTION_PRECISION
780
-    */
761
+    /**
762
+     * Calculates a percentage match of the source string with the target string.
763
+     * 
764
+     * Options are:
765
+     * 
766
+     * - maxLevenshtein, default: 10
767
+     *   Any levenshtein results above this value are ignored.
768
+     *   
769
+     * - precision, default: 1
770
+     *   The precision of the percentage float value
771
+     * 
772
+     * @param string $source
773
+     * @param string $target
774
+     * @param array<string,mixed> $options
775
+     * @return float
776
+     *
777
+     * @see ConvertHelper_TextComparer
778
+     * @see ConvertHelper_TextComparer::OPTION_MAX_LEVENSHTEIN_DISTANCE
779
+     * @see ConvertHelper_TextComparer::OPTION_PRECISION
780
+     */
781 781
     public static function matchString(string $source, string $target, array $options=array()) : float
782 782
     {
783 783
         return (new ConvertHelper_TextComparer())
@@ -785,109 +785,109 @@  discard block
 block discarded – undo
785 785
             ->match($source, $target);
786 786
     }
787 787
     
788
-   /**
789
-    * Converts a date interval to a human-readable string with
790
-    * all necessary time components, e.g. "1 year, 2 months and 4 days".
791
-    * 
792
-    * @param DateInterval $interval
793
-    * @return string
794
-    * @see ConvertHelper_IntervalConverter
795
-    *
796
-    * @throws ConvertHelper_Exception
797
-    * @see ConvertHelper_IntervalConverter::ERROR_MISSING_TRANSLATION
798
-    */
788
+    /**
789
+     * Converts a date interval to a human-readable string with
790
+     * all necessary time components, e.g. "1 year, 2 months and 4 days".
791
+     * 
792
+     * @param DateInterval $interval
793
+     * @return string
794
+     * @see ConvertHelper_IntervalConverter
795
+     *
796
+     * @throws ConvertHelper_Exception
797
+     * @see ConvertHelper_IntervalConverter::ERROR_MISSING_TRANSLATION
798
+     */
799 799
     public static function interval2string(DateInterval $interval) : string
800 800
     {
801 801
         return (new ConvertHelper_IntervalConverter())
802 802
             ->toString($interval);
803 803
     }
804 804
     
805
-   /**
806
-    * Converts an interval to its total amount of days.
807
-    * @param DateInterval $interval
808
-    * @return int
809
-    */
805
+    /**
806
+     * Converts an interval to its total amount of days.
807
+     * @param DateInterval $interval
808
+     * @return int
809
+     */
810 810
     public static function interval2days(DateInterval $interval) : int
811 811
     {
812 812
         return ConvertHelper_DateInterval::toDays($interval);
813 813
     }
814 814
 
815
-   /**
816
-    * Converts an interval to its total amount of hours.
817
-    * @param DateInterval $interval
818
-    * @return int
819
-    */
815
+    /**
816
+     * Converts an interval to its total amount of hours.
817
+     * @param DateInterval $interval
818
+     * @return int
819
+     */
820 820
     public static function interval2hours(DateInterval $interval) : int
821 821
     {
822 822
         return ConvertHelper_DateInterval::toHours($interval);
823 823
     }
824 824
     
825
-   /**
826
-    * Converts an interval to its total amount of minutes. 
827
-    * @param DateInterval $interval
828
-    * @return int
829
-    */
825
+    /**
826
+     * Converts an interval to its total amount of minutes. 
827
+     * @param DateInterval $interval
828
+     * @return int
829
+     */
830 830
     public static function interval2minutes(DateInterval $interval) : int
831 831
     {
832 832
         return ConvertHelper_DateInterval::toMinutes($interval);
833 833
     }
834 834
     
835
-   /**
836
-    * Converts an interval to its total amount of seconds.
837
-    * @param DateInterval $interval
838
-    * @return int
839
-    */    
835
+    /**
836
+     * Converts an interval to its total amount of seconds.
837
+     * @param DateInterval $interval
838
+     * @return int
839
+     */    
840 840
     public static function interval2seconds(DateInterval $interval) : int
841 841
     {
842 842
         return ConvertHelper_DateInterval::toSeconds($interval);
843 843
     }
844 844
     
845
-   /**
846
-    * Calculates the total amount of days / hours / minutes or seconds
847
-    * of a date interval object (depending on the specified units), and
848
-    * returns the total amount.
849
-    * 
850
-    * @param DateInterval $interval
851
-    * @param string $unit What total value to calculate.
852
-    * @return integer
853
-    * 
854
-    * @see ConvertHelper::INTERVAL_SECONDS
855
-    * @see ConvertHelper::INTERVAL_MINUTES
856
-    * @see ConvertHelper::INTERVAL_HOURS
857
-    * @see ConvertHelper::INTERVAL_DAYS
858
-    */
845
+    /**
846
+     * Calculates the total amount of days / hours / minutes or seconds
847
+     * of a date interval object (depending on the specified units), and
848
+     * returns the total amount.
849
+     * 
850
+     * @param DateInterval $interval
851
+     * @param string $unit What total value to calculate.
852
+     * @return integer
853
+     * 
854
+     * @see ConvertHelper::INTERVAL_SECONDS
855
+     * @see ConvertHelper::INTERVAL_MINUTES
856
+     * @see ConvertHelper::INTERVAL_HOURS
857
+     * @see ConvertHelper::INTERVAL_DAYS
858
+     */
859 859
     public static function interval2total(DateInterval $interval, string $unit=self::INTERVAL_SECONDS) : int
860 860
     {
861 861
         return ConvertHelper_DateInterval::toTotal($interval, $unit);
862 862
     }
863 863
 
864
-   /**
865
-    * Converts a date to the corresponding day name.
866
-    * 
867
-    * @param DateTime $date
868
-    * @param bool $short
869
-    * @return string|NULL
870
-    */
864
+    /**
865
+     * Converts a date to the corresponding day name.
866
+     * 
867
+     * @param DateTime $date
868
+     * @param bool $short
869
+     * @return string|NULL
870
+     */
871 871
     public static function date2dayName(DateTime $date, bool $short=false) : ?string
872 872
     {
873 873
         return ConvertHelper_Date::toDayName($date, $short);
874 874
     }
875 875
     
876
-   /**
877
-    * Retrieves a list of english day names.
878
-    * @return string[]
879
-    */
876
+    /**
877
+     * Retrieves a list of english day names.
878
+     * @return string[]
879
+     */
880 880
     public static function getDayNamesInvariant() : array
881 881
     {
882 882
         return ConvertHelper_Date::getDayNamesInvariant();
883 883
     }
884 884
     
885
-   /**
886
-    * Retrieves the day names list for the current locale.
887
-    * 
888
-    * @param bool $short
889
-    * @return string[]
890
-    */
885
+    /**
886
+     * Retrieves the day names list for the current locale.
887
+     * 
888
+     * @param bool $short
889
+     * @return string[]
890
+     */
891 891
     public static function getDayNames(bool $short=false) : array
892 892
     {
893 893
         return ConvertHelper_Date::getDayNames($short);
@@ -906,68 +906,68 @@  discard block
 block discarded – undo
906 906
         return ConvertHelper_Array::implodeWithAnd($list, $sep, $conjunction);
907 907
     }
908 908
     
909
-   /**
910
-    * Splits a string into an array of all characters it is composed of.
911
-    * Unicode character safe.
912
-    * 
913
-    * NOTE: Spaces and newlines (both \r and \n) are also considered single
914
-    * characters.
915
-    * 
916
-    * @param string $string
917
-    * @return string[]
918
-    */
909
+    /**
910
+     * Splits a string into an array of all characters it is composed of.
911
+     * Unicode character safe.
912
+     * 
913
+     * NOTE: Spaces and newlines (both \r and \n) are also considered single
914
+     * characters.
915
+     * 
916
+     * @param string $string
917
+     * @return string[]
918
+     */
919 919
     public static function string2array(string $string) : array
920 920
     {
921 921
         return ConvertHelper_String::toArray($string);
922 922
     }
923 923
     
924
-   /**
925
-    * Checks whether the specified string contains HTML code.
926
-    * 
927
-    * @param string $string
928
-    * @return boolean
929
-    */
924
+    /**
925
+     * Checks whether the specified string contains HTML code.
926
+     * 
927
+     * @param string $string
928
+     * @return boolean
929
+     */
930 930
     public static function isStringHTML(string $string) : bool
931 931
     {
932 932
         return ConvertHelper_String::isHTML($string);
933 933
     }
934 934
     
935
-   /**
936
-    * UTF8-safe wordwrap method: works like the regular wordwrap
937
-    * PHP function but compatible with UTF8. Otherwise the lengths
938
-    * are not calculated correctly.
939
-    * 
940
-    * @param string $str
941
-    * @param int $width
942
-    * @param string $break
943
-    * @param bool $cut
944
-    * @return string
945
-    */
935
+    /**
936
+     * UTF8-safe wordwrap method: works like the regular wordwrap
937
+     * PHP function but compatible with UTF8. Otherwise the lengths
938
+     * are not calculated correctly.
939
+     * 
940
+     * @param string $str
941
+     * @param int $width
942
+     * @param string $break
943
+     * @param bool $cut
944
+     * @return string
945
+     */
946 946
     public static function wordwrap(string $str, int $width = 75, string $break = "\n", bool $cut = false) : string 
947 947
     {
948 948
         return ConvertHelper_String::wordwrap($str, $width, $break, $cut);
949 949
     }
950 950
     
951
-   /**
952
-    * Calculates the byte length of a string, taking into 
953
-    * account any unicode characters.
954
-    * 
955
-    * @param string $string
956
-    * @return int
957
-    */
951
+    /**
952
+     * Calculates the byte length of a string, taking into 
953
+     * account any unicode characters.
954
+     * 
955
+     * @param string $string
956
+     * @return int
957
+     */
958 958
     public static function string2bytes(string $string): int
959 959
     {
960 960
         return ConvertHelper_String::toBytes($string);
961 961
     }
962 962
     
963
-   /**
964
-    * Creates a short, 8-character long hash for the specified string.
965
-    * 
966
-    * WARNING: Not cryptographically safe.
967
-    * 
968
-    * @param string $string
969
-    * @return string
970
-    */
963
+    /**
964
+     * Creates a short, 8-character long hash for the specified string.
965
+     * 
966
+     * WARNING: Not cryptographically safe.
967
+     * 
968
+     * @param string $string
969
+     * @return string
970
+     */
971 971
     public static function string2shortHash(string $string) : string
972 972
     {
973 973
         return ConvertHelper_String::toShortHash($string);
@@ -1013,88 +1013,88 @@  discard block
 block discarded – undo
1013 1013
         return ConvertHelper_ThrowableInfo::fromThrowable($e);
1014 1014
     }
1015 1015
     
1016
-   /**
1017
-    * Parses the specified query string like the native 
1018
-    * function <code>parse_str</code>, without the key
1019
-    * naming limitations.
1020
-    * 
1021
-    * Using parse_str, dots or spaces in key names are 
1022
-    * replaced by underscores. This method keeps all names
1023
-    * intact.
1024
-    * 
1025
-    * It still uses the parse_str implementation as it 
1026
-    * is tested and tried, but fixes the parameter names
1027
-    * after parsing, as needed.
1028
-    * 
1029
-    * @param string $queryString
1030
-    * @return array<string,string>
1031
-    * @see ConvertHelper_QueryParser
1032
-    */
1016
+    /**
1017
+     * Parses the specified query string like the native 
1018
+     * function <code>parse_str</code>, without the key
1019
+     * naming limitations.
1020
+     * 
1021
+     * Using parse_str, dots or spaces in key names are 
1022
+     * replaced by underscores. This method keeps all names
1023
+     * intact.
1024
+     * 
1025
+     * It still uses the parse_str implementation as it 
1026
+     * is tested and tried, but fixes the parameter names
1027
+     * after parsing, as needed.
1028
+     * 
1029
+     * @param string $queryString
1030
+     * @return array<string,string>
1031
+     * @see ConvertHelper_QueryParser
1032
+     */
1033 1033
     public static function parseQueryString(string $queryString) : array
1034 1034
     {
1035 1035
         $parser = new ConvertHelper_QueryParser();
1036 1036
         return $parser->parse($queryString);
1037 1037
     }
1038 1038
 
1039
-   /**
1040
-    * Searches for needle in the specified string, and returns a list
1041
-    * of all occurrences, including the matched string. The matched 
1042
-    * string is useful when doing a case-insensitive search, as it
1043
-    * shows the exact matched case of needle.
1044
-    *   
1045
-    * @param string $needle
1046
-    * @param string $haystack
1047
-    * @param bool $caseInsensitive
1048
-    * @return ConvertHelper_StringMatch[]
1049
-    */
1039
+    /**
1040
+     * Searches for needle in the specified string, and returns a list
1041
+     * of all occurrences, including the matched string. The matched 
1042
+     * string is useful when doing a case-insensitive search, as it
1043
+     * shows the exact matched case of needle.
1044
+     *   
1045
+     * @param string $needle
1046
+     * @param string $haystack
1047
+     * @param bool $caseInsensitive
1048
+     * @return ConvertHelper_StringMatch[]
1049
+     */
1050 1050
     public static function findString(string $needle, string $haystack, bool $caseInsensitive=false): array
1051 1051
     {
1052 1052
         return ConvertHelper_String::findString($needle, $haystack, $caseInsensitive);
1053 1053
     }
1054 1054
     
1055
-   /**
1056
-    * Like explode, but trims all entries, and removes 
1057
-    * empty entries from the resulting array.
1058
-    * 
1059
-    * @param string $delimiter
1060
-    * @param string $string
1061
-    * @return string[]
1062
-    */
1055
+    /**
1056
+     * Like explode, but trims all entries, and removes 
1057
+     * empty entries from the resulting array.
1058
+     * 
1059
+     * @param string $delimiter
1060
+     * @param string $string
1061
+     * @return string[]
1062
+     */
1063 1063
     public static function explodeTrim(string $delimiter, string $string) : array
1064 1064
     {
1065 1065
         return ConvertHelper_String::explodeTrim($delimiter, $string);
1066 1066
     }
1067 1067
     
1068
-   /**
1069
-    * Detects the most used end-of-line character in the subject string.
1070
-    * 
1071
-    * @param string $subjectString The string to check.
1072
-    * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected.
1073
-    */
1068
+    /**
1069
+     * Detects the most used end-of-line character in the subject string.
1070
+     * 
1071
+     * @param string $subjectString The string to check.
1072
+     * @return NULL|ConvertHelper_EOL The detected EOL instance, or NULL if none has been detected.
1073
+     */
1074 1074
     public static function detectEOLCharacter(string $subjectString) : ?ConvertHelper_EOL
1075 1075
     {
1076 1076
         return ConvertHelper_EOL::detect($subjectString);
1077 1077
     }
1078 1078
 
1079
-   /**
1080
-    * Removes the specified keys from the target array,
1081
-    * if they exist.
1082
-    * 
1083
-    * @param array<string|int,mixed> $array
1084
-    * @param string[] $keys
1085
-    */
1079
+    /**
1080
+     * Removes the specified keys from the target array,
1081
+     * if they exist.
1082
+     * 
1083
+     * @param array<string|int,mixed> $array
1084
+     * @param string[] $keys
1085
+     */
1086 1086
     public static function arrayRemoveKeys(array &$array, array $keys) : void
1087 1087
     {
1088 1088
         ConvertHelper_Array::removeKeys($array, $keys);
1089 1089
     }
1090 1090
     
1091
-   /**
1092
-    * Checks if the specified variable is an integer or a string containing an integer.
1093
-    * Accepts both positive and negative integers.
1094
-    * 
1095
-    * @param mixed $value
1096
-    * @return bool
1097
-    */
1091
+    /**
1092
+     * Checks if the specified variable is an integer or a string containing an integer.
1093
+     * Accepts both positive and negative integers.
1094
+     * 
1095
+     * @param mixed $value
1096
+     * @return bool
1097
+     */
1098 1098
     public static function isInteger($value) : bool
1099 1099
     {
1100 1100
         if(is_int($value)) {
@@ -1114,52 +1114,52 @@  discard block
 block discarded – undo
1114 1114
         return false;    
1115 1115
     }
1116 1116
     
1117
-   /**
1118
-    * Converts an amount of seconds to a DateInterval object.
1119
-    * 
1120
-    * @param int $seconds
1121
-    * @return DateInterval
1122
-    * @throws ConvertHelper_Exception If the date interval cannot be created.
1123
-    * 
1124
-    * @see ConvertHelper::ERROR_CANNOT_GET_DATE_DIFF
1125
-    */
1117
+    /**
1118
+     * Converts an amount of seconds to a DateInterval object.
1119
+     * 
1120
+     * @param int $seconds
1121
+     * @return DateInterval
1122
+     * @throws ConvertHelper_Exception If the date interval cannot be created.
1123
+     * 
1124
+     * @see ConvertHelper::ERROR_CANNOT_GET_DATE_DIFF
1125
+     */
1126 1126
     public static function seconds2interval(int $seconds) : DateInterval
1127 1127
     {
1128 1128
         return ConvertHelper_DateInterval::fromSeconds($seconds)->getInterval();
1129 1129
     }
1130 1130
     
1131
-   /**
1132
-    * Converts a size string like "50 MB" to the corresponding byte size.
1133
-    * It is case-insensitive, ignores spaces, and supports both traditional
1134
-    * "MB" and "MiB" notations.
1135
-    * 
1136
-    * @param string $size
1137
-    * @return int
1138
-    */
1131
+    /**
1132
+     * Converts a size string like "50 MB" to the corresponding byte size.
1133
+     * It is case-insensitive, ignores spaces, and supports both traditional
1134
+     * "MB" and "MiB" notations.
1135
+     * 
1136
+     * @param string $size
1137
+     * @return int
1138
+     */
1139 1139
     public static function size2bytes(string $size) : int
1140 1140
     {
1141 1141
         return self::parseSize($size)->toBytes();
1142 1142
     }
1143 1143
     
1144
-   /**
1145
-    * Parses a size string like "50 MB" and returns a size notation instance
1146
-    * that has utility methods to access information on it, and convert it.
1147
-    * 
1148
-    * @param string $size
1149
-    * @return ConvertHelper_SizeNotation
1150
-    */
1144
+    /**
1145
+     * Parses a size string like "50 MB" and returns a size notation instance
1146
+     * that has utility methods to access information on it, and convert it.
1147
+     * 
1148
+     * @param string $size
1149
+     * @return ConvertHelper_SizeNotation
1150
+     */
1151 1151
     public static function parseSize(string $size) : ConvertHelper_SizeNotation
1152 1152
     {
1153 1153
         return new ConvertHelper_SizeNotation($size);
1154 1154
     }
1155 1155
     
1156
-   /**
1157
-    * Creates a URL finder instance, which can be used to find
1158
-    * URLs in a string - be it plain text, or HTML.
1159
-    * 
1160
-    * @param string $subject
1161
-    * @return ConvertHelper_URLFinder
1162
-    */
1156
+    /**
1157
+     * Creates a URL finder instance, which can be used to find
1158
+     * URLs in a string - be it plain text, or HTML.
1159
+     * 
1160
+     * @param string $subject
1161
+     * @return ConvertHelper_URLFinder
1162
+     */
1163 1163
     public static function createURLFinder(string $subject) : ConvertHelper_URLFinder
1164 1164
     {
1165 1165
         return new ConvertHelper_URLFinder($subject);
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      * @param int $tabSize The amount of spaces per tab.
56 56
      * @return string
57 57
      */
58
-    public static function tabs2spaces(string $string, int $tabSize=4) : string
58
+    public static function tabs2spaces(string $string, int $tabSize = 4) : string
59 59
     {
60 60
         return ConvertHelper_String::tabs2spaces($string, $tabSize);
61 61
     }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     * @param int $tabSize The amount of spaces per tab in the source string.
68 68
     * @return string
69 69
     */
70
-    public static function spaces2tabs(string $string, int $tabSize=4) : string
70
+    public static function spaces2tabs(string $string, int $tabSize = 4) : string
71 71
     {
72 72
         return ConvertHelper_String::spaces2tabs($string, $tabSize);
73 73
     }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     * @deprecated Use the Highlighter class directly instead.
141 141
     * @see Highlighter::xml()
142 142
     */
143
-    public static function highlight_xml(string $xml, bool $formatSource=false) : string
143
+    public static function highlight_xml(string $xml, bool $formatSource = false) : string
144 144
     {
145 145
         return Highlighter::xml($xml, $formatSource);
146 146
     }
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
      * @param bool $html
207 207
      * @return string
208 208
      */
209
-    public static function var_dump($var, bool $html=true) : string
209
+    public static function var_dump($var, bool $html = true) : string
210 210
     {
211 211
         $info = parseVariable($var);
212 212
         
213
-        if($html) {
213
+        if ($html) {
214 214
             return $info->toHTML();
215 215
         }
216 216
         
@@ -225,11 +225,11 @@  discard block
 block discarded – undo
225 225
     * @param bool $html Whether to style the dump as HTML.
226 226
     * @return string
227 227
     */
228
-    public static function print_r($var, bool $return=false, bool $html=true) : string
228
+    public static function print_r($var, bool $return = false, bool $html = true) : string
229 229
     {
230 230
         $result = parseVariable($var)->enableType()->toString();
231 231
         
232
-        if($html) 
232
+        if ($html) 
233 233
         {
234 234
             $result = 
235 235
             '<pre style="background:#fff;color:#333;padding:16px;border:solid 1px #bbb;border-radius:4px">'.
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
             '</pre>';
238 238
         }
239 239
         
240
-        if(!$return) 
240
+        if (!$return) 
241 241
         {
242 242
             echo $result;
243 243
         }
@@ -419,12 +419,12 @@  discard block
 block discarded – undo
419 419
         $output = '';
420 420
         $split = str_split($unicodeChar);
421 421
         
422
-        foreach($split as $octet) 
422
+        foreach ($split as $octet) 
423 423
         {
424 424
             $ordInt = ord($octet);
425 425
             // Convert from int (base 10) to hex (base 16), for PHP \x syntax
426 426
             $ordHex = base_convert((string)$ordInt, 10, 16);
427
-            $output .= '\x' . $ordHex;
427
+            $output .= '\x'.$ordHex;
428 428
         }
429 429
         
430 430
         return $output;
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
     * 
639 639
     * @see JSHelper::buildRegexStatement()
640 640
     */
641
-    public static function regex2js(string $regex, string $statementType=JSHelper::JS_REGEX_OBJECT) : string
641
+    public static function regex2js(string $regex, string $statementType = JSHelper::JS_REGEX_OBJECT) : string
642 642
     {
643 643
         return JSHelper::buildRegexStatement($regex, $statementType);
644 644
     }
@@ -657,11 +657,11 @@  discard block
 block discarded – undo
657 657
     * @throws ConvertHelper_Exception
658 658
     * @see ConvertHelper::ERROR_JSON_ENCODE_FAILED
659 659
     */
660
-    public static function var2json($variable, int $options=0, int $depth=512) : string
660
+    public static function var2json($variable, int $options = 0, int $depth = 512) : string
661 661
     {
662 662
         $result = json_encode($variable, $options, $depth);
663 663
         
664
-        if($result !== false) {
664
+        if ($result !== false) {
665 665
             return $result;
666 666
         }
667 667
         
@@ -701,12 +701,12 @@  discard block
 block discarded – undo
701 701
     {
702 702
         $boms = FileHelper::getUTFBOMs();
703 703
 
704
-        foreach($boms as $bomChars)
704
+        foreach ($boms as $bomChars)
705 705
         {
706 706
             $length = mb_strlen($bomChars);
707 707
             $text = mb_substr($string, 0, $length);
708 708
 
709
-            if($text===$bomChars)
709
+            if ($text === $bomChars)
710 710
             {
711 711
                 return mb_substr($string, $length);
712 712
             }
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
     * @see ConvertHelper_TextComparer::OPTION_MAX_LEVENSHTEIN_DISTANCE
779 779
     * @see ConvertHelper_TextComparer::OPTION_PRECISION
780 780
     */
781
-    public static function matchString(string $source, string $target, array $options=array()) : float
781
+    public static function matchString(string $source, string $target, array $options = array()) : float
782 782
     {
783 783
         return (new ConvertHelper_TextComparer())
784 784
             ->setOptions($options)
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
     * @see ConvertHelper::INTERVAL_HOURS
857 857
     * @see ConvertHelper::INTERVAL_DAYS
858 858
     */
859
-    public static function interval2total(DateInterval $interval, string $unit=self::INTERVAL_SECONDS) : int
859
+    public static function interval2total(DateInterval $interval, string $unit = self::INTERVAL_SECONDS) : int
860 860
     {
861 861
         return ConvertHelper_DateInterval::toTotal($interval, $unit);
862 862
     }
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
     * @param bool $short
869 869
     * @return string|NULL
870 870
     */
871
-    public static function date2dayName(DateTime $date, bool $short=false) : ?string
871
+    public static function date2dayName(DateTime $date, bool $short = false) : ?string
872 872
     {
873 873
         return ConvertHelper_Date::toDayName($date, $short);
874 874
     }
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
     * @param bool $short
889 889
     * @return string[]
890 890
     */
891
-    public static function getDayNames(bool $short=false) : array
891
+    public static function getDayNames(bool $short = false) : array
892 892
     {
893 893
         return ConvertHelper_Date::getDayNames($short);
894 894
     }
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
     * @param bool $caseInsensitive
1048 1048
     * @return ConvertHelper_StringMatch[]
1049 1049
     */
1050
-    public static function findString(string $needle, string $haystack, bool $caseInsensitive=false): array
1050
+    public static function findString(string $needle, string $haystack, bool $caseInsensitive = false): array
1051 1051
     {
1052 1052
         return ConvertHelper_String::findString($needle, $haystack, $caseInsensitive);
1053 1053
     }
@@ -1097,17 +1097,17 @@  discard block
 block discarded – undo
1097 1097
     */
1098 1098
     public static function isInteger($value) : bool
1099 1099
     {
1100
-        if(is_int($value)) {
1100
+        if (is_int($value)) {
1101 1101
             return true;
1102 1102
         }
1103 1103
         
1104 1104
         // booleans get converted to numbers, so they would
1105 1105
         // actually match the regex.
1106
-        if(is_bool($value)) {
1106
+        if (is_bool($value)) {
1107 1107
             return false;
1108 1108
         }
1109 1109
         
1110
-        if(is_string($value) && $value !== '') {
1110
+        if (is_string($value) && $value !== '') {
1111 1111
             return preg_match('/\A-?\d+\z/', $value) === 1;
1112 1112
         }
1113 1113
         
@@ -1173,7 +1173,7 @@  discard block
 block discarded – undo
1173 1173
      * @param bool $keepKeys
1174 1174
      * @return array<number|string,mixed>
1175 1175
      */
1176
-    public static function arrayRemoveValues(array $sourceArray, array $values, bool $keepKeys=false) : array
1176
+    public static function arrayRemoveValues(array $sourceArray, array $values, bool $keepKeys = false) : array
1177 1177
     {
1178 1178
         return ConvertHelper_Array::removeValues($sourceArray, $values, $keepKeys);
1179 1179
     }
Please login to merge, or discard this patch.
src/ConvertHelper/TextComparer.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -87,14 +87,14 @@
 block discarded – undo
87 87
     public function match(string $source, string $target) : float
88 88
     {
89 89
         // avoid doing this via levenshtein
90
-        if($source === $target) {
90
+        if ($source === $target) {
91 91
             return 100;
92 92
         }
93 93
 
94 94
         $maxL = $this->getMaxDistance();
95 95
 
96 96
         $diff = levenshtein($source, $target);
97
-        if($diff > $maxL) {
97
+        if ($diff > $maxL) {
98 98
             return 0;
99 99
         }
100 100
 
Please login to merge, or discard this patch.
src/ConvertHelper/Comparator.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,19 +49,19 @@
 block discarded – undo
49 49
      */
50 50
     protected static function convertScalarForComparison($scalar) : ?string
51 51
     {
52
-        if($scalar === '' || is_null($scalar)) {
52
+        if ($scalar === '' || is_null($scalar)) {
53 53
             return null;
54 54
         }
55 55
 
56
-        if(is_bool($scalar)) {
56
+        if (is_bool($scalar)) {
57 57
             return ConvertHelper_Bool::toStringStrict($scalar);
58 58
         }
59 59
 
60
-        if(is_array($scalar)) {
60
+        if (is_array($scalar)) {
61 61
             $scalar = md5(serialize($scalar));
62 62
         }
63 63
 
64
-        if($scalar !== null && !is_scalar($scalar)) {
64
+        if ($scalar !== null && !is_scalar($scalar)) {
65 65
             throw new ConvertHelper_Exception(
66 66
                 'Not a scalar value in comparison',
67 67
                 null,
Please login to merge, or discard this patch.
src/ConvertHelper/String.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
      * @param bool $caseInsensitive
34 34
      * @return ConvertHelper_StringMatch[]
35 35
      */
36
-    public static function findString(string $needle, string $haystack, bool $caseInsensitive=false): array
36
+    public static function findString(string $needle, string $haystack, bool $caseInsensitive = false): array
37 37
     {
38
-        if($needle === '') {
38
+        if ($needle === '') {
39 39
             return array();
40 40
         }
41 41
 
42 42
         $function = 'mb_strpos';
43
-        if($caseInsensitive) {
43
+        if ($caseInsensitive) {
44 44
             $function = 'mb_stripos';
45 45
         }
46 46
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
         $positions = array();
49 49
         $length = mb_strlen($needle);
50 50
 
51
-        while( ($pos = $function($haystack, $needle, $pos)) !== false)
51
+        while (($pos = $function($haystack, $needle, $pos)) !== false)
52 52
         {
53 53
             $match = mb_substr($haystack, $pos, $length);
54 54
             $positions[] = new ConvertHelper_StringMatch($pos, $match);
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     public static function toArray(string $string) : array
72 72
     {
73 73
         $result = preg_split('//u', $string, 0, PREG_SPLIT_NO_EMPTY);
74
-        if($result !== false) {
74
+        if ($result !== false) {
75 75
             return $result;
76 76
         }
77 77
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      */
125 125
     public static function toUtf8(string $string) : string
126 126
     {
127
-        if(!self::isASCII($string)) {
127
+        if (!self::isASCII($string)) {
128 128
             return Encoding::toUTF8($string);
129 129
         }
130 130
 
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
      */
143 143
     public static function isASCII($string) : bool
144 144
     {
145
-        if($string === '' || $string === NULL) {
145
+        if ($string === '' || $string === NULL) {
146 146
             return true;
147 147
         }
148 148
 
149
-        if(!is_string($string)) {
149
+        if (!is_string($string)) {
150 150
             return false;
151 151
         }
152 152
 
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
      */
162 162
     public static function isHTML(string $string) : bool
163 163
     {
164
-        if(preg_match('%<[a-z/][\s\S]*>%siU', $string)) {
164
+        if (preg_match('%<[a-z/][\s\S]*>%siU', $string)) {
165 165
             return true;
166 166
         }
167 167
 
168 168
         $decoded = html_entity_decode($string);
169
-        if($decoded !== $string) {
169
+        if ($decoded !== $string) {
170 170
             return true;
171 171
         }
172 172
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
      * @param int $tabSize The amount of spaces per tab.
199 199
      * @return string
200 200
      */
201
-    public static function tabs2spaces(string $string, int $tabSize=4) : string
201
+    public static function tabs2spaces(string $string, int $tabSize = 4) : string
202 202
     {
203 203
         return str_replace("\t", str_repeat(' ', $tabSize), $string);
204 204
     }
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
      * @param int $tabSize The amount of spaces per tab in the source string.
211 211
      * @return string
212 212
      */
213
-    public static function spaces2tabs(string $string, int $tabSize=4) : string
213
+    public static function spaces2tabs(string $string, int $tabSize = 4) : string
214 214
     {
215 215
         return str_replace(str_repeat(' ', $tabSize), "\t", $string);
216 216
     }
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
             return $text;
290 290
         }
291 291
 
292
-        return trim(mb_substr($text, 0, $targetLength)) . $append;
292
+        return trim(mb_substr($text, 0, $targetLength)).$append;
293 293
     }
294 294
 
295 295
     /**
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
      */
303 303
     public static function explodeTrim(string $delimiter, string $string) : array
304 304
     {
305
-        if(empty($string) || empty($delimiter)) {
305
+        if (empty($string) || empty($delimiter)) {
306 306
             return array();
307 307
         }
308 308
 
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
         $tokens = array_map('trim', $tokens);
311 311
 
312 312
         $keep = array();
313
-        foreach($tokens as $token) {
314
-            if($token !== '') {
313
+        foreach ($tokens as $token) {
314
+            if ($token !== '') {
315 315
                 $keep[] = $token;
316 316
             }
317 317
         }
Please login to merge, or discard this patch.
src/RequestHelper/Exception.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
  */
23 23
 class RequestHelper_Exception extends BaseException
24 24
 {
25
-   /**
26
-    * @var RequestHelper_Response|NULL
27
-    */
25
+    /**
26
+     * @var RequestHelper_Response|NULL
27
+     */
28 28
     protected $response = null;
29 29
 
30 30
     /**
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
         return $this;
38 38
     }
39 39
     
40
-   /**
41
-    * Retrieves the related response instance, if available.
42
-    * 
43
-    * @return RequestHelper_Response|NULL
44
-    */
40
+    /**
41
+     * Retrieves the related response instance, if available.
42
+     * 
43
+     * @return RequestHelper_Response|NULL
44
+     */
45 45
     public function getResponse() : ?RequestHelper_Response
46 46
     {
47 47
         return $this->response;
Please login to merge, or discard this patch.
src/NumberInfo/Comparer.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
      */
56 56
     private function validate() : bool
57 57
     {
58
-        if($this->a->getUnits() !== $this->b->getUnits())
58
+        if ($this->a->getUnits() !== $this->b->getUnits())
59 59
         {
60 60
             return false;
61 61
         }
62 62
 
63
-        if($this->a->isEmpty() || $this->b->isEmpty())
63
+        if ($this->a->isEmpty() || $this->b->isEmpty())
64 64
         {
65 65
             return false;
66 66
         }
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
     public function isBiggerThan() : bool
72 72
     {
73
-        if($this->valid === false)
73
+        if ($this->valid === false)
74 74
         {
75 75
             return false;
76 76
         }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 
81 81
     public function isBiggerEqual() : bool
82 82
     {
83
-        if($this->valid === false)
83
+        if ($this->valid === false)
84 84
         {
85 85
             return false;
86 86
         }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
     public function isSmallerThan() : bool
92 92
     {
93
-        if($this->valid === false)
93
+        if ($this->valid === false)
94 94
         {
95 95
             return false;
96 96
         }
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 
101 101
     public function isSmallerEqual() : bool
102 102
     {
103
-        if($this->valid === false)
103
+        if ($this->valid === false)
104 104
         {
105 105
             return false;
106 106
         }
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
     public function isEqual() : bool
112 112
     {
113
-        if($this->valid === false)
113
+        if ($this->valid === false)
114 114
         {
115 115
             return false;
116 116
         }
Please login to merge, or discard this patch.
src/NumberInfo/Immutable.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     {
15 15
         $number = parseNumber($value, true);
16 16
 
17
-        if($number->getNumber() === $this->getNumber() && $number->hasUnits() === $this->hasUnits())
17
+        if ($number->getNumber() === $this->getNumber() && $number->hasUnits() === $this->hasUnits())
18 18
         {
19 19
             return $this;
20 20
         }
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
     {
31 31
         $number = parseNumber($number, true);
32 32
 
33
-        if($number->getNumber() === $this->getNumber() && $number->getUnits() === $this->getUnits())
33
+        if ($number->getNumber() === $this->getNumber() && $number->getUnits() === $this->getUnits())
34 34
         {
35 35
             return $this;
36 36
         }
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         $number = parseNumber($this, true);
48 48
         $number->add($value);
49 49
 
50
-        if($number->getNumber() === $this->getNumber())
50
+        if ($number->getNumber() === $this->getNumber())
51 51
         {
52 52
             return $this;
53 53
         }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         $number = parseNumber($this, true);
65 65
         $number->subtract($value);
66 66
 
67
-        if($number->getNumber() === $this->getNumber())
67
+        if ($number->getNumber() === $this->getNumber())
68 68
         {
69 69
             return $this;
70 70
         }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
         $number = parseNumber($this, true);
82 82
         $number->subtractPercent($percent);
83 83
 
84
-        if($number->getNumber() === $this->getNumber())
84
+        if ($number->getNumber() === $this->getNumber())
85 85
         {
86 86
             return $this;
87 87
         }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         $number = parseNumber($this, true);
99 99
         $number->addPercent($percent);
100 100
 
101
-        if($number->getNumber() === $this->getNumber())
101
+        if ($number->getNumber() === $this->getNumber())
102 102
         {
103 103
             return $this;
104 104
         }
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
         $number = parseNumber($this, true);
115 115
         $number->floorEven();
116 116
 
117
-        if($number->getNumber() === $this->getNumber())
117
+        if ($number->getNumber() === $this->getNumber())
118 118
         {
119 119
             return $this;
120 120
         }
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         $number = parseNumber($this, true);
131 131
         $number->ceilEven();
132 132
 
133
-        if($number->getNumber() === $this->getNumber())
133
+        if ($number->getNumber() === $this->getNumber())
134 134
         {
135 135
             return $this;
136 136
         }
Please login to merge, or discard this patch.
src/NumberInfo.php 3 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -40,19 +40,19 @@  discard block
 block discarded – undo
40 40
  */
41 41
 class NumberInfo
42 42
 {
43
-   /**
44
-    * @var string|int|float|null
45
-    */
43
+    /**
44
+     * @var string|int|float|null
45
+     */
46 46
     protected $rawValue;
47 47
     
48
-   /**
49
-    * @var array<string,mixed>
50
-    */
48
+    /**
49
+     * @var array<string,mixed>
50
+     */
51 51
     protected $info;
52 52
     
53
-   /**
54
-    * @var bool
55
-    */
53
+    /**
54
+     * @var bool
55
+     */
56 56
     protected $empty = false;
57 57
 
58 58
     /**
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 
63 63
     /**
64 64
      * Units and whether they allow decimal values.
65
-    * @var array<string,bool>
66
-    */
65
+     * @var array<string,bool>
66
+     */
67 67
     protected $knownUnits = array(
68 68
         '%' => true,
69 69
         'rem' => true,
@@ -141,21 +141,21 @@  discard block
 block discarded – undo
141 141
         return $this;
142 142
     }
143 143
     
144
-   /**
145
-    * Retrieves the raw, internal information array resulting
146
-    * from the parsing of the number.
147
-    *  
148
-    * @return array<string,mixed>
149
-    */
144
+    /**
145
+     * Retrieves the raw, internal information array resulting
146
+     * from the parsing of the number.
147
+     *  
148
+     * @return array<string,mixed>
149
+     */
150 150
     public function getRawInfo() : array
151 151
     {
152 152
         return $this->info;
153 153
     }
154 154
     
155
-   /**
156
-    * Whether the number was empty (null or empty string).
157
-    * @return boolean
158
-    */
155
+    /**
156
+     * Whether the number was empty (null or empty string).
157
+     * @return boolean
158
+     */
159 159
     public function isEmpty() : bool
160 160
     {
161 161
         return $this->empty;
@@ -729,12 +729,12 @@  discard block
 block discarded – undo
729 729
         return $cache[$key];
730 730
     }
731 731
     
732
-   /**
733
-    * Parses a string number notation with units included, e.g. 14px, 50%...
734
-    * 
735
-    * @param string $test
736
-    * @return array<string,mixed>
737
-    */
732
+    /**
733
+     * Parses a string number notation with units included, e.g. 14px, 50%...
734
+     * 
735
+     * @param string $test
736
+     * @return array<string,mixed>
737
+     */
738 738
     private function parseStringValue(string $test) : array
739 739
     {
740 740
         $number = null;
@@ -785,13 +785,13 @@  discard block
 block discarded – undo
785 785
         return $this->filterInfo($result);
786 786
     }
787 787
     
788
-   /**
789
-    * Attempts to determine what kind of units are specified
790
-    * in the string. Returns NULL if none could be matched.
791
-    * 
792
-    * @param string $value
793
-    * @return array<string,mixed>|NULL
794
-    */
788
+    /**
789
+     * Attempts to determine what kind of units are specified
790
+     * in the string. Returns NULL if none could be matched.
791
+     * 
792
+     * @param string $value
793
+     * @return array<string,mixed>|NULL
794
+     */
795 795
     private function findUnits(string $value) : ?array
796 796
     {
797 797
         $vlength = strlen($value);
@@ -819,12 +819,12 @@  discard block
 block discarded – undo
819 819
         return null;
820 820
     }
821 821
     
822
-   /**
823
-    * Creates the cache key for the specified value.
824
-    * 
825
-    * @param mixed $value
826
-    * @return string
827
-    */
822
+    /**
823
+     * Creates the cache key for the specified value.
824
+     * 
825
+     * @param mixed $value
826
+     * @return string
827
+     */
828 828
     private function createValueKey($value) : string
829 829
     {
830 830
         if(!is_string($value) && !is_numeric($value))
@@ -835,59 +835,59 @@  discard block
 block discarded – undo
835 835
         return (string)$value;
836 836
     }
837 837
 
838
-   /**
839
-    * Called if explicitly enabled: allows filtering the 
840
-    * number after the detection process has completed.
841
-    * 
842
-    * @param string|NULL $number The adjusted number
843
-    * @param string $originalString The original value before it was parsed
844
-    * @return string|null
845
-    */
838
+    /**
839
+     * Called if explicitly enabled: allows filtering the 
840
+     * number after the detection process has completed.
841
+     * 
842
+     * @param string|NULL $number The adjusted number
843
+     * @param string $originalString The original value before it was parsed
844
+     * @return string|null
845
+     */
846 846
     protected function postProcess(?string $number, /** @scrutinizer ignore-unused */ string $originalString)
847 847
     {
848 848
         return $number;
849 849
     }
850 850
     
851
-   /**
852
-    * Filters the value before it is parsed, but only if it is a string.
853
-    * 
854
-    * NOTE: This may be overwritten in a subclass, to allow custom filtering
855
-    * the values. An example of a use case would be a preprocessor for
856
-    * variables in a templating system.
857
-    * 
858
-    * @param string $trimmedString The trimmed value.
859
-    * @param array<string,mixed> $cache The internal values cache array.
860
-    * @param string $originalValue The original value that the NumberInfo was created for.
861
-    * @return string
862
-    * 
863
-    * @see NumberInfo::enablePostProcess()
864
-    */
851
+    /**
852
+     * Filters the value before it is parsed, but only if it is a string.
853
+     * 
854
+     * NOTE: This may be overwritten in a subclass, to allow custom filtering
855
+     * the values. An example of a use case would be a preprocessor for
856
+     * variables in a templating system.
857
+     * 
858
+     * @param string $trimmedString The trimmed value.
859
+     * @param array<string,mixed> $cache The internal values cache array.
860
+     * @param string $originalValue The original value that the NumberInfo was created for.
861
+     * @return string
862
+     * 
863
+     * @see NumberInfo::enablePostProcess()
864
+     */
865 865
     protected function preProcess(string $trimmedString, /** @scrutinizer ignore-unused */ array &$cache, /** @scrutinizer ignore-unused */ string $originalValue) : string
866 866
     {
867 867
         return str_replace(',', '.', $trimmedString);
868 868
     }
869 869
     
870
-   /**
871
-    * Enables the post-processing so the postProcess method gets called.
872
-    * This should be called in the {@link NumberInfo::preProcess()}
873
-    * method as needed.
874
-    * 
875
-    * @return $this
876
-    * @see NumberInfo::postProcess()
877
-    */
870
+    /**
871
+     * Enables the post-processing so the postProcess method gets called.
872
+     * This should be called in the {@link NumberInfo::preProcess()}
873
+     * method as needed.
874
+     * 
875
+     * @return $this
876
+     * @see NumberInfo::postProcess()
877
+     */
878 878
     protected function enablePostProcess() : NumberInfo
879 879
     {
880 880
         $this->postProcess = true;
881 881
         return $this;
882 882
     }
883 883
     
884
-   /**
885
-    * Filters the number info array to adjust the units
886
-    * and number according to the required rules.
887
-    * 
888
-    * @param array<string,mixed> $info
889
-    * @return array<string,mixed>
890
-    */
884
+    /**
885
+     * Filters the number info array to adjust the units
886
+     * and number according to the required rules.
887
+     * 
888
+     * @param array<string,mixed> $info
889
+     * @return array<string,mixed>
890
+     */
891 891
     protected function filterInfo(array $info) : array
892 892
     {
893 893
         $useUnits = 'px';
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
      */
131 131
     protected function _setValue($value)
132 132
     {
133
-        if($value instanceof NumberInfo) {
133
+        if ($value instanceof NumberInfo) {
134 134
             $value = $value->getValue();
135 135
         }
136 136
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
      */
171 171
     public function isPositive() : bool
172 172
     {
173
-        if($this->isEmpty())
173
+        if ($this->isEmpty())
174 174
         {
175 175
             return false;
176 176
         }
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
      */
186 186
     public function isZero() : bool
187 187
     {
188
-        if($this->isEmpty())
188
+        if ($this->isEmpty())
189 189
         {
190 190
             return false;
191 191
         }
@@ -231,23 +231,23 @@  discard block
 block discarded – undo
231 231
     {
232 232
         // Append the units if the value is a number,
233 233
         // so they can be inherited.
234
-        if($this->hasUnits() && is_numeric($number))
234
+        if ($this->hasUnits() && is_numeric($number))
235 235
         {
236 236
             $number .= $this->getUnits();
237 237
         }
238 238
 
239 239
         $new = parseNumber($number);
240 240
 
241
-        if($new->isEmpty())
241
+        if ($new->isEmpty())
242 242
         {
243 243
             return $this;
244 244
         }
245 245
 
246
-        if($new->getUnits() === $this->getUnits())
246
+        if ($new->getUnits() === $this->getUnits())
247 247
         {
248 248
             $value = $new->getNumber();
249 249
 
250
-            if($this->hasUnits()) {
250
+            if ($this->hasUnits()) {
251 251
                 $value .= $this->getUnits();
252 252
             }
253 253
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     {
290 290
         $number = (float)$this->info['number'];
291 291
 
292
-        if($this->hasDecimals())
292
+        if ($this->hasDecimals())
293 293
         {
294 294
             return $number;
295 295
         }
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
      */
326 326
     public function getUnits() : string
327 327
     {
328
-        if($this->isEmpty()) {
328
+        if ($this->isEmpty()) {
329 329
             return '';
330 330
         }
331 331
 
332
-        if(!$this->hasUnits()) {
332
+        if (!$this->hasUnits()) {
333 333
             return 'px';
334 334
         }
335 335
         
@@ -363,15 +363,15 @@  discard block
 block discarded – undo
363 363
      */
364 364
     public function toAttribute() : string
365 365
     {
366
-        if($this->isEmpty()) {
366
+        if ($this->isEmpty()) {
367 367
             return '';
368 368
         }
369 369
         
370
-        if($this->isZero()) {
370
+        if ($this->isZero()) {
371 371
             return '0';
372 372
         }
373 373
         
374
-        if($this->isPercent()) {
374
+        if ($this->isPercent()) {
375 375
             return $this->getNumber().$this->getUnits();
376 376
         }
377 377
         
@@ -384,11 +384,11 @@  discard block
 block discarded – undo
384 384
      */
385 385
     public function toCSS() : string
386 386
     {
387
-        if($this->isEmpty()) {
387
+        if ($this->isEmpty()) {
388 388
             return '';
389 389
         }
390 390
         
391
-        if($this->isZero()) {
391
+        if ($this->isZero()) {
392 392
             return '0';
393 393
         }
394 394
         
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
     
398 398
     public function __toString()
399 399
     {
400
-        if($this->isEmpty()) {
400
+        if ($this->isEmpty()) {
401 401
             return '';
402 402
         }
403 403
         
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
      */
504 504
     public function add($value)
505 505
     {
506
-        if($this->isEmpty())
506
+        if ($this->isEmpty())
507 507
         {
508 508
             $this->setValue($value);
509 509
             return $this;
@@ -511,11 +511,11 @@  discard block
 block discarded – undo
511 511
         
512 512
         $number = parseNumber($value);
513 513
         
514
-        if($number->getUnits() === $this->getUnits() || !$number->hasUnits())
514
+        if ($number->getUnits() === $this->getUnits() || !$number->hasUnits())
515 515
         {
516 516
             $new = $this->getNumber() + $number->getNumber();
517 517
 
518
-            if($this->hasUnits())
518
+            if ($this->hasUnits())
519 519
             {
520 520
                 $new .= $this->getUnits();
521 521
             }
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
      */
537 537
     public function subtract($value)
538 538
     {
539
-        if($this->isEmpty())
539
+        if ($this->isEmpty())
540 540
         {
541 541
             $this->setValue($value);
542 542
             return $this;
@@ -544,11 +544,11 @@  discard block
 block discarded – undo
544 544
         
545 545
         $number = parseNumber($value);
546 546
         
547
-        if($number->getUnits() == $this->getUnits() || !$number->hasUnits())
547
+        if ($number->getUnits() == $this->getUnits() || !$number->hasUnits())
548 548
         {
549 549
             $new = $this->getNumber() - $number->getNumber();
550 550
 
551
-            if($this->hasUnits())
551
+            if ($this->hasUnits())
552 552
             {
553 553
                 $new .= $this->getUnits();
554 554
             }
@@ -588,13 +588,13 @@  discard block
 block discarded – undo
588 588
      */
589 589
     protected function percentOperation(string $operation, $percent)
590 590
     {
591
-        if($this->isZeroOrEmpty()) {
591
+        if ($this->isZeroOrEmpty()) {
592 592
             return $this;
593 593
         }
594 594
         
595 595
         $percent = parseNumber($percent);
596 596
 
597
-        if($percent->hasUnits() && !$percent->isPercent())
597
+        if ($percent->hasUnits() && !$percent->isPercent())
598 598
         {
599 599
             return $this;
600 600
         }
@@ -602,18 +602,18 @@  discard block
 block discarded – undo
602 602
         $number = $this->getNumber();
603 603
         $value = $number * $percent->getNumber() / 100;
604 604
         
605
-        if($operation == '-') {
605
+        if ($operation == '-') {
606 606
             $number = $number - $value;
607 607
         } else {
608 608
             $number = $number + $value;
609 609
         }
610 610
         
611
-        if($this->isUnitInteger())
611
+        if ($this->isUnitInteger())
612 612
         {
613 613
             $number = intval($number);
614 614
         }
615 615
 
616
-        if($this->hasUnits())
616
+        if ($this->hasUnits())
617 617
         {
618 618
             $number .= $this->getUnits();
619 619
         }
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
     {
628 628
         $units = $this->getUnits();
629 629
 
630
-        if(isset($this->knownUnits[$units]))
630
+        if (isset($this->knownUnits[$units]))
631 631
         {
632 632
             return !$this->knownUnits[$units];
633 633
         }
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
     {
640 640
         $units = $this->getUnits();
641 641
 
642
-        if(isset($this->knownUnits[$units]))
642
+        if (isset($this->knownUnits[$units]))
643 643
         {
644 644
             return $this->knownUnits[$units];
645 645
         }
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
         
679 679
         $key = $this->createValueKey($value);
680 680
 
681
-        if(array_key_exists($key, $cache)) {
681
+        if (array_key_exists($key, $cache)) {
682 682
             return $cache[$key];
683 683
         }
684 684
         
@@ -688,13 +688,13 @@  discard block
 block discarded – undo
688 688
             'number' => null
689 689
         );
690 690
         
691
-        if($key === '_EMPTY_') 
691
+        if ($key === '_EMPTY_') 
692 692
         {
693 693
             $cache[$key]['empty'] = true;
694 694
             return $cache[$key];
695 695
         }
696 696
         
697
-        if($value === 0 || $value === '0') 
697
+        if ($value === 0 || $value === '0') 
698 698
         {
699 699
             $cache[$key]['number'] = 0;
700 700
             $cache[$key] = $this->filterInfo($cache[$key]);
@@ -703,20 +703,20 @@  discard block
 block discarded – undo
703 703
         
704 704
         $test = trim((string)$value);
705 705
         
706
-        if($test === '') 
706
+        if ($test === '') 
707 707
         {
708 708
             $cache[$key]['empty'] = true;
709 709
             return $cache[$key];
710 710
         }
711 711
         
712 712
         // replace comma notation (which is only possible if it's a string)
713
-        if(is_string($value))
713
+        if (is_string($value))
714 714
         {
715 715
             $test = $this->preProcess($test, $cache, $value);
716 716
         }
717 717
         
718 718
         // convert to a number if it's numeric
719
-        if(is_numeric($test)) 
719
+        if (is_numeric($test)) 
720 720
         {
721 721
             $cache[$key]['number'] = (float)$test * 1;
722 722
             $cache[$key] = $this->filterInfo($cache[$key]);
@@ -742,19 +742,19 @@  discard block
 block discarded – undo
742 742
         $empty = false;
743 743
         
744 744
         $found = $this->findUnits($test);
745
-        if($found !== null) 
745
+        if ($found !== null) 
746 746
         {
747 747
             $number = $found['number'];
748 748
             $units = $found['units'];
749 749
         }
750 750
         
751 751
         // the filters have to restore the value
752
-        if($this->postProcess)
752
+        if ($this->postProcess)
753 753
         {
754 754
             $number = $this->postProcess($number, $test);
755 755
         }
756 756
         // empty number
757
-        else if($number === '' || $number === null || is_bool($number))
757
+        else if ($number === '' || $number === null || is_bool($number))
758 758
         {
759 759
             $number = null;
760 760
             $empty = true;
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
             $number = trim($number);
766 766
             
767 767
             // may be an arbitrary string in some cases
768
-            if(!is_numeric($number))
768
+            if (!is_numeric($number))
769 769
             {
770 770
                 $number = null;
771 771
                 $empty = true;
@@ -797,17 +797,17 @@  discard block
 block discarded – undo
797 797
         $vlength = strlen($value);
798 798
         $names = array_keys($this->knownUnits);
799 799
         
800
-        foreach($names as $unit)
800
+        foreach ($names as $unit)
801 801
         {
802 802
             $ulength = strlen($unit);
803
-            $start = $vlength-$ulength;
804
-            if($start < 0) {
803
+            $start = $vlength - $ulength;
804
+            if ($start < 0) {
805 805
                 continue;
806 806
             }
807 807
             
808 808
             $search = substr($value, $start, $ulength);
809 809
             
810
-            if($search==$unit) 
810
+            if ($search == $unit) 
811 811
             {
812 812
                 return array(
813 813
                     'units' => $unit,
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
     */
828 828
     private function createValueKey($value) : string
829 829
     {
830
-        if(!is_string($value) && !is_numeric($value))
830
+        if (!is_string($value) && !is_numeric($value))
831 831
         {
832 832
             return '_EMPTY_';
833 833
         }
@@ -891,12 +891,12 @@  discard block
 block discarded – undo
891 891
     protected function filterInfo(array $info) : array
892 892
     {
893 893
         $useUnits = 'px';
894
-        if($info['units'] !== null) {
894
+        if ($info['units'] !== null) {
895 895
             $useUnits = $info['units'];
896 896
         }
897 897
         
898 898
         // the units are non-decimal: convert decimal values
899
-        if($this->knownUnits[$useUnits] === false && !$info['empty'] && is_numeric($info['number']))
899
+        if ($this->knownUnits[$useUnits] === false && !$info['empty'] && is_numeric($info['number']))
900 900
         {
901 901
             $info['number'] = intval($info['number']);
902 902
         }
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
     {
923 923
         $number = floor($this->getNumber());
924 924
 
925
-        if($number % 2 == 1) $number--;
925
+        if ($number % 2 == 1) $number--;
926 926
 
927 927
         return $this->setNumber($number);
928 928
     }
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
     {
939 939
         $number = ceil($this->getNumber());
940 940
 
941
-        if($number % 2 == 1) $number++;
941
+        if ($number % 2 == 1) $number++;
942 942
 
943 943
         return $this->setNumber($number);
944 944
     }
Please login to merge, or discard this patch.
Braces   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -769,8 +769,7 @@  discard block
 block discarded – undo
769 769
             {
770 770
                 $number = null;
771 771
                 $empty = true;
772
-            }
773
-            else
772
+            } else
774 773
             {
775 774
                 $number = (float)$number * 1;
776 775
             }
@@ -922,7 +921,9 @@  discard block
 block discarded – undo
922 921
     {
923 922
         $number = floor($this->getNumber());
924 923
 
925
-        if($number % 2 == 1) $number--;
924
+        if($number % 2 == 1) {
925
+            $number--;
926
+        }
926 927
 
927 928
         return $this->setNumber($number);
928 929
     }
@@ -938,7 +939,9 @@  discard block
 block discarded – undo
938 939
     {
939 940
         $number = ceil($this->getNumber());
940 941
 
941
-        if($number % 2 == 1) $number++;
942
+        if($number % 2 == 1) {
943
+            $number++;
944
+        }
942 945
 
943 946
         return $this->setNumber($number);
944 947
     }
Please login to merge, or discard this patch.