/** * {@inheritdoc} */ public function getExchangeRate($sourceCurrencyCode, $targetCurrencyCode) { if (isset($this->exchangeRates[$sourceCurrencyCode][$targetCurrencyCode])) { return $this->exchangeRates[$sourceCurrencyCode][$targetCurrencyCode]; } throw CurrencyConversionException::exchangeRateNotAvailable($sourceCurrencyCode, $targetCurrencyCode); }
/** * {@inheritdoc} */ public function getExchangeRate($sourceCurrencyCode, $targetCurrencyCode) { $this->statement->execute([$sourceCurrencyCode, $targetCurrencyCode]); $exchangeRate = $this->statement->fetchColumn(); if ($exchangeRate === false) { throw CurrencyConversionException::exchangeRateNotAvailable($sourceCurrencyCode, $targetCurrencyCode); } return $exchangeRate; }
/** * {@inheritdoc} */ public function getExchangeRate($sourceCurrencyCode, $targetCurrencyCode) { foreach ($this->providers as $provider) { try { return $provider->getExchangeRate($sourceCurrencyCode, $targetCurrencyCode); } catch (CurrencyConversionException $e) { continue; } } throw CurrencyConversionException::exchangeRateNotAvailable($sourceCurrencyCode, $targetCurrencyCode); }