Files
kulakpos_web/vendor/moneyphp/money/src/Currencies/AggregateCurrencies.php
eko54r b5e3a778ce
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
allow vendord
2026-03-30 14:54:57 +07:00

60 lines
1.3 KiB
PHP

<?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;
}
}