API reference / Quittio \ Core \ View
IntlFormatter
final class in quittio/core · implements Formatter
Quittio\Core\View\IntlFormatter · Source
Locale aware formatting with ext-intl and a fallback for German and English conventions.
Numbers are formatted from their exact decimal string, never via float.
Methods#
| Method | Description |
|---|---|
->date() | Formats the date as dd.MM.yyyy for de, dd/MM/yyyy for fr, it, es, pt, nl and en, and MM/dd/yyyy for en_US; other locales use the ICU medium format. Without ext-intl d.m.Y for de, otherwise d/m/Y. |
->money() | Formats the amount with two decimals, grouped by the locale, and the currency: a symbol for EUR, USD and GBP (in front for USD and GBP in English locales, otherwise behind), else the code. |
->percent() | Formats the percentage without trailing zeros, e.g. "19%" in English locales and "19 %" (with a no-break space) in others. |
->price() | |
->quantity() | Formats the quantity with the locale's separators and as many decimals as it has without trailing zeros, e.g. "1.250,5" for locale de. |
date()#
public function date(Date $date, string $locale): stringFormats the date as dd.MM.yyyy for de, dd/MM/yyyy for fr, it, es, pt, nl and en, and MM/dd/yyyy for en_US; other locales use the ICU medium format. Without ext-intl d.m.Y for de, otherwise d/m/Y.
| Parameter | Type | Description |
|---|---|---|
$date | Date | |
$locale | string |
- Returns
string
money()#
public function money(Money $money, string $locale): stringFormats the amount with two decimals, grouped by the locale, and the currency: a symbol for EUR, USD and GBP (in front for USD and GBP in English locales, otherwise behind), else the code.
| Parameter | Type | Description |
|---|---|---|
$money | Brick\Money\Money | |
$locale | string |
- Returns
string
percent()#
public function percent(BigDecimal $percent, string $locale): stringFormats the percentage without trailing zeros, e.g. "19%" in English locales and "19 %" (with a no-break space) in others.
| Parameter | Type | Description |
|---|---|---|
$percent | Brick\Math\BigDecimal | |
$locale | string |
- Returns
string
price()#
public function price(BigDecimal $price, string $currency, string $locale): string| Parameter | Type | Description |
|---|---|---|
$price | Brick\Math\BigDecimal | |
$currency | string | |
$locale | string |
- Returns
string
quantity()#
public function quantity(BigDecimal $quantity, string $locale): stringFormats the quantity with the locale's separators and as many decimals as it has without trailing zeros, e.g. "1.250,5" for locale de.
| Parameter | Type | Description |
|---|---|---|
$quantity | Brick\Math\BigDecimal | |
$locale | string |
- Returns
string