frederikbosch
Repos
99
Followers
37
Following
1

Events

closed issue
SwapExchange does not work with small floating point numbers

If SwapExchange would return a rate like 0.0000550000 PHP will display as 5.5E-5 thus simply casting to string will result to "5.5E-5". Then Converter passes ratio to the Number class which will throw invalid fractional part exception.

Although this issue has been handled in ExchangerExchange by using sprintf :)

Created at 1 week ago

swap exchange use sprintf instead of cast (#744)

Created at 1 week ago
pull request closed
swap exchange use sprintf instead of cast

Fixes #743

Made it similar to ExchangerExchange

Created at 1 week ago
issue comment
Add PHP 8.2 support

Tag with PHP 8.2 is now available. I also dropped PHP 7.4 support.

Created at 1 week ago
frederikbosch create tag 3.3.0
Created at 1 week ago
delete branch
frederikbosch delete branch single_gz_stream
Created at 1 week ago
delete branch
frederikbosch delete branch with_contents
Created at 1 week ago
delete branch
frederikbosch delete branch drop_74
Created at 1 week ago
create branch
frederikbosch create branch drop_74
Created at 1 week ago
delete branch
frederikbosch delete branch drop_74
Created at 1 week ago

drop php 7.4

Merge pull request #8 from genkgo/drop_74

drop php 7.4

Created at 1 week ago
pull request closed
drop php 7.4
Created at 1 week ago
pull request opened
drop php 7.4
Created at 1 week ago
create branch
frederikbosch create branch drop_74
Created at 1 week ago
issue comment
Add PHP 8.2 support

Great, thank you!

Created at 1 week ago

Add PHP 8.2 support

Merge pull request #7 from bcremer/add-php82-support

Add PHP 8.2 support

Created at 1 week ago
pull request closed
Add PHP 8.2 support
Created at 1 week ago
issue comment
.sortedKeys requires iOS 11

Yes, I am also using that for my PHP packages.

Created at 1 week ago
issue comment
.sortedKeys requires iOS 11

Good idea. Another option is to only support iOS/Mac etc versions that actually receive security updates by Apple. Users that really want support for older operating system versions are then forced to use older versions of the library.

If you would follow this path, this would lead to the following minimal operating system versions.

  • iOS 12
  • MacOS 11
  • WatchOS 9
  • For TV OS I cannot find any reference to what version receives updates by Apple, by I only observe updates for the latest OS. So I would set that to tvOS 16.
Created at 1 week ago
issue comment
abstract CurrencyPair to an interface

@morloderex I'd rather not provide an interface for value objects. Then the value object loses its purposes. Money\Exchange and MoneyConverter are tied to Money\CurrencyPair by design. If it does not fit you, you can create own exchanges, converters and currency-pair-alike objects. Or, as I have suggested, have your own exchange and converter next to ours. Per use-case you can decide what to inject Money\Converter, with limited conversion meta data, or Vendor\Converter with extended meta data. I do this quite often in my own applications.

Created at 2 weeks ago
issue comment
SwapExchange does not work with small floating point numbers

If you can make a PR with the sprintf solution, including a test, would be great.

Created at 2 weeks ago
pull request opened
.sortedKeys requires iOS 11
Created at 2 weeks ago

.sortedKeys requires iOS 11

Created at 2 weeks ago
issue comment
abstract CurrencyPair to an interface

I disagree.

namespace Vendor;

interface MyExchange {
  public function quote(Currency $baseCurrency, Currency $counterCurrency): MyReturnType;
}

final class MyConverter {
  public function __construct(private MyExchange $myExchange, private Money\Converter $moneyConverter) {}

  /** @return array{0: Money, 1: MyReturnType} */
  public function convertAndReturnWithMyReturnType(Money $money, Currency $counterCurrency, int $roundingMode = Money::ROUND_HALF_UP): array
  {
      $myPair = $this->myExchange->quote(
          $money->getCurrency(),
          $counterCurrency
      );

      $moneyCurrencyPair = new CurrencyPair($myPair->getBaseCurrency(), $myPair->getCounterCurrency(), $myPair->getConversionRatio());

      return [$this->converter->convertAgainstCurrencyPair($money, $moneyCurrencyPair, $roundingMode), $myPair];
  }
}

                                
Created at 2 weeks ago
issue comment
abstract CurrencyPair to an interface

While I get where you are going with this, I wonder why you must talk to the Exchange interface defined in this package.

namespace Vendor;

interface Exchange {
  public function quote(Currency $baseCurrency, Currency $counterCurrency): MyReturnType;
}

final class MyExchange implements Exchange {
  public function __construct(private Money\Exchange $moneyExchange) {}

  public function quote(Currency $baseCurrency, Currency $counterCurrency): MyReturnType
  {
       $currencyPair = $this->moneyExchange->quote($baseCurrency, $counterCurrency);
       return $this->convertToOrAddSpecificsAboutMyReturnType($currencyPair);
  }
}
                                
Created at 2 weeks ago
issue comment
Allow public init from P384 PublicKey

@aidantwoods Wonderful, thanks for all your work here!

Created at 3 weeks ago
closed issue
`roundToUnit` does not handles amounts less than 1 unit

Hi there,

Given:

$currencies = new \Money\Currencies\ISOCurrencies();
$money = \Money\Money::USD(10); //10 cent

$money->roundToUnit($currencies->subunitFor($money->getCurrency()));

should return \Money\Money::USD(0)

but will throw:

Fatal error: Uncaught InvalidArgumentException: Leading zeros are not allowed in /vendor/moneyphp/money/src/Number.php:216
Stack trace:
#0 /vendor/moneyphp/money/src/Number.php(44): Money\Number::parseIntegerPart('000')
#1 /vendor/moneyphp/money/src/Number.php(53): Money\Number->__construct('000', '')
#2 /vendor/moneyphp/money/src/Money.php(81): Money\Number::fromString('000')
#3 /vendor/moneyphp/money/src/Money.php(410): Money\Money->__construct('000', Object(Money\Currency))
#4 /test.php(10): Money\Money->roundToUnit(2)
#5 {main}

Thanks

Created at 3 weeks ago

Try reproduce bug #740 (#741)

  • Fix rounding to unit with value between 10 and 49, fixes #740
Created at 3 weeks ago
delete branch
frederikbosch delete branch bug_740
Created at 3 weeks ago