mirror of
https://github.com/archtechx/money.git
synced 2025-12-12 11:24:03 +00:00
fix: make PHPStan happy by protecting against some rare scenarios
This commit is contained in:
parent
38c6326a4d
commit
77bec6ed02
1 changed files with 4 additions and 0 deletions
|
|
@ -35,6 +35,10 @@ class PriceFormatter
|
|||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue