Zum Inhalt springen

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#

MethodDescription
->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): string

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.

ParameterTypeDescription
$dateDate
$localestring
Returns
string

money()#

public function money(Money $money, string $locale): string

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.

ParameterTypeDescription
$moneyBrick\Money\Money
$localestring
Returns
string

percent()#

public function percent(BigDecimal $percent, string $locale): string

Formats the percentage without trailing zeros, e.g. "19%" in English locales and "19 %" (with a no-break space) in others.

ParameterTypeDescription
$percentBrick\Math\BigDecimal
$localestring
Returns
string

price()#

public function price(BigDecimal $price, string $currency, string $locale): string
ParameterTypeDescription
$priceBrick\Math\BigDecimal
$currencystring
$localestring
Returns
string

quantity()#

public function quantity(BigDecimal $quantity, string $locale): string

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.

ParameterTypeDescription
$quantityBrick\Math\BigDecimal
$localestring
Returns
string

Die Open-Core-Pakete stehen unter der MIT-Lizenz. Die rechtlichen Formulierungen der Länderpakete sind mit einer Steuerberatung abzustimmen.