public function getRateModel($base = null, $date = null) : Rates
    {
        $base = strtoupper($base);
        if (empty($base)) {
            $base = 'USD';
        }
        if (empty($date)) {
            $date = date('Y-m-d');
        }
        $this->fromCache = false;
        $api = $this->api;

        if ($this->cacheEnabled) {
            $cachekey = "cc-$api-$base-$date";

            $rates = Cache::get($cachekey);
            if (is_object($rates) and isset($rates->rates)) {
                $this->fromCache = true;
                if ($this->logEnabled) {
                    Log::debug("Got currency rates from cache: $cachekey");
                }
            }
            else {
                $rates = $this->provider->rates($base, $date);
                if (!empty($rates->rates)) {
                    if(Cache::add($cachekey, $rates, $this->cacheMinutes) and $this->logEnabled) {
                        Log::debug('Added new currency rates to cache: '.$cachekey.' for '.$this->cacheMinutes.' min.');
                    }
                }
            }
        }
        else {
            $rates = $this->provider->rates($base, $date);
        }

        if (empty($rates->rates)) {
            Log::warning("$rates->error -> $rates->url");
        }

        return $rates;
    }
public function getRateModel($base = null, $date = null) : Rates
    {
        $base = strtoupper($base);
        if (empty($base)) {
            $base = 'USD';
        }
        if (empty($date)) {
            $date = date('Y-m-d');
        }
        $this->fromCache = false;
        $api = $this->api;

        if ($this->cacheEnabled) {
            $cachekey = "cc-$api-$base-$date";

            $rates = Cache::get($cachekey);
            if (is_object($rates) and isset($rates->rates)) {
                $this->fromCache = true;
                if ($this->logEnabled) {
                    Log::debug("Got currency rates from cache: $cachekey");
                }
            }
            else {
                $rates = $this->provider->rates($base, $date);
                if (!empty($rates->rates)) {
                    if(Cache::add($cachekey, $rates, $this->cacheMinutes) and $this->logEnabled) {
                        Log::debug('Added new currency rates to cache: '.$cachekey.' for '.$this->cacheMinutes.' min.');
                    }
                }
            }
        }
        else {
            $rates = $this->provider->rates($base, $date);
        }

        if (empty($rates->rates)) {
            Log::warning("$rates->error -> $rates->url");
        }

        return $rates;
    }
public function getRateModel ( $ base = null , $ date = null ) : Rates { $ base = strtoupper ( $ base ) ; if ( empty ( $ base ) ) { $ base = 'USD' ; } if ( empty ( $ date ) ) { $ date = date ( 'Y-m-d' ) ; } $ this -> fromCache = false ; $ api = $ this -> api ; if ( $ this -> cacheEnabled ) { $ cachekey = "cc-$api-$base-$date" ; $ rates = Cache :: get ( $ cachekey ) ; if ( is_object ( $ rates ) and isset ( $ rates -> rates ) ) { $ this -> fromCache = true ; if ( $ this -> logEnabled ) { Log :: debug ( "Got currency rates from cache: $cachekey" ) ; } } else { $ rates = $ this -> provider -> rates ( $ base , $ date ) ; if ( ! empty ( $ rates -> rates ) ) { if ( Cache :: add ( $ cachekey , $ rates , $ this -> cacheMinutes ) and $ this -> logEnabled ) { Log :: debug ( 'Added new currency rates to cache: ' . $ cachekey . ' for ' . $ this -> cacheMinutes . ' min.' ) ; } } } } else { $ rates = $ this -> provider -> rates ( $ base , $ date ) ; } if ( empty ( $ rates -> rates ) ) { Log :: warning ( "$rates->error -> $rates->url" ) ; } return $ rates ; }
Get the Rates object from the Provider

@param null|string $base
@param null|string $date

@return Rates
Get the Rates object from the Provider