use RunOpenCode\AssetsInjection\Exception\ConfigurationException;
7
use RunOpenCode\ExchangeRate\Contract\ProcessorInterface;
8
use RunOpenCode\ExchangeRate\Contract\RateInterface;
9
use RunOpenCode\ExchangeRate\Utils\CurrencyCode;
10
11
class BaseCurrencyValidator implements ProcessorInterface
12
{
13
use LoggerAwareTrait;
14
15
/**
16
* {@inheritdoc}
17
*/
18
public function process($baseCurrencyCode, array $rateConfigurations, array $rates)
19
{
20
if (!CurrencyCode::exists($baseCurrencyCode)) {
21
throw new \RuntimeException(sprintf('Unknown base currency code "%s".', $baseCurrencyCode));
22
}
23
24
/**
25
* @var RateInterface $rate
26
*/
27
foreach ($rates as $rate) {
28
29
if ($baseCurrencyCode !== $rate->getBaseCurrencyCode()) {
30
throw new ConfigurationException(sprintf('Conversion of compound rate "%s" from source "%s" is not calculated.', $rate->getCurrencyCode(), $rate->getSourceName()));