# give/4.17.0/vendor/moneyphp/money/src/Exchange/FixedExchange.php

GiveWP – Donation Plugin and Fundraising Platform, version 4.17.0. 43 lines.

- Page: https://pluginprobe.com/plugins/give/4.17.0/code/vendor/moneyphp/money/src/Exchange/FixedExchange.php
- Raw: https://pluginprobe.com/plugins/give/4.17.0/raw/vendor/moneyphp/money/src/Exchange/FixedExchange.php
- Modified: 2025-03-31T19:17:16+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/give/4.17.0/code/vendor/moneyphp/money/src/Exchange/FixedExchange.php#L10-L20`.

```php
<?php

namespace Money\Exchange;

use Money\Currency;
use Money\CurrencyPair;
use Money\Exception\UnresolvableCurrencyPairException;
use Money\Exchange;

/**
 * Provides a way to get exchange rate from a static list (array).
 *
 * @author Frederik Bosch <f.bosch@genkgo.nl>
 */
final class FixedExchange implements Exchange
{
    /**
     * @var array
     */
    private $list;

    public function __construct(array $list)
    {
        $this->list = $list;
    }

    /**
     * {@inheritdoc}
     */
    public function quote(Currency $baseCurrency, Currency $counterCurrency)
    {
        if (isset($this->list[$baseCurrency->getCode()][$counterCurrency->getCode()])) {
            return new CurrencyPair(
                $baseCurrency,
                $counterCurrency,
                $this->list[$baseCurrency->getCode()][$counterCurrency->getCode()]
            );
        }

        throw UnresolvableCurrencyPairException::createFromCurrencies($baseCurrency, $counterCurrency);
    }
}

```
