Passed
Branch master (3119af)
by Eric
01:41
created
src/Utility/Utility.php 2 patches
Spacing   +38 added lines, -39 removed lines patch added patch discarded remove patch
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
 
141 141
         foreach ($array AS $key => $value) {
142 142
             if (is_array($value) AND $value !== []) {
143
-                $result[] = static::arrayFlatten($value, $separator, $prepend . $key . $separator);
143
+                $result[] = static::arrayFlatten($value, $separator, $prepend.$key.$separator);
144 144
             } else {
145
-                $result[] = [$prepend . $key => $value];
145
+                $result[] = [$prepend.$key => $value];
146 146
             }
147 147
         }
148 148
 
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
      */
306 306
     public static function lcfirst(string $string): string
307 307
     {
308
-        return self::lower(self::substr($string, 0, 1)) . self::substr($string, 1);
308
+        return self::lower(self::substr($string, 0, 1)).self::substr($string, 1);
309 309
     }
310 310
 
311 311
     /**
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
      */
321 321
     public static function ucfirst(string $string): string
322 322
     {
323
-        return self::upper(self::substr($string, 0, 1)) . self::substr($string, 1);
323
+        return self::upper(self::substr($string, 0, 1)).self::substr($string, 1);
324 324
     }
325 325
 
326 326
     /**
@@ -566,22 +566,22 @@  discard block
 block discarded – undo
566 566
         // preg_replace can return null if an error occurs. It shouldn't happen, but if it does,
567 567
         // we return what we have processed thus far
568 568
         $title = (
569
-            preg_replace('![' . preg_quote(($separator === '-' ? '_' : '-')) . ']+!u', $separator, $title)
569
+            preg_replace('!['.preg_quote(($separator === '-' ? '_' : '-')).']+!u', $separator, $title)
570 570
             ?? $title
571 571
         );
572 572
 
573 573
         // Replace @ with the word 'at'
574
-        $title = str_replace('@', $separator . 'at' . $separator, $title);
574
+        $title = str_replace('@', $separator.'at'.$separator, $title);
575 575
 
576 576
         // Remove all characters that are not the separator, letters, numbers, or whitespace.
577 577
         $title = (
578
-            preg_replace('![^' . preg_quote($separator) . '\pL\pN\s]+!u', '', static::lower($title))
578
+            preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', static::lower($title))
579 579
             ?? $title
580 580
         );
581 581
 
582 582
         // Replace all separator characters and whitespace by a single separator
583 583
         $title = (
584
-            preg_replace('![' . preg_quote($separator) . '\s]+!u', $separator, $title)
584
+            preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title)
585 585
             ?? $title
586 586
         );
587 587
 
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
             $bytes = random_bytes($length);
613 613
         } catch (RandomException | Exception $e) {
614 614
             throw new RandomException(
615
-                'Utility was unable to generate random bytes: ' . $e->getMessage(), $e->getCode(), $e->getPrevious()
615
+                'Utility was unable to generate random bytes: '.$e->getMessage(), $e->getCode(), $e->getPrevious()
616 616
             );
617 617
         }
618 618
         return $bytes;
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
             $int = random_int($min, $max);
650 650
         } catch (RandomException | Exception $e) {
651 651
             throw new RandomException(
652
-                'Utility was unable to generate random int: ' . $e->getMessage(), $e->getCode(), $e->getPrevious()
652
+                'Utility was unable to generate random int: '.$e->getMessage(), $e->getCode(), $e->getPrevious()
653 653
             );
654 654
         }
655 655
         return $int;
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
                     continue;
754 754
                 }
755 755
 
756
-                $content = file($val->getPath() . DIRECTORY_SEPARATOR . $val->getFilename(), $flags);
756
+                $content = file($val->getPath().DIRECTORY_SEPARATOR.$val->getFilename(), $flags);
757 757
 
758 758
                 if ($content === false) {
759 759
                     continue;
@@ -888,11 +888,11 @@  discard block
 block discarded – undo
888 888
     public static function normalizeFilePath(string $path, string $separator = DIRECTORY_SEPARATOR): string
889 889
     {
890 890
         // Clean up our path
891
-        $path = rtrim(strtr($path, '/\\', $separator . $separator), $separator);
891
+        $path = rtrim(strtr($path, '/\\', $separator.$separator), $separator);
892 892
 
893 893
         if (
894
-            static::doesNotContain($separator . $path, "{$separator}.")
895
-            AND static::doesNotContain($path, $separator . $separator)
894
+            static::doesNotContain($separator.$path, "{$separator}.")
895
+            AND static::doesNotContain($path, $separator.$separator)
896 896
         ) {
897 897
             return $path;
898 898
         }
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
         // Otherwise, if on Windows...
937 937
         if (is_dir($file)) {
938 938
             // Generate random filename.
939
-            $file = rtrim($file, '\\/') . DIRECTORY_SEPARATOR;
939
+            $file = rtrim($file, '\\/').DIRECTORY_SEPARATOR;
940 940
             $file .= hash('md5', static::randomString());
941 941
 
942 942
             if (($fp = fopen($file, 'ab')) === false) {
@@ -1272,15 +1272,15 @@  discard block
 block discarded – undo
1272 1272
         $bytes = floatval($bytes);
1273 1273
 
1274 1274
         return match (true) {
1275
-            $bytes >= $pow['yotta'] => number_format(($bytes / $pow['yotta']), $decimals, '.', '') . ' YiB',
1276
-            $bytes >= $pow['zeta']  => number_format(($bytes / $pow['zeta']), $decimals, '.', '') . ' ZiB',
1277
-            $bytes >= $pow['exa']   => number_format(($bytes / $pow['exa']), $decimals, '.', '') . ' EiB',
1278
-            $bytes >= $pow['peta']  => number_format(($bytes / $pow['peta']), $decimals, '.', '') . ' PiB',
1279
-            $bytes >= $pow['tera']  => number_format(($bytes / $pow['tera']), $decimals, '.', '') . ' TiB',
1280
-            $bytes >= $pow['giga']  => number_format(($bytes / $pow['giga']), $decimals, '.', '') . ' GiB',
1281
-            $bytes >= $pow['mega']  => number_format(($bytes / $pow['mega']), $decimals, '.', '') . ' MiB',
1282
-            $bytes >= $pow['kilo']  => number_format(($bytes / $pow['kilo']), $decimals, '.', '') . ' KiB',
1283
-            default => number_format($bytes, $decimals, '.', '') . ' B'
1275
+            $bytes >= $pow['yotta'] => number_format(($bytes / $pow['yotta']), $decimals, '.', '').' YiB',
1276
+            $bytes >= $pow['zeta']  => number_format(($bytes / $pow['zeta']), $decimals, '.', '').' ZiB',
1277
+            $bytes >= $pow['exa']   => number_format(($bytes / $pow['exa']), $decimals, '.', '').' EiB',
1278
+            $bytes >= $pow['peta']  => number_format(($bytes / $pow['peta']), $decimals, '.', '').' PiB',
1279
+            $bytes >= $pow['tera']  => number_format(($bytes / $pow['tera']), $decimals, '.', '').' TiB',
1280
+            $bytes >= $pow['giga']  => number_format(($bytes / $pow['giga']), $decimals, '.', '').' GiB',
1281
+            $bytes >= $pow['mega']  => number_format(($bytes / $pow['mega']), $decimals, '.', '').' MiB',
1282
+            $bytes >= $pow['kilo']  => number_format(($bytes / $pow['kilo']), $decimals, '.', '').' KiB',
1283
+            default => number_format($bytes, $decimals, '.', '').' B'
1284 1284
         };
1285 1285
     }
1286 1286
 
@@ -1336,19 +1336,19 @@  discard block
 block discarded – undo
1336 1336
         $difference = $timestampFrom->diff($timestampTo);
1337 1337
 
1338 1338
         $string = match (true) {
1339
-            $difference->y > 0 => $difference->y . ' year(s)',
1340
-            $difference->m > 0 => $difference->m . ' month(s)',
1339
+            $difference->y > 0 => $difference->y.' year(s)',
1340
+            $difference->m > 0 => $difference->m.' month(s)',
1341 1341
             $difference->d > 0 => (
1342 1342
             $difference->d >= 7
1343
-                ? ceil($difference->d / 7) . ' week(s)'
1344
-                : $difference->d . ' day(s)'
1343
+                ? ceil($difference->d / 7).' week(s)'
1344
+                : $difference->d.' day(s)'
1345 1345
             ),
1346
-            $difference->h > 0 => $difference->h . ' hour(s)',
1347
-            $difference->i > 0 => $difference->i . ' minute(s)',
1348
-            $difference->s > 0 => $difference->s . ' second(s)',
1346
+            $difference->h > 0 => $difference->h.' hour(s)',
1347
+            $difference->i > 0 => $difference->i.' minute(s)',
1348
+            $difference->s > 0 => $difference->s.' second(s)',
1349 1349
             default => ''
1350 1350
         };
1351
-        return $string . $append;
1351
+        return $string.$append;
1352 1352
     }
1353 1353
 
1354 1354
     /**
@@ -1474,7 +1474,7 @@  discard block
 block discarded – undo
1474 1474
         // Split and process
1475 1475
         $email = str_split($email);
1476 1476
         $email = array_map(function($char) {
1477
-            return '&#' . ord($char) . ';';
1477
+            return '&#'.ord($char).';';
1478 1478
         }, $email);
1479 1479
         return implode('', $email);
1480 1480
     }
@@ -1493,8 +1493,7 @@  discard block
 block discarded – undo
1493 1493
         /** @var string $host **/
