From: Roland Häder Date: Sat, 25 Feb 2023 04:03:41 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ba76f1380ebef3021b78d122cbabd6fe3173cd47;p=core.git Continued: - zero can be an indexed array key, so it is valid, only below zero isn't --- diff --git a/framework/main/classes/utils/strings/class_StringUtils.php b/framework/main/classes/utils/strings/class_StringUtils.php index 7c6eb7bd..c97c9fe3 100644 --- a/framework/main/classes/utils/strings/class_StringUtils.php +++ b/framework/main/classes/utils/strings/class_StringUtils.php @@ -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