Skip to content

Releases: brick/money

0.12.1

11 Mar 11:53

Choose a tag to compare

πŸ“Œ Compatibility

  • Compatibility with brick/math version 0.16

0.12.0

03 Mar 14:59

Choose a tag to compare

πŸ’₯ Breaking changes

  • Calling the following methods with floating-point values is no longer supported, explicitly cast floats to string (string) $float to get the same behaviour as before (brick/math#105):
    • Money::of(), ofMinor(), plus(), minus(), multipliedBy(), dividedBy(), quotient(), quotientAndRemainder(), convertedTo()
    • RationalMoney::of(), plus(), minus(), multipliedBy(), dividedBy()
    • AbstractMoney::compareTo(), isEqualTo(), isLessThan(), isLessThanOrEqualTo(), isGreaterThan(), isGreaterThanOrEqualTo()
    • ConfigurableProvider::setExchangeRate()
  • Calling Currency::of() with a numeric code is no longer supported, use Currency::ofNumericCode() instead (#104)
  • Calling the following methods with a numeric currency code is no longer supported, use a Currency instance from Currency::ofNumericCode() instead (#104):
    • Money::of()
    • Money::ofMinor()
    • Money::zero()
    • Money::convertedTo()
    • RationalMoney::of()
    • CurrencyConverter::convert()
    • CurrencyConverter::convertToRational()
    • IsoCurrencyProvider::getCurrency()
  • RationalMoney is now always simplified to lowest terms: USD 25/100 is automatically simplified to USD 1/4
  • Currency::$numericCode is now nullable
  • PdoProviderConfiguration now has a private constructor, use a factory method instead
  • Internal method Money::create() is now protected

Class name case changes:

  • ISOCurrencyProvider has been renamed to IsoCurrencyProvider
  • PDOProvider has been renamed to PdoProvider
  • PDOProviderConfiguration has been renamed to PdoProviderConfiguration

Deprecated methods removed:

  • Currency::is() has been removed, use Currency::isEqualTo() instead
  • MoneyBag::getAmount() has been removed, use MoneyBag::getMoney()->getAmount() instead
  • Money::formatTo() has been removed, use Money::formatToLocale() instead
  • Money::formatWith() has been removed, use MoneyNumberFormatter::format() instead

⚠️ Deprecations

  • Method RationalMoney::simplified() is deprecated, as it is now a no-op
  • Method Money::getUnscaledAmount() is deprecated, use getAmount()->getUnscaledValue() instead
  • Method Money::total() is deprecated, use sum() instead
  • Method AbstractMoney::to() is deprecated, use toContext() instead
  • Passing null to the $context parameter of the following methods is deprecated, use named arguments if you need to skip $context:
    • CurrencyConverter::convert()
    • Money::of()
    • Money::ofMinor()
    • Money::zero()
  • Passing null to the $context parameter of Money::convertedTo() is deprecated, use an explicit Context instance; the default will change to DefaultContext in a future version
  • Instantiating a MoneyBag with new is deprecated, use MoneyBag::zero() or MoneyBag::fromMonies() instead
  • Method MoneyBag::add() is deprecated, use plus() instead, which returns a new instance
  • Method MoneyBag::subtract() is deprecated, use minus() instead, which returns a new instance

πŸ“Œ Compatibility

  • brick/money now requires brick/math:~0.15

πŸ‘Œ Improvements

  • All InvalidArgumentException thrown now implement MoneyException
  • More exceptions have been documented
  • CashContext::applyTo() now performs step ⟷ scale validation

✨ New features

  • New method: AbstractMoney::toRational()
  • New method: Money::sum() (replaces total())
  • New method: RationalMoney::convertedTo()
  • New method: RationalMoney::abs()
  • New method: RationalMoney::negated()
  • New MoneyBag immutable API:
    • MoneyBag::zero()
    • MoneyBag::fromMonies()
    • MoneyBag::plus()
    • MoneyBag::minus()
  • New exception: ContextException thrown when a context cannot be applied
  • New PDOProviderConfiguration factory methods:
    • forCurrencyPair()
    • forFixedSourceCurrency()
    • forFixedTargetCurrency()
  • MoneyBag now implements JsonSerializable

0.11.2

02 Mar 20:27

Choose a tag to compare

⚠️ Deprecations

  • Money::create() is now marked as @internal, and will be made protected in version 0.12

0.11.1

12 Feb 09:51

Choose a tag to compare

⚠️ Deprecations

  • Added explicit trigger_deprecation() calls to methods that were already marked as @deprecated, so deprecation notices are now emitted at runtime

πŸ“Œ Compatibility

  • Restricted compatibility to brick/math:~0.14.4

πŸ‘Œ Improvements

  • Fixed calls to deprecated brick/math and brick/money APIs

0.11.0

22 Jan 14:40

Choose a tag to compare

πŸ’₯ Breaking changes

  • Minimum PHP version is now 8.2
  • The following classes are now final:
    • CurrencyConversionException
    • MoneyMismatchException
    • UnknownCurrencyException
  • CustomContext now validates the step and will throw an exception if an invalid step is given
  • Interface MoneyContainer has been removed (replaced with Monetary)
  • Method AbstractMoney::getAmounts() has been removed (replaced with getMonies())
  • Method MoneyBag::getAmounts() has been removed (replaced with getMonies())
  • CurrencyConverter::convert() and convertToRational() now accept a Monetary instance (which still includes Money, RationalMoney and MoneyBag)
  • MoneyBag::add() and subtract() now accept a Monetary instance (which still includes Money, RationalMoney and MoneyBag)

⚠️ Deprecations

  • Calling Currency::of() with a numeric code is deprecated, use Currency::ofNumericCode() instead
  • Calling ISOCurrencyProvider::getCurrency() with a numeric code is deprecated, use getCurrencyByNumericCode() instead
  • Calling CurrencyConverter::convert() or convertToRational() with a numeric currency code is deprecated, use a Currency instance instead
  • Calling Money::of(), ofMinor(), zero() or convertedTo() with a numeric currency code is deprecated, use a Currency instance instead
  • Calling RationalMoney::of() with a numeric currency code is deprecated, use a Currency instance instead
  • MoneyBag::getAmount() is deprecated, use getMoney() instead
  • Money::formatTo() is deprecated, use Money::formatToLocale() instead
  • Money::formatWith() is deprecated, use MoneyNumberFormatter::format() instead
  • Currency::is() is deprecated, use Currency::isEqualTo() instead

Important

The convenience of passing a currency by ISO numeric code in addition to alphabetic code has been deprecated, leaving only alphabetic-code lookup in generic APIs. For example, Money::of() will accept Currency|string in the future, instead of Currency|string|int today.
This makes explicit the separation between retrieval by alphabetic code, which has strong backwards compatibility guarantees, and retrieval by numeric code, which may change in minor versions due to ISO reassignments.
This will require users to explicitly obtain a currency through Currency::ofNumericCode(), which is documented as not being covered by the same BC guarantees.

✨ New features

  • Support for historical currencies in Money::of(), Currency::of(), etc. (#104 by @survik1)
  • New enum: CurrencyType
  • New methods:
    • Currency::getCurrencyType() returns the type of the currency
    • Currency::ofNumericCode() returns a currency by its numeric ISO 4217 code
    • Currency::isEqualTo() compares two currencies for equality (replaces is())
    • ISOCurrencyProvider::getCurrencyByNumericCode() returns a currency by its numeric code
    • ISOCurrencyProvider::getHistoricalCurrenciesForCountry() returns historical currencies for a country
    • MoneyBag::getMoney() returns the contained amount in a given currency (replaces getAmount())
    • MoneyBag::getMonies() returns the contained monies (replaces getAmounts())
    • Money::formatToLocale() formats the amount to a locale (replaces formatTo()) (#105 by @mklepaczewski)
    • RationalMoney::zero() returns a zero RationalMoney in a given currency
  • New interfaces:
    • Monetary (replaces MoneyContainer)
    • MoneyFormatter formats a given Money object (#105 by @mklepaczewski)
  • New classes:
    • MoneyLocaleFormatter formats a given Money object to a locale (#105 by @mklepaczewski)
    • MoneyNumberFormatter formats a given Money object using a NumberFormatter instance (#105 by @mklepaczewski)

0.10.3

03 Sep 10:02

Choose a tag to compare

πŸ‘Œ Improvements

0.10.2

05 Aug 13:10

Choose a tag to compare

✨ New features

  • Add possibility to pass previous exception in CurrencyConversionException (#99 by @arokettu)

0.10.1

05 Mar 13:01

Choose a tag to compare

πŸ‘Œ Improvements

0.10.0

12 Oct 21:35

Choose a tag to compare

πŸ’₯ ISO currency changes

  • ZWG (Zimbabwe Gold) has been added
  • ZWL (Zimbabwean Dollar) has been removed
  • SLL (Sierra Leonean Leone) has been removed
  • The currency of Zimbabwe (ZW) has been changed to ZWG (Zimbabwe Gold)
  • The SLL currency has been removed from Sierra Leone (SL), which only has SLE now

0.9.0

26 Nov 16:55

Choose a tag to compare

πŸ’₯ Breaking changes

  • Minimum PHP version is now 8.1
  • PDOProviderConfiguration no longer has getters, its properties are public readonly
  • RoundingMode from brick/math is now an enum, so:
    • all methods accepting an int rounding mode now accept a RoundingMode instance instead
    • this should be transparent to your application, as you'll be using the same constants such as RoundingMode::UP