A package used for money formatting
Switch branches/tags
Nothing to show
Clone or download
nWidart Merge branch 'master' of github.com:nWidart/MoneyFormatter
* 'master' of github.com:nWidart/MoneyFormatter:
  Make the Euros tests pass!
Latest commit 89b785e Mar 27, 2015
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Remove the laravel integration Mar 22, 2015
tests
.gitattributes First Commit Mar 22, 2015
.gitignore Add a php_cs config file Mar 22, 2015
.php_cs
.scrutinizer.yml
.travis.yml Remove composer install Mar 26, 2015
CHANGELOG.md
CONTRIBUTING.md First Commit Mar 22, 2015
LICENSE.md
README.md
composer.json Remove the laravel integration Mar 22, 2015
phpunit.xml.dist First Commit Mar 22, 2015

README.md

MoneyFormatter

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

A simple package used for formatting a Money\Money value object.

Money is usually not stored as a float in your database, though your clients/users don't want to see 1000 meaning, 10. This package receives an amount in cents, and displays it according to the given locale with or with the currency symbol.

Want to use this inside a Laravel application? Check out the MoneyFormatter-Laravel package.

Install

Via Composer

$ composer require nwidart/money-formatter

Usage

To format money in cents:

$formatter = new MoneyFormatter('en_US');
$formattedMoney = $formatter->format(new Money(1000, new Currency('USD')));
# output : $10.00

Sometimes you may wish to not have the currency symbol, this can be done like so:

$formatter = new MoneyFormatter('en_US');
$formattedMoney = $formatter->formatWithoutCurrency(new Money(1000, new Currency('USD')));
# output : 10.00

This can be useful if your currency selection is a separate dropdown, for instance.

Testing

$ phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.