1
0
Fork 0
mirror of https://github.com/archtechx/money.git synced 2025-12-12 03:14:03 +00:00

fix: make PHPStan happy by protecting against some rare scenarios

This commit is contained in:
Gaurav 2022-03-09 13:06:40 +05:30
parent 38c6326a4d
commit 77bec6ed02

View file

@ -35,6 +35,10 @@ class PriceFormatter
$removeNonDigits = preg_replace('/[^\d'.preg_quote($currency->decimalSeparator()).']/', '', $formatted); $removeNonDigits = preg_replace('/[^\d'.preg_quote($currency->decimalSeparator()).']/', '', $formatted);
if (!is_string($removeNonDigits)) {
throw new \Exception('The formatted string could not be resolved to a valid number.');
}
return (float) str_replace($currency->decimalSeparator(), '.', $removeNonDigits); return (float) str_replace($currency->decimalSeparator(), '.', $removeNonDigits);
} }
} }