commerceguys / intl

A PHP internationalization library, powered by CLDR data.
MIT License
361 stars 45 forks source link

Split NumberFormatter into NumberFormatter and CurrencyFormatter #62

Closed bojanz closed 6 years ago

bojanz commented 6 years ago

The current formatter does two distinct jobs: formats both numbers and currency amounts. This allows it to be configured in weird ways, for example, you can instantiate it using the decimal/percent style, then use it to format currencies, and vice-versa. Recently I've been cleaning it up to behave more like a regular service, injecting the number format repository, etc. I want to do the same for currency formatting, to inject a currency repository and accept a currency code, instead of requiring callers to care about currency objects. But it's odd to have to inject the currency repository even when you just want to format regular numbers.

All of this makes it obvious that the code would be simpler when split, so let's go for it.