1494 1494
         $host = (
1495 1495
             ($acceptForwarded AND isset($_SERVER['HTTP_X_FORWARDED_HOST'])) ? 
1496
-            $_SERVER['HTTP_X_FORWARDED_HOST'] : 
1497
-            ($_SERVER['HTTP_HOST'] ?? $_SERVER['SERVER_NAME'] ?? '')
1496
+            $_SERVER['HTTP_X_FORWARDED_HOST'] : ($_SERVER['HTTP_HOST'] ?? $_SERVER['SERVER_NAME'] ?? '')
1498 1497
         );
1499 1498
         $host = trim(strval($host));
1500 1499
 
@@ -1611,7 +1610,7 @@  discard block
 block discarded – undo
1611 1610
         /** @var string $request **/
1612 1611
         $request = $_SERVER['REQUEST_URI'] ?? '';
1613 1612
         /** @var string $path **/
1614
-        $path = ($request === '' ? $self . ($query !== '' ? '?' . $query : '') : $request);
1613
+        $path = ($request === '' ? $self.($query !== '' ? '?'.$query : '') : $request);
1615 1614
 
1616 1615
         // Put it all together
1617 1616
         /** @var string $url **/
@@ -1642,7 +1641,7 @@  discard block
 block discarded – undo
1642 1641
         } else {
1643 1642
             $suffix = $suffixes[0];
1644 1643
         }
