moneyphp / money

PHP implementation of Fowler's Money pattern.
http://moneyphp.org
MIT License
4.62k stars 440 forks source link

Unable to parse SDG. #699

Closed birdy247 closed 1 year ago

birdy247 commented 2 years ago

When trying to parse S$10.00 We receive this error

Upon investigation it appears to fail on line 49 on the IntlMoneyParser.php because the PHP NumberFormatter returns false i.e. its unable to parse it to a decimal.

PHP 7.2

Any ideas?

UlrichEckhardt commented 2 years ago

Can you provide example code that reproduces this? Also, which version are you using?

I'd consider upgrading PHP, just btw, at least to the latest version 7 or maybe even 8.

birdy247 commented 2 years ago

`

    $currencies = new ISOCurrencies();

    $numberFormatter = new \NumberFormatter('en_GB', \NumberFormatter::CURRENCY);
    $moneyParser = new IntlMoneyParser($numberFormatter, $currencies);
    $money = $moneyParser->parse($value);

    return $money->getAmount();

`

version: 3.2.1

birdy247 commented 2 years ago

@UlrichEckhardt Just checking you saw this. Any ideas (other than the PHP version)? Thanks in advance

UlrichEckhardt commented 2 years ago

Oh, yes, saw it but slipped underneath the radar again... Just for completeness, can you set the value of $value in your code snippet?

UlrichEckhardt commented 2 years ago

Also, the NumberFormatter, how would that format the numeric value you're expecting as a result from parsing? The idea is to turn the process around, just to rule out that the input does not have the format expected by the parser.

frederikbosch commented 1 year ago

PHP 7.2, no support anymore.