ExchangeRate.php in Currency 8.3
File
src/ExchangeRate.php
View source
<?php
namespace Drupal\currency;
use Commercie\CurrencyExchange\ExchangeRate as GenericExchangeRate;
use Commercie\CurrencyExchange\ExchangeRateInterface as GenericExchangeRateInterface;
use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
use Drupal\Core\Cache\RefinableCacheableDependencyTrait;
class ExchangeRate extends GenericExchangeRate implements ExchangeRateInterface, RefinableCacheableDependencyInterface {
use RefinableCacheableDependencyTrait;
protected $exchangeRateProviderId;
public function __construct($source_currency_code, $destination_currency_code, $rate, $exchange_rate_provider_id) {
parent::__construct($source_currency_code, $destination_currency_code, $rate);
$this->exchangeRateProviderId = $exchange_rate_provider_id;
}
public static function createFromExchangeRate(GenericExchangerateInterface $other_exchange_rate, $exchange_rate_provider_id) {
$exchange_rate = new static($other_exchange_rate
->getSourceCurrencyCode(), $other_exchange_rate
->getDestinationCurrencyCode(), $other_exchange_rate
->getRate(), $exchange_rate_provider_id);
$exchange_rate
->setTimestamp($other_exchange_rate
->getTimestamp());
return $exchange_rate;
}
public function getExchangeRateProviderId() {
return $this->exchangeRateProviderId;
}
public function setExchangeRateProviderId($id) {
$this->exchangeRateProviderId = $id;
return $this;
}
}