Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bump dev-dependencies #775

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"ext-gmp": "*",
"ext-intl": "*",
"cache/taggable-cache": "^1.1.0",
"doctrine/coding-standard": "^12.0",
"doctrine/coding-standard": "^9.0",
"doctrine/instantiator": "^1.5.0 || ^2.0",
"florianv/exchanger": "^2.8.1",
Expand Down
14 changes: 7 additions & 7 deletions src/Calculator/BcMathCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static function round(string $number, int $roundingMode): string
return bcadd(
$number->__toString(),
$number->getIntegerRoundingMultiplier(),
0
0,
);
}

Expand All @@ -145,7 +145,7 @@ public static function round(string $number, int $roundingMode): string
return bcadd(
$number->__toString(),
$number->getIntegerRoundingMultiplier(),
0
0,
);
}

Expand All @@ -154,7 +154,7 @@ public static function round(string $number, int $roundingMode): string
return bcadd(
$number->__toString(),
$number->getIntegerRoundingMultiplier(),
0
0,
);
}

Expand All @@ -169,7 +169,7 @@ public static function round(string $number, int $roundingMode): string
return bcadd(
$number->__toString(),
$number->getIntegerRoundingMultiplier(),
0
0,
);
}

Expand All @@ -178,14 +178,14 @@ public static function round(string $number, int $roundingMode): string
return bcadd(
$number->__toString(),
$number->getIntegerRoundingMultiplier(),
0
0,
);
}

return bcadd(
$number->__toString(),
'0',
0
0,
);
}

Expand All @@ -203,7 +203,7 @@ private static function roundDigit(Number $number): string
return bcadd(
$number->__toString(),
$number->getIntegerRoundingMultiplier(),
0
0,
);
}

Expand Down
20 changes: 10 additions & 10 deletions src/Calculator/GmpCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ public static function divide(string $amount, string $divisor): string
gmp_div_q(
gmp_mul($remainder, gmp_init('1' . str_pad('', self::SCALE, '0'))),
gmp_init((string) $divisor),
GMP_ROUND_MINUSINF
)
GMP_ROUND_MINUSINF,
),
);

if ($divisionOfRemainder[0] === '-') {
Expand Down Expand Up @@ -237,7 +237,7 @@ public static function round(string $number, int $roundingMode): string
if ($roundingMode === Money::ROUND_HALF_UP) {
return self::add(
$number->getIntegerPart(),
$number->getIntegerRoundingMultiplier()
$number->getIntegerRoundingMultiplier(),
);
}

Expand All @@ -252,15 +252,15 @@ public static function round(string $number, int $roundingMode): string

return self::add(
$number->getIntegerPart(),
$number->getIntegerRoundingMultiplier()
$number->getIntegerRoundingMultiplier(),
);
}

if ($roundingMode === Money::ROUND_HALF_ODD) {
if ($number->isCurrentEven()) {
return self::add(
$number->getIntegerPart(),
$number->getIntegerRoundingMultiplier()
$number->getIntegerRoundingMultiplier(),
);
}

Expand All @@ -271,27 +271,27 @@ public static function round(string $number, int $roundingMode): string
if ($number->isNegative()) {
return self::add(
$number->getIntegerPart(),
'0'
'0',
);
}

return self::add(
$number->getIntegerPart(),
$number->getIntegerRoundingMultiplier()
$number->getIntegerRoundingMultiplier(),
);
}

if ($roundingMode === Money::ROUND_HALF_NEGATIVE_INFINITY) {
if ($number->isNegative()) {
return self::add(
$number->getIntegerPart(),
$number->getIntegerRoundingMultiplier()
$number->getIntegerRoundingMultiplier(),
);
}

return self::add(
$number->getIntegerPart(),
'0'
'0',
);
}

Expand All @@ -308,7 +308,7 @@ private static function roundDigit(Number $number): string
if ($number->isCloserToNext()) {
return self::add(
$number->getIntegerPart(),
$number->getIntegerRoundingMultiplier()
$number->getIntegerRoundingMultiplier(),
);
}

Expand Down
18 changes: 6 additions & 12 deletions src/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@
*/
final class Converter
{
private Currencies $currencies;

private Exchange $exchange;

public function __construct(Currencies $currencies, Exchange $exchange)
public function __construct(private Currencies $currencies, private Exchange $exchange)
{
$this->currencies = $currencies;
$this->exchange = $exchange;
}

public function convert(Money $money, Currency $counterCurrency, int $roundingMode = Money::ROUND_HALF_UP): Money
Expand All @@ -29,9 +23,9 @@ public function convert(Money $money, Currency $counterCurrency, int $roundingMo
$money,
$this->exchange->quote(
$money->getCurrency(),
$counterCurrency
$counterCurrency,
),
$roundingMode
$roundingMode,
);
}

Expand All @@ -40,7 +34,7 @@ public function convertAndReturnWithCurrencyPair(Money $money, Currency $counter
{
$pair = $this->exchange->quote(
$money->getCurrency(),
$counterCurrency
$counterCurrency,
);

return [$this->convertAgainstCurrencyPair($money, $pair, $roundingMode), $pair];
Expand All @@ -53,8 +47,8 @@ public function convertAgainstCurrencyPair(Money $money, CurrencyPair $currencyP
sprintf(
'Expecting to convert against base currency %s, but got %s instead',
$money->getCurrency()->getCode(),
$currencyPair->getBaseCurrency()->getCode()
)
$currencyPair->getBaseCurrency()->getCode(),
),
);
}

