]> git.mxchange.org Git - core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 25 Feb 2023 04:03:41 +0000 (05:03 +0100)
committerRoland Häder <roland@mxchange.org>
Sat, 25 Feb 2023 04:03:41 +0000 (05:03 +0100)
- zero can be an indexed array key, so it is valid, only below zero isn't

framework/main/classes/utils/strings/class_StringUtils.php

index 7c6eb7bde6e8d9f6c7932d00a146f87633517fe0..c97c9fe3d23c0c3247fa8fb7b3e691bbedeef494 100644 (file)
@@ -314,9 +314,9 @@ final class StringUtils extends BaseFrameworkSystem {
        public static function dec2hex (int $dec, int $maxLength = 0) {
                // Check parameter
                //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: dec=%d,maxLength=%d - CALLED!', $dec, $maxLength));
-               if (empty($dec)) {
+               if ($dec < 0) {
                        // Throw IAE
-                       throw new InvalidArgumentException('Parameter "dec" is empty');
+                       throw new InvalidArgumentException(sprintf('dec=%d is below zero', $dec));
                } elseif ($maxLength != 0 && ($maxLength % 2) != 0) {
                        // Throw it again
                        throw new InvalidArgumentException(sprintf('maxLength=%d is not dividable by 2 or zero', $maxLength));
@@ -391,9 +391,9 @@ final class StringUtils extends BaseFrameworkSystem {
        public static function dec2asc (int $dec) {
                // Check parameter
                //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('STRING-UTILS: dec=%d - CALLED!', $dec));
-               if (empty($dec)) {
+               if ($dec < 0) {
                        // Throw IAE
-                       throw new InvalidArgumentException('Parameter "dec" is empty');
+                       throw new InvalidArgumentException(sprintf('dec=%d is below zero', $dec));
                }
 
                // First convert the number into a hexadecimal string