Example #1
0
File: CuEx.php Project: tautiz/cuex
 public function getRates($currencyPair)
 {
     if (is_string($currencyPair)) {
         $currencyPair = CurrencyPair::createFromString($currencyPair);
     } elseif (!$currencyPair instanceof CurrencyPair) {
         throw new \InvalidArgumentException('The currency pair must be either a string or an instance of CurrencyPair');
     }
     /**
      * @TODO: Imti is Cache duomenis
      */
     if (null !== $this->cache && null !== ($rate = $this->cache->fetchRate($currencyPair))) {
         return $rate;
     }
     if (isset($this->chainProviders)) {
         $rate = $this->chainProviders->fetchRates($currencyPair);
     } else {
         $rate = $this->provider->fetchRates($currencyPair);
     }
     if (null !== $this->cache) {
         $this->cache->storeRate($currencyPair, $rate);
     }
     return $rate;
 }