2017 © Pedro Peláez
 

library money-formatter

Formatter for moneyphp/money library using alcohol/iso4217 for obtaining the number of decimal digits in each currency

image

antonienko/money-formatter

Formatter for moneyphp/money library using alcohol/iso4217 for obtaining the number of decimal digits in each currency

  • Friday, March 4, 2016
  • by antonienko
  • Repository
  • 1 Watchers
  • 1 Stars
  • 3,052 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Money Formatter

Run Status Scrutinizer Code Quality Code Coverage Build Status, (*1)

Class to convert Moneyphp/money objects to the base unit representation of the given currency (float) or to a string representation given a locale, using php's intl extension., (*2)

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., (*3)

Installation

Composer

This library is available in packagist.org, you can add it to your project via Composer., (*4)

In the "require" section of your composer.json file:, (*5)

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

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

Specific minor version, API stability, (*7)

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

Features

  • Convert a Money Object to float value, depending on the number of decimal places used by the currency.
  • Convert a Money Object to string, formatted using the provided locale.
  • Get the currency symbol of a Money Object, either just the symbol or the full currency symbol (The "just the symbol" option for Canadian Dollar would be '$', but if you are in the USA you would need the "full symbol" option "CA$")
  • Get the symbol position for a given locale (right or left position)

Sample Usage

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

$some_euros   = new Money(300005, new Currency('EUR'));
$some_dollars = new Money(300005, new Currency('USD'));
$mf = new MoneyFormatter('fr_FR');

$amount = $mf->toFloat($some_euros); //$amount will be (float)3000.05

$french_formatted = $mf->toString($some_euros); //$french_formatted will be '3 000,05 €'

$just_symbol = $mf->toSymbol($some_dollars); //$just_symbol would be '$'

$full_symbol = $mf->toSymbol($some_dollars, false); //$full_symbol would be '$US'

$position = $mf->getSymbolPosition($some_euros); //position would be MoneyFormatter::SYMBOL_POSITION_RIGHT

License Information

Licensed under The MIT License (MIT). See the LICENSE file for more details., (*8)

The Versions

04/03 2016

dev-master

9999999-dev http://www.antoniohs.com/2016/03/03/antonienkomoneyformatter-2-0/

Formatter for moneyphp/money library using alcohol/iso4217 for obtaining the number of decimal digits in each currency

  Sources   Download

MIT

The Requires

 

The Development Requires

formatter currency money value object

04/03 2016

v2.0

2.0.0.0 http://www.antoniohs.com/2016/03/03/antonienkomoneyformatter-2-0/

Formatter for moneyphp/money library using alcohol/iso4217 for obtaining the number of decimal digits in each currency

  Sources   Download

MIT

The Requires

 

The Development Requires

formatter currency money value object

19/02 2016

v1.4

1.4.0.0

Formatter for mathiasverraes' money library using alcohol's iso4217 standard implementation

  Sources   Download

MIT

The Requires

 

The Development Requires

formatter currency money value object

17/02 2016

v1.3.1

1.3.1.0

Formatter for mathiasverraes' money library using alcohol's iso4217 standard implementation

  Sources   Download

MIT

The Requires

 

The Development Requires

formatter currency money value object

20/01 2016

v1.3

1.3.0.0

Formatter for mathiasverraes' money library using alcohol's iso4217 standard implementation

  Sources   Download

MIT

The Requires

 

The Development Requires

formatter currency money value object

23/12 2015

v1.2

1.2.0.0

Formatter for mathiasverraes' money library using alcohol's iso4217 standard implementation

  Sources   Download

MIT

The Requires

 

The Development Requires

formatter currency money value object

27/07 2015

v1.1

1.1.0.0

Formatter for mathiasverraes' money library using alcohol's iso4217 standard implementation

  Sources   Download

MIT

The Requires

 

The Development Requires

formatter currency money value object

21/07 2015

v1.0

1.0.0.0

Formatter for mathiasverraes' money library using alcohol's iso4217 standard implementation

  Sources   Download

MIT

The Requires

 

The Development Requires

formatter currency money value object