/**
  * This function calculate rates.
  *
  * @param float|int $amount
  * @param string    $toCurrency
  * @param null      $fromCurrency
  *
  * @return float
  */
 public function calculateRate($amount, $toCurrency, $fromCurrency = null)
 {
     if (!isset($fromCurrency)) {
         $fromCurrency = $this->defaultCurrency;
     }
     if ($this->rates->getBaseCurrency() != $fromCurrency) {
         $amount = $amount / $this->getCurrencyRate($fromCurrency);
     }
     if ($toCurrency == $this->rates->getBaseCurrency()) {
         return $amount;
     }
     return $amount * $this->getCurrencyRate($toCurrency);
 }
 /**
  * Test if we return correct base currency.
  */
 public function testGetBaseCurrency()
 {
     $service = new CurrencyRatesService($this->getDriverMock('EUR'), $this->esManagerMock, $this->getCachePool());
     $service->setLogger($this->getLogger());
     $this->assertEquals('EUR', $service->getBaseCurrency());
 }