/** * Internal method which calculates the exchanges currency * * @param float|integer|Zend_Currency $value Compares the currency with this value * @param string|Zend_Currency $currency The currency to compare this value from * @return unknown */ protected function _exchangeCurrency($value, $currency) { if ($value instanceof Zend_Currency) { $currency = $value->getShortName(); $value = $value->getValue(); } else { $currency = $this->getShortName($currency, $this->getLocale()); } $rate = 1; if ($currency !== $this->getShortName()) { $service = $this->getService(); if (!$service instanceof Zend_Currency_CurrencyInterface) { require_once 'Zend/Currency/Exception.php'; throw new Zend_Currency_Exception('No exchange service applied'); } $rate = $service->getRate($currency, $this->getShortName()); } $value *= $rate; return $value; }
/** * Internal method which calculates the exchanges currency * * @param float|integer|Zend\Currency\Currency $value Compares the currency with this value * @param string|Zend\Currency\Currency $currency The currency to compare this value from * @return float */ protected function _exchangeCurrency($value, $currency) { if ($value instanceof Currency) { $currency = $value->getShortName(); $value = $value->getValue(); } else { $currency = $this->getShortName($currency, $this->getLocale()); } $rate = 1; if ($currency !== $this->getShortName()) { $service = $this->getService(); if (!$service instanceof CurrencyService) { throw new Exception\RuntimeException('No exchange service applied'); } $rate = $service->getRate($currency, $this->getShortName()); } $value *= $rate; return $value; }