Download the PHP package rossmitchell/xfi-currency without Composer
On this page you can find all versions of the php package rossmitchell/xfi-currency. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rossmitchell/xfi-currency
More information about rossmitchell/xfi-currency
Files in rossmitchell/xfi-currency
Package xfi-currency
Short Description Currency for use with MoneyPHP that handle Financial Prices with fractions of a penny
License GPL-3.0-or-later
Informations about the package xfi-currency
XFI Currency
XFI Currency is a new currency type for use with Money PHP that handles values with fractions of pennies.
Installation
Rational
I'm working with financial information related to fund prices. These are returned in fractions of a penny, e.g. 123.45 is £1,23 pence, and 45 centi-pennies. Money PHP doesn't support these natively using GBP as it expects whole pennies only.
To avoid having to remember to convert these each time I need to use the data, this package create a new Currency for use with the Money library that correctly stores the information and then allows the values to be converted between the two currencies.
I'm using the code XFI, as X is used to denoted things which are "similar to currencies" in ISO-4217, FI to stand for Financial Information, and XFI as it has not been assigned in the list yet
Usage
Using the currency is as simple as using the code, like so
The package also provides a converter to convert the currency into GBP and vice versa. This is currently using a fixed exchange rate between XFI and GBP and can not convert into different currencies. This can be extended in the future
The package also provides a formatter for the currency, that wraps around the standard currencies.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.