Download the PHP package thedevick/precise-money without Composer
On this page you can find all versions of the php package thedevick/precise-money. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thedevick/precise-money
More information about thedevick/precise-money
Files in thedevick/precise-money
Package precise-money
Short Description Manipulate money precisely with PHP.
License MIT
Homepage https://github.com/TheDevick/PreciseMoney
Informations about the package precise-money
PHP Precise Money
The Money Object
The Money class is an immutable class, that represent an amount of money. You can add, subtract, multiply and divide the amount in the object with numeric-string or other Money object. Also, the Money Class is Json Serializable and Stringable.
Internally
Internally, the Money object stores the amount in an numeric-string.
Why use Precise Money?
This package provides an way to calculate money precisely. In other libraries,that stores the amount as cents as an integer,you can't calculate, for example, the price per kWh, since the price per kWh usally have more than 4 decimals. But since the Precise Money package stores the amount as an numeric-string, you can store many decimals as you wan't.
Calculating
Today, we only have the CalculatorInterface
.
Tests
Calculator
Custom Calculator Test Trait
To test calculator classes that implements the Calculator Interface, you can use the Calculator Test Trait. It have some methods that can help you write your tests:
generateCalculatorMessage(CalculatorInterface $calculator)
Returns a nice message that says the Class and Scale of the Calculator. Useful with$message
argument in assertions.assertCalculatorAddMethod($calculator, $expected, $x, $y)
This methods asserts the calculator add method.assertCalculatorAddMethodComplete($calculator)
nThis methods asserts many operations with the calculator.