/**
  * {@inheritdoc}
  */
 public function getExchangeRate($sourceCurrencyCode, $targetCurrencyCode)
 {
     if (isset($this->exchangeRates[$sourceCurrencyCode][$targetCurrencyCode])) {
         return $this->exchangeRates[$sourceCurrencyCode][$targetCurrencyCode];
     }
     throw CurrencyConversionException::exchangeRateNotAvailable($sourceCurrencyCode, $targetCurrencyCode);
 }
예제 #2
0
 /**
  * {@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;
 }
예제 #3
0
 /**
  * {@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);
 }