Download the PHP package rogervila/moneyphp-operations without Composer
On this page you can find all versions of the php package rogervila/moneyphp-operations. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rogervila/moneyphp-operations
More information about rogervila/moneyphp-operations
Files in rogervila/moneyphp-operations
Package moneyphp-operations
Short Description Helpers for manipulating money with MoneyPHP
License MIT
Informations about the package moneyphp-operations

MoneyPHP Operations
MoneyPHP Operations provides a set of powerful helpers to manipulate and format money using MoneyPHP.
Installation
Usage
Initialization
You can initialize an Operation instance using an existing Money object or directly from values.
Percentage Operations
Increase
Increase the amount by a given percentage.
Decrease
Decrease the amount by a given percentage. Supports both positive and negative percentage strings.
Difference
Calculate the percentage difference between two Money objects.
Collection Operations
Split
Split a Money object into multiple parts. It ensures the sum of parts equals the original amount by adding the remainder to the first part.
Join
Combine an array of Money objects back into a single Money object.
Assert Split
Verify if an array of Money objects correctly totals the original instance.
Average
Calculate the average value of a collection of Money objects.
Formatting and Parsing
Formatting
Format a Money object to a localized string. Requires the intl extension.
Parsing
Parse a localized currency string into a Money object.
To Decimal
Convert a Money object to a float representation.
Factory
Create Money instances easily.
Rounding Modes
Most operations accept an optional $roundingMode parameter. By default, it uses Money::ROUND_HALF_UP.
Available modes (from MoneyPHP):
Money::ROUND_HALF_UPMoney::ROUND_HALF_DOWNMoney::ROUND_HALF_EVENMoney::ROUND_HALF_ODDMoney::ROUND_UPMoney::ROUND_DOWNMoney::ROUND_CEILINGMoney::ROUND_FLOOR
Exceptions
Methods may throw \MoneyOperation\Exceptions\InvalidOperationException in cases like:
- Invalid number of parts for
split. - Indivisible amounts.
- Missing
intlextension for formatting/parsing. - Empty arrays for
joinoraverage.
Author
Created by Roger Vilà
License
MoneyPHP Operations is open-sourced software licensed under the MIT license.
Icons made by Prosymbols Premium from www.flaticon.es