Expand Down
4 changes: 1 addition & 3 deletions src/Currencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public function contains(Currency $currency): bool;
*/
public function subunitFor(Currency $currency): int;

/**
* @psalm-return Traversable<int|string, Currency>
*/
/** @psalm-return Traversable<int|string, Currency> */
public function getIterator(): Traversable;
}
10 changes: 2 additions & 8 deletions src/Currencies/AggregateCurrencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,9 @@
*/
final class AggregateCurrencies implements Currencies
{
/** @var Currencies[] */
private array $currencies;

/**
* @param Currencies[] $currencies
*/
public function __construct(array $currencies)
/** @param Currencies[] $currencies */
public function __construct(private array $currencies)
{
$this->currencies = $currencies;
}

public function contains(Currency $currency): bool
Expand Down
10 changes: 2 additions & 8 deletions src/Currencies/CachedCurrencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,8 @@
*/
final class CachedCurrencies implements Currencies
{
private Currencies $currencies;

private CacheItemPoolInterface $pool;

public function __construct(Currencies $currencies, CacheItemPoolInterface $pool)
public function __construct(private Currencies $currencies, private CacheItemPoolInterface $pool)
{
$this->currencies = $currencies;
$this->pool = $pool;
}

public function contains(Currency $currency): bool
Expand Down Expand Up @@ -79,7 +73,7 @@ function (Currency $currency): bool {
$this->pool->save($item);

return true;
}
},
);
}
}
10 changes: 4 additions & 6 deletions src/Currencies/CryptoCurrencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class CryptoCurrencies implements Currencies
* minorUnit: non-negative-int
* }>|null
*/
private static ?array $currencies = null;
private static array|null $currencies = null;

public function contains(Currency $currency): bool
{
Expand All @@ -44,18 +44,16 @@ public function subunitFor(Currency $currency): int
return $this->getCurrencies()[$currency->getCode()]['minorUnit'];
}

/**
* @psalm-return Traversable<int, Currency>
*/
/** @psalm-return Traversable<int, Currency> */
public function getIterator(): Traversable
{
return new ArrayIterator(
array_map(
static function ($code) {
return new Currency($code);
},
array_keys($this->getCurrencies())
)
array_keys($this->getCurrencies()),
),
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Currencies/CurrencyList.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public function getIterator(): Traversable
static function ($code) {
return new Currency($code);
},
array_keys($this->currencies)
)
array_keys($this->currencies),
),
);
}
}
10 changes: 4 additions & 6 deletions src/Currencies/ISOCurrencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class ISOCurrencies implements Currencies
* numericCode: positive-int
* }>|null
*/
private static ?array $currencies = null;
private static array|null $currencies = null;

public function contains(Currency $currency): bool
{
Expand Down Expand Up @@ -60,18 +60,16 @@ public function numericCodeFor(Currency $currency): int
return $this->getCurrencies()[$currency->getCode()]['numericCode'];
}

/**
* @psalm-return Traversable<int, Currency>
*/
/** @psalm-return Traversable<int, Currency> */
public function getIterator(): Traversable
{
return new ArrayIterator(
array_map(
static function ($code) {
return new Currency($code);
},
array_keys($this->getCurrencies())
)
array_keys($this->getCurrencies()),
),
);
}

Expand Down
12 changes: 3 additions & 9 deletions src/CurrencyPair.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,11 @@ final class CurrencyPair implements JsonSerializable
*/
private Currency $counterCurrency;

/** @psalm-var numeric-string */
private string $conversionRatio;

/**
* @psalm-param numeric-string $conversionRatio
*/
public function __construct(Currency $baseCurrency, Currency $counterCurrency, string $conversionRatio)
/** @psalm-param numeric-string $conversionRatio */
public function __construct(Currency $baseCurrency, Currency $counterCurrency, private string $conversionRatio)
{
$this->counterCurrency = $counterCurrency;
$this->baseCurrency = $baseCurrency;
$this->conversionRatio = $conversionRatio;
}

/**
Expand Down Expand Up @@ -105,7 +99,7 @@ public function equals(CurrencyPair $other): bool
}

/**
* {@inheritdoc}
* {@inheritDoc}
*
* @psalm-return array{baseCurrency: Currency, counterCurrency: Currency, ratio: numeric-string}
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/UnresolvableCurrencyPairException.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static function createFromCurrencies(Currency $baseCurrency, Currency $co
$message = sprintf(
'Cannot resolve a currency pair for currencies: %s/%s',
$baseCurrency->getCode(),
$counterCurrency->getCode()
$counterCurrency->getCode(),
);

return new self($message);
Expand Down
7 changes: 2 additions & 5 deletions src/Exchange/ExchangerExchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,15 @@
*/
final class ExchangerExchange implements Exchange
{
private ExchangeRateProvider $exchanger;

public function __construct(ExchangeRateProvider $exchanger)
public function __construct(private ExchangeRateProvider $exchanger)
{
$this->exchanger = $exchanger;
}

public function quote(Currency $baseCurrency, Currency $counterCurrency): CurrencyPair
{
try {
$query = new ExchangeRateQuery(
new ExchangerCurrencyPair($baseCurrency->getCode(), $counterCurrency->getCode())
new ExchangerCurrencyPair($baseCurrency->getCode(), $counterCurrency->getCode()),
);
$rate = $this->exchanger->getExchangeRate($query);
} catch (ExchangerException) {
Expand Down
Loading