Releases: brick/money
Releases · brick/money
Release list
0.15.2
0.15.1
0.15.0
💥 Breaking changes
- The constructors of these exception classes are now
@internal:ExchangeRateProviderExceptionMoneyFormatException
MoneyNumberFormatterhas been removed; callNumberFormatter::formatCurrency()directly insteadMoney::formatToLocale()andMoneyLocaleFormatter:- now format through ICU's modern number skeleton pipeline, and minor formatting differences may appear in some locales
- now require the intl extension to be linked against ICU 62.1 or later, and throw a
MoneyFormatExceptionon older ICU (this is independent of the PHP version) - now accept a
CurrencyDisplayparameter in the second position - now throw a
MoneyFormatExceptionif the amount cannot be accurately represented as a float, rather than formatting it with wrong digits - now throw a
MoneyFormatExceptionif the intl extension has no data for the locale's language (e.g.xx_YY), rather than silently formatting in the process default locale
- The
$allowWholeNumberparameter ofMoney::formatToLocale()andMoneyLocaleFormatterhas been renamed to$hideFractionIfWhole
✨ New features
Money::formatToLocale()andMoneyLocaleFormatternow accept aCurrencyDisplayparameter controlling how the currency is displayed:Symbol(default),NarrowSymbol,Code,Name, orNone(amount only)MoneyLocaleFormatternow properly displays custom currencies whose code is not three letters (e.g.USDT,GOLD)
0.14.2
0.14.1
0.14.0
0.13.0
💥 Breaking changes
MoneyBagcan no longer be instantiated withnew: its constructor is now private; useMoneyBag::zero()to create an empty instanceMoney::convertedTo()now defaults toDefaultContextinstead of$this's context- The following methods no longer accept
nullfor the$contextparameter:CurrencyConverter::convert()Money::of()Money::ofMinor()Money::zero()Money::convertedTo()
Money::allocate()signature has changed: replaceallocate(1, 2, 3)withallocate([1, 2, 3], AllocationMode::FloorToFirst)to keep the same behaviour as beforeMoney::allocateWithRemainder()has been removed: replaceallocateWithRemainder(1, 2, 3)withallocate([1, 2, 3], AllocationMode::BlockSeparate)to keep the same behaviour as beforeMoney::split()signature has changed: replacesplit(3)withsplit(3, SplitMode::ToFirst)to keep the same behaviour as beforeMoney::splitWithRemainder()has been removed: replacesplitWithRemainder(3)withsplit(3, SplitMode::Separate)to keep the same behaviour as before- The following methods now throw an exception when used on a
MoneywithAutoContext:quotient()remainder()quotientAndRemainder()allocate()split()
MoneyBagno longer retains zero-balance currencies afterplus()/minus()operationsExchangeRateProvider::getExchangeRate()signature has changed: it now acceptsCurrencyinstances, and returnsBigNumber|nullCurrencyConversionExceptionhas been renamed toExchangeRateException, withExchangeRateProviderExceptionandExchangeRateNotFoundExceptionsubclassesPdoProvider::setParameters()has been removed, use dimension bindings insteadPdoProviderconstructor is now private, usePdoProvider::builder()->...->build()to create an instancePdoProviderConfigurationhas been removed, usePdoProvider::builder()insteadCurrencyConverter::convert()signature has changed: parameter$dimensionsnow comes before$contextCachedProvider::invalidate()has been removed, pass a PSR-16 cache implementation to the constructor if you need to invalidate the cacheMoneyComparatorconstructor now requires aComparisonModeinstance, explicitly pass an instance ofPairwiseModeto keep the same behaviour as beforeConfigurableProvideris now immutable:setExchangeRate()has been removed, useConfigurableProvider::builder()->addExchangeRate()->build()instead- The following methods now throw an exception when the exchange rate is negative or zero:
Money::convertedTo()RationalMoney::convertedTo()CurrencyConverter::convert()CurrencyConverter::convertToRational()
- The following methods now throw when performing same-currency operations with a rate different from
1:Money::convertedTo()RationalMoney::convertedTo()
- Constructors and factory methods of library-internal exceptions are now
@internal Contextmethods are now@internal: userland code should only rely on constructors- Interfaces
Context,Monetary, andMoneyExceptionare now sealed: userland implementations are no longer supported - Built-in
ExchangeRateProviderimplementations now consistently return1for same-currency pairs
Deprecated methods removed:
AbstractMoney::to()has been removed, usetoContext()insteadAbstractMoney::isAmountAndCurrencyEqualTo()has been removed, useisSameValueAs()insteadMoney::total()has been removed, usesum()insteadMoney::getUnscaledAmount()has been removed, usegetAmount()->getUnscaledValue()insteadRationalMoney::simplified()has been removed,RationalMoneyis always in its simplest form nowMoneyBag::add()has been removed, useplus()instead, which returns a new instanceMoneyBag::subtract()has been removed, useminus()instead, which returns a new instance
The following breaking changes only affect you if you're using named arguments:
Currency::ofNumericCode()now uses$numericCodeas the parameter nameIsoCurrencyProvider::getCurrencyByNumericCode()now uses$numericCodeas the parameter nameMoneyBag::plus()andminus()now use$thatas the parameter name
- Method
MoneyBag::fromMonies()is deprecated, useof()instead - Class
ProviderChainis deprecated, useChainProviderinstead
✨ New features
- Support for custom dimensions (date, rate type, ...) in
ExchangeRateProvider,CurrencyConverterandMoneyComparator - Support for
Money,RationalMoney, andMoneyBaginMoneyComparator - Support for multiple comparison modes in
MoneyComparator - New
Money::allocate()API with five algorithms, exposed through the newAllocationModeenum:FloorToFirst(this is the implementationallocate()used previously)FloorToLargestRatioFloorToLargestRemainderFloorSeparateBlockSeparate(this is the implementationallocateWithRemainder()used previously)
- New
Money::split()API with two algorithms, exposed through the newSplitModeenum:ToFirst(this is the implementationsplit()used previously)Separate(this is the implementationsplitWithRemainder()used previously)
MoneyMismatchExceptionnow has explicitCurrencyMismatchExceptionandContextMismatchExceptionsubclasses- New exception:
MoneyFormatException, thrown byMoneyFormatter::format() - New methods in
MoneyBag:isZero(),multipliedBy(),dividedBy(),negated(),isEqualTo(),of()(replacesfromMonies()) - New methods in
RationalMoney:min(),max(),sum() - Support for custom PSR-16 cache implementations in
CachedProvider - New exchange rate provider:
ChainProvider(replacesProviderChain) - Support for numeric currency codes in
PdoProvider
0.12.3
- Method
AbstractMoney::isAmountAndCurrencyEqualTo()is deprecated, useisSameValueAs()instead
🔄 Reverted deprecations
- The deprecation notice when calling
AbstractMoney::isEqualTo()with a money in a different currency (introduced in 0.12.1) has been removed; this method will continue to throw aMoneyMismatchException
✨ New features
- New method:
AbstractMoney::isSameValueAs()(replacesisAmountAndCurrencyEqualTo())
0.12.2
✨ New features
Money::allocate()&allocateWithRemainder()now acceptBigNumber|int|stringand support decimal & rational ratios- New method:
Money::remainder() - Methods
abs()andnegated()are now available onAbstractMoney
📌 Compatibility
- Compatibility with
brick/mathversion0.17