1645
-        return $number . $suffix;
1644
+        return $number.$suffix;
1646 1645
     }
1647 1646
 
1648 1647
     /**
@@ -1732,7 +1731,7 @@  discard block
 block discarded – undo
1732 1731
             header("Status: $code $message", $replace);
1733 1732
         } else {
1734 1733
             header(
1735
-                ($_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.1') . " $code $message",
1734
+                ($_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.1')." $code $message",
1736 1735
                 $replace,
1737 1736
                 $code
1738 1737
             );
@@ -1764,7 +1763,7 @@  discard block
 block discarded – undo
1764 1763
                 static::randomInt(0, 0xffff)
1765 1764
             );
1766 1765
         } catch (RandomException | Exception $e) {
1767
-            throw new RandomException('Unable to generate GUID: ' . $e->getMessage(), 0, $e);
1766
+            throw new RandomException('Unable to generate GUID: '.$e->getMessage(), 0, $e);
1768 1767
         }
1769 1768
         return $guid;
1770 1769
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1798,8 +1798,7 @@
 block discarded – undo
1798 1798
 
1799 1799
         try {
1800 1800
             $tz = new DateTimeZone($timezone);
1801
-        }
1802
-        catch (Exception $e) {
1801
+        } catch (Exception $e) {
1803 1802
             throw new InvalidArgumentException($e->getMessage(), 0, $e);
1804 1803
         }
1805 1804
 
Please login to merge, or discard this patch.