diff --git a/src/Miscellaneous/Utilities.php b/src/Miscellaneous/Utilities.php index a5766dc..419fe35 100644 --- a/src/Miscellaneous/Utilities.php +++ b/src/Miscellaneous/Utilities.php @@ -87,7 +87,7 @@ public static function isNotExceedMax($value) if (self::isValidString($value) || self::isValidDouble($value)) { $parts = explode('.', $value); $integerPart = intval($parts[0]); - $decimalPart = intval($parts[1]); + $decimalPart = intval($parts[1] ?? 0); $validateInteger = is_numeric($integerPart) && filter_var($integerPart, FILTER_VALIDATE_INT) !== false; $validateDecimal = is_numeric($decimalPart) && filter_var($decimalPart, FILTER_VALIDATE_INT) !== false; diff --git a/src/SpellNumber.php b/src/SpellNumber.php index 3c133f5..a2a2162 100644 --- a/src/SpellNumber.php +++ b/src/SpellNumber.php @@ -154,6 +154,11 @@ private function integerToLetters() private function doubleToLetters() { $parts = explode('.', $this->value); + + if (!array_key_exists(1, $parts)) { + return $this->integerToLetters(); + } + $letters1 = NumberFormatterWrapper::format($parts[0], $this->locale); $letters2 = NumberFormatterWrapper::format($parts[1], $this->locale); @@ -181,6 +186,11 @@ private function integerToMoney() private function doubleToMoney() { $parts = explode('.', $this->value); + + if (!array_key_exists(1, $parts)) { + return $this->integerToMoney(); + } + $letters1 = NumberFormatterWrapper::format($parts[0], $this->locale); $letters1 = Replaces::locale($letters1, $this->locale, $this->currency);