Brick Money Versions Save

A money and currency library for PHP

0.4.5

4 years ago

🐛 Bug fix

MoneyBag::getAmount(), add() and subtract() would throw an exception when using a custom currency (#25).

0.4.4

4 years ago

New method

AbstractMoney::isAmountAndCurrencyEqualTo() compares a money to another. (#17)

This method is different from isEqualTo() in 2 aspects:

  • it only accepts another money, not a raw number;
  • it returns false if the money is in another currency, instead of throwing an exception.

0.4.3

4 years ago

🛠 Improvements

  • MoneyBag::getAmount() now accepts an ISO numeric currency code as well

New methods

  • CurrencyConverter::convertToRational() converts to a RationalMoney (#22)

0.4.2

4 years ago

Performance improvement when calling Money::formatTo() many times for the same locale.

0.4.1

5 years ago

Added support for brick/math version 0.8.

0.4.0

5 years ago

Breaking Changes

  • Deprecated method BigRational::toMoney() has been removed, use BigRational::to() instead;
  • BigRational::__toString() now always outputs the amount in non-simplified rational form.

New methods

  • BigRational::simplified() returns a copy of the money with the amount simplified.

0.3.4

5 years ago

ISO currency list update.

0.3.3

5 years ago

ISO currency list update.

0.3.2

5 years ago

Money::formatTo() can now format the amount as a whole number:

formatTo(string $locale, bool $allowWholeNumber = false) : string

By default, formatTo() always outputs all the fraction digits:

Money::of('23.5', 'USD')->formatTo('en_US'); // $23.50
Money::of(23, 'USD')->formatTo('en_US'); // $23.00

But can now be allowed to return the whole number by passing true as a second argument:

Money::of('23.5', 'USD')->formatTo('en_US', true); // $23.50
Money::of(23, 'USD')->formatTo('en_US', true); // $23

Note that this version now requires brick/math version 0.7.3. This is not a BC break. If you've locked your composer.json to an earlier version, you will just not be able to install brick/money version 0.3.2.

0.3.1

5 years ago

ISO currency list update.