Download the PHP package php-collective/decimal-object without Composer
On this page you can find all versions of the php package php-collective/decimal-object. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download php-collective/decimal-object
More information about php-collective/decimal-object
Files in php-collective/decimal-object
Package decimal-object
Short Description PHP decimal handling as value object
License MIT
Informations about the package decimal-object
Decimal Object
Decimal value object for PHP.
Documentation
https://php-collective.github.io/decimal-object/
Background
Floats cannot represent most decimal fractions exactly, which makes them unsuitable for money and other values that must add up:
Handling such values as strings works, and a value object keeps the logic for it in one place:
Features
- Explicit scale handling for arithmetic, truncation and rounding.
- Readable API:
add(),greaterThan(),isZero(). - Arithmetic, rounding, comparison and conversion.
- Immutable.
- Handles numbers beyond the integer and float range.
- Calculates with PHP's
bcmathextension.
Installation
Follow Installation to install the package and enable bcmath for the PHP process that runs it.
Usage
Integrations
- dereuromark/cakephp-decimal as decimal type for the CakePHP ORM.
See Alternatives for how this library compares to php-decimal, brick/math and the money libraries.
Contributing
Pull requests are welcome:
- Target
masterfor bug fixes and backwards compatible improvements. - Target
next(the next major version) for anything that breaks backwards compatibility.
History
The library was written in 2019 for the Spryker commerce framework and has been used there in order and price calculations since. This repository is the independently maintained continuation for the PHP ecosystem as a whole.
All versions of decimal-object with dependencies
ext-bcmath Version *
ext-json Version *