Download the PHP package ferdiunal/money without Composer
On this page you can find all versions of the php package ferdiunal/money. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package money
ferdiunal/money
This package is a fork of the sineld/money repository, with added discount and data types.
ferdiunal/money is a PHP library designed to make working with money easier! There are no static properties or methods. Any number you pass to the class will automatically be prepared for mathematical operations. The class uses , for thousands and . for decimals.
This package can be used with any framework or spaghetti application. If you encounter any issues, feel free to reach out to me by email.
Installation
Via Composer
Add the following use statement to the top of your file:
Then, start using the library!
Non-Composer Users
If you are not using Composer, simply copy the Money.php file located in the src folder to your project and begin using the library. There are no extra dependencies.
Request method aliases
Here are the parameters you can use with methods:
money->setDecimals(default = 2)
money->addTax(default = 18)
money->removeTax(default = 18)
money->setLocaleActive(default = false)
money->setLocaleCode(default = TRL)
money->setLocalePosition(default = prefix, (use "suffix" instead of reverse))
Usage Examples
In the following code example, a currency object is created using the Ferdiunal\Money\Money
class. First, a currency object is created based on the specified numeric value. Then, another numeric value is added, subtracted, multiplied, and divided to the currency object. After adding a percentage-based tax, a fixed discount and a percentage-based discount are added. Finally, tax and discount are removed based on the calculations, and the currency object is formatted and retrieved using the get()
method. The all()
method returns the currency and tax amount as an array. The getTax()
method returns the calculated tax amount. The getDiscount()
method returns the calculated discount amount.
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email author email instead of using the issue tracker.
Credits
License
Please see the license file for more information.