Skip to content

rmrbest/MoneyFormatter

 
 

Repository files navigation

Money Formatter

Build Status

Class to convert Mathias Verraes Money value objects to the base unit representation of the given currency (float) or to a string representation given a locale, using php's intl extension.

To do so it leverages the info provided by the iso4217 library from Alcohol in order to know the exact number of decimal places that each currency uses.

##Installation ###Composer This library is available in packagist.org, you can add it to your project via Composer.

In the "require" section of your composer.json file:

Always up to date (bleeding edge, API not guaranteed stable)

"antonienko/money-formatter": "dev-master"

Specific minor version, API stability

"antonienko/money-formatter": "1.0.*"

##Sample Usage

use antonienko\MoneyFormatter\MoneyFormatter;
use Money\Currency;
use Money\Money;

$money = new Money(300005, new Currency('EUR'));

$mf = new MoneyFormatter();
$amount = $mf->getAmountInBaseUnits($money); //$amount will be (float)3000.05
$french_formatted = $mf->toStringByLocale('fr_FR', $money) //$french_formatted will be '3 000,05 €'

##License Information Licensed under The MIT License (MIT). See the LICENSE file for more details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%