Releases: brick/money
0.12.1
0.12.0
π₯ Breaking changes
- Calling the following methods with floating-point values is no longer supported, explicitly cast floats to string
(string) $floatto 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, useCurrency::ofNumericCode()instead (#104) - Calling the following methods with a numeric currency code is no longer supported, use a
Currencyinstance fromCurrency::ofNumericCode()instead (#104):Money::of()Money::ofMinor()Money::zero()Money::convertedTo()RationalMoney::of()CurrencyConverter::convert()CurrencyConverter::convertToRational()IsoCurrencyProvider::getCurrency()
RationalMoneyis now always simplified to lowest terms:USD 25/100is automatically simplified toUSD 1/4Currency::$numericCodeis now nullablePdoProviderConfigurationnow has a private constructor, use a factory method instead- Internal method
Money::create()is nowprotected
Class name case changes:
ISOCurrencyProviderhas been renamed toIsoCurrencyProviderPDOProviderhas been renamed toPdoProviderPDOProviderConfigurationhas been renamed toPdoProviderConfiguration
Deprecated methods removed:
Currency::is()has been removed, useCurrency::isEqualTo()insteadMoneyBag::getAmount()has been removed, useMoneyBag::getMoney()->getAmount()insteadMoney::formatTo()has been removed, useMoney::formatToLocale()insteadMoney::formatWith()has been removed, useMoneyNumberFormatter::format()instead
- Method
RationalMoney::simplified()is deprecated, as it is now a no-op - Method
Money::getUnscaledAmount()is deprecated, usegetAmount()->getUnscaledValue()instead - Method
Money::total()is deprecated, usesum()instead - Method
AbstractMoney::to()is deprecated, usetoContext()instead - Passing
nullto the$contextparameter of the following methods is deprecated, use named arguments if you need to skip$context:CurrencyConverter::convert()Money::of()Money::ofMinor()Money::zero()
- Passing
nullto the$contextparameter ofMoney::convertedTo()is deprecated, use an explicitContextinstance; the default will change toDefaultContextin a future version - Instantiating a
MoneyBagwithnewis deprecated, useMoneyBag::zero()orMoneyBag::fromMonies()instead - Method
MoneyBag::add()is deprecated, useplus()instead, which returns a new instance - Method
MoneyBag::subtract()is deprecated, useminus()instead, which returns a new instance
π Compatibility
- brick/money now requires
brick/math:~0.15
π Improvements
- All
InvalidArgumentExceptionthrown now implementMoneyException - More exceptions have been documented
CashContext::applyTo()now performs step β· scale validation
β¨ New features
- New method:
AbstractMoney::toRational() - New method:
Money::sum()(replacestotal()) - New method:
RationalMoney::convertedTo() - New method:
RationalMoney::abs() - New method:
RationalMoney::negated() - New
MoneyBagimmutable API:MoneyBag::zero()MoneyBag::fromMonies()MoneyBag::plus()MoneyBag::minus()
- New exception:
ContextExceptionthrown when a context cannot be applied - New
PDOProviderConfigurationfactory methods:forCurrencyPair()forFixedSourceCurrency()forFixedTargetCurrency()
MoneyBagnow implementsJsonSerializable
0.11.2
0.11.1
- 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
π₯ Breaking changes
- Minimum PHP version is now 8.2
- The following classes are now
final:CurrencyConversionExceptionMoneyMismatchExceptionUnknownCurrencyException
CustomContextnow validates the step and will throw an exception if an invalid step is given- Interface
MoneyContainerhas been removed (replaced withMonetary) - Method
AbstractMoney::getAmounts()has been removed (replaced withgetMonies()) - Method
MoneyBag::getAmounts()has been removed (replaced withgetMonies()) CurrencyConverter::convert()andconvertToRational()now accept aMonetaryinstance (which still includesMoney,RationalMoneyandMoneyBag)MoneyBag::add()andsubtract()now accept aMonetaryinstance (which still includesMoney,RationalMoneyandMoneyBag)
- Calling
Currency::of()with a numeric code is deprecated, useCurrency::ofNumericCode()instead - Calling
ISOCurrencyProvider::getCurrency()with a numeric code is deprecated, usegetCurrencyByNumericCode()instead - Calling
CurrencyConverter::convert()orconvertToRational()with a numeric currency code is deprecated, use aCurrencyinstance instead - Calling
Money::of(),ofMinor(),zero()orconvertedTo()with a numeric currency code is deprecated, use aCurrencyinstance instead - Calling
RationalMoney::of()with a numeric currency code is deprecated, use aCurrencyinstance instead MoneyBag::getAmount()is deprecated, usegetMoney()insteadMoney::formatTo()is deprecated, useMoney::formatToLocale()insteadMoney::formatWith()is deprecated, useMoneyNumberFormatter::format()insteadCurrency::is()is deprecated, useCurrency::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 currencyCurrency::ofNumericCode()returns a currency by its numeric ISO 4217 codeCurrency::isEqualTo()compares two currencies for equality (replacesis())ISOCurrencyProvider::getCurrencyByNumericCode()returns a currency by its numeric codeISOCurrencyProvider::getHistoricalCurrenciesForCountry()returns historical currencies for a countryMoneyBag::getMoney()returns the contained amount in a given currency (replacesgetAmount())MoneyBag::getMonies()returns the contained monies (replacesgetAmounts())Money::formatToLocale()formats the amount to a locale (replacesformatTo()) (#105 by @mklepaczewski)RationalMoney::zero()returns a zeroRationalMoneyin a given currency
- New interfaces:
Monetary(replacesMoneyContainer)MoneyFormatterformats a givenMoneyobject (#105 by @mklepaczewski)
- New classes:
MoneyLocaleFormatterformats a givenMoneyobject to a locale (#105 by @mklepaczewski)MoneyNumberFormatterformats a givenMoneyobject using aNumberFormatterinstance (#105 by @mklepaczewski)
0.10.3
0.10.2
0.10.1
0.10.0
π₯ ISO currency changes
ZWG(Zimbabwe Gold) has been addedZWL(Zimbabwean Dollar) has been removedSLL(Sierra Leonean Leone) has been removed- The currency of Zimbabwe (
ZW) has been changed toZWG(Zimbabwe Gold) - The
SLLcurrency has been removed from Sierra Leone (SL), which only hasSLEnow
0.9.0
π₯ Breaking changes
- Minimum PHP version is now 8.1
PDOProviderConfigurationno longer has getters, its properties arepublic readonlyRoundingModefrombrick/mathis now an enum, so:- all methods accepting an
introunding mode now accept aRoundingModeinstance instead - this should be transparent to your application, as you'll be using the same constants such as
RoundingMode::UP
- all methods accepting an