Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
9 / 9 |
| FixedExchange | |
100.00% |
1 / 1 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
9 / 9 |
| __construct | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| quote | |
100.00% |
1 / 1 |
2 | |
100.00% |
7 / 7 |
|||
| <?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; | |
| /** | |
| * @param array $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); | |
| } | |
| } |