API reference / Quittio \ Core \ View
Formatter
interface in quittio/core
Quittio\Core\View\Formatter · Source
Formats values for display according to a locale.
Methods#
| Method | Description |
|---|---|
->date() | Formats a date by the conventions of the locale, e.g. "03.10.2026" for locale de. |
->money() | Formats an amount with two decimals and its currency, e.g. "1.234,50 €" for locale de. |
->percent() | Formats a percentage such as a VAT rate (BT-152), e.g. "19 %" for locale de. |
->price() | Prices may have more decimals than amounts; at least two are shown. |
->quantity() | Formats a quantity with as many decimals as it has, without trailing zeros, e.g. "1,5". |
date()#
public function date(Date $date, string $locale): stringFormats a date by the conventions of the locale, e.g. "03.10.2026" for locale de.
| Parameter | Type | Description |
|---|---|---|
$date | Date | |
$locale | string |
- Returns
string
money()#
public function money(Money $money, string $locale): stringFormats an amount with two decimals and its currency, e.g. "1.234,50 €" for locale de.
| Parameter | Type | Description |
|---|---|---|
$money | Brick\Money\Money | |
$locale | string |
- Returns
string
percent()#
public function percent(BigDecimal $percent, string $locale): stringFormats a percentage such as a VAT rate (BT-152), e.g. "19 %" for locale de.
| Parameter | Type | Description |
|---|---|---|
$percent | Brick\Math\BigDecimal | |
$locale | string |
- Returns
string
price()#
public function price(BigDecimal $price, string $currency, string $locale): stringPrices may have more decimals than amounts; at least two are shown.
| Parameter | Type | Description |
|---|---|---|
$price | Brick\Math\BigDecimal | |
$currency | string | |
$locale | string |
- Returns
string
quantity()#
public function quantity(BigDecimal $quantity, string $locale): stringFormats a quantity with as many decimals as it has, without trailing zeros, e.g. "1,5".
| Parameter | Type | Description |
|---|---|---|
$quantity | Brick\Math\BigDecimal | |
$locale | string |
- Returns
string