/** * {@inheritdoc} */ public function fetchRate(CurrencyPair $currencyPair) { if (!isset($this->rates[$currencyPair->toString()])) { throw new UnsupportedCurrencyPairException($currencyPair); } $rate = $this->rates[$currencyPair->toString()]; if (is_scalar($rate)) { $rate = new Rate($rate); } elseif (!$rate instanceof Rate) { throw new InternalException(sprintf('Rates passed to the ArrayProvider must be Rate instances or scalars "%s" given.', gettype($rate))); } return $rate; }
/** * @test */ public function it_can_be_converted_to_a_string() { $pair = new CurrencyPair('EUR', 'USD'); $this->assertEquals('EUR/USD', (string) $pair); $this->assertEquals('EUR/USD', $pair->toString()); }
/** * {@inheritdoc} */ public function storeRate(CurrencyPair $currencyPair, Rate $rate) { $this->store->put($currencyPair->toString(), $rate, $this->ttl); }
protected function getKey(CurrencyPair $currencyPair, $date) { return $currencyPair->toString() . '_' . $date; }
public function __construct(CurrencyPair $currencyPair) { parent::__construct(sprintf('The currency pair "%s" is not supported.', $currencyPair->toString())); $this->currencyPair = $currencyPair; }