You are here

public static function ExchangeRate::createFromExchangeRate in Currency 8.3

Creates a new exchange rate based on another one.

Parameters

\Commercie\CurrencyExchange\ExchangerateInterface $other_exchange_rate: The code of the source currency.

string $exchange_rate_provider_id: The ID of the exchange rate provider that provided this rate.

Return value

static

3 calls to ExchangeRate::createFromExchangeRate()
ExchangeRateProviderDecorator::load in src/Plugin/Currency/ExchangeRateProvider/ExchangeRateProviderDecorator.php
ExchangeRateProviderDecorator::loadMultiple in src/Plugin/Currency/ExchangeRateProvider/ExchangeRateProviderDecorator.php
ExchangeRateTest::testCreateFromExchangeRate in tests/src/Unit/ExchangeRateTest.php
@covers ::createFromExchangeRate

File

src/ExchangeRate.php, line 51

Class

ExchangeRate
Provides an exchange rate.

Namespace

Drupal\currency

Code

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;
}