allow vendord
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
All checks were successful
Build, Push and Deploy / build-and-push (push) Successful in 3m3s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 16s
Build, Push and Deploy / deploy-staging (push) Successful in 32s
Build, Push and Deploy / deploy-production (push) Has been skipped
Build, Push and Deploy / cleanup (push) Successful in 1s
This commit is contained in:
59
vendor/moneyphp/money/src/Currencies/AggregateCurrencies.php
vendored
Normal file
59
vendor/moneyphp/money/src/Currencies/AggregateCurrencies.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Money\Currencies;
|
||||
|
||||
use AppendIterator;
|
||||
use IteratorIterator;
|
||||
use Money\Currencies;
|
||||
use Money\Currency;
|
||||
use Money\Exception\UnknownCurrencyException;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
* Aggregates several currency repositories.
|
||||
*/
|
||||
final class AggregateCurrencies implements Currencies
|
||||
{
|
||||
/**
|
||||
* @param Currencies[] $currencies
|
||||
*/
|
||||
public function __construct(private readonly array $currencies)
|
||||
{
|
||||
}
|
||||
|
||||
public function contains(Currency $currency): bool
|
||||
{
|
||||
foreach ($this->currencies as $currencies) {
|
||||
if ($currencies->contains($currency)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function subunitFor(Currency $currency): int
|
||||
{
|
||||
foreach ($this->currencies as $currencies) {
|
||||
if ($currencies->contains($currency)) {
|
||||
return $currencies->subunitFor($currency);
|
||||
}
|
||||
}
|
||||
|
||||
throw new UnknownCurrencyException('Cannot find currency ' . $currency->getCode());
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public function getIterator(): Traversable
|
||||
{
|
||||
$iterator = new AppendIterator();
|
||||
|
||||
foreach ($this->currencies as $currencies) {
|
||||
$iterator->append(new IteratorIterator($currencies->getIterator()));
|
||||
}
|
||||
|
||||
return $iterator;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user