Server IP : 66.29.132.124 / Your IP : 3.138.204.147 Web Server : LiteSpeed System : Linux business141.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : wavevlvu ( 1524) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/wavevlvu/book24.ng/vendor/moneyphp/money/src/Exchange/ |
Upload File : |
<?php namespace Money\Exchange; use Exchanger\CurrencyPair as ExchangerCurrencyPair; use Exchanger\Contract\ExchangeRateProvider; use Exchanger\Exception\Exception as ExchangerException; use Exchanger\ExchangeRateQuery; use Money\Currency; use Money\CurrencyPair; use Money\Exception\UnresolvableCurrencyPairException; use Money\Exchange; /** * Provides a way to get exchange rate from a third-party source and return a currency pair. * * @author Maksim (Ellrion) Platonov <ellrion11@gmail.com> */ final class ExchangerExchange implements Exchange { /** * @var ExchangeRateProvider */ private $exchanger; /** * @param ExchangeRateProvider $exchanger */ public function __construct(ExchangeRateProvider $exchanger) { $this->exchanger = $exchanger; } /** * {@inheritdoc} */ public function quote(Currency $baseCurrency, Currency $counterCurrency) { try { $query = new ExchangeRateQuery( new ExchangerCurrencyPair($baseCurrency->getCode(), $counterCurrency->getCode()) ); $rate = $this->exchanger->getExchangeRate($query); } catch (ExchangerException $e) { throw UnresolvableCurrencyPairException::createFromCurrencies($baseCurrency, $counterCurrency); } return new CurrencyPair($baseCurrency, $counterCurrency, $rate->getValue()); } }