Cmfcmf\OpenWeatherMap::cacheOrFetchResult PHP Method

cacheOrFetchResult() private method

Fetches the result or delivers a cached version of the result.
private cacheOrFetchResult ( string $url ) : string
$url string
return string
    private function cacheOrFetchResult($url)
    {
        if ($this->cache !== false) {
            /** @var AbstractCache $cache */
            $cache = $this->cache;
            $cache->setSeconds($this->seconds);
            if ($cache->isCached($url)) {
                $this->wasCached = true;
                return $cache->getCached($url);
            }
            $result = $this->fetcher->fetch($url);
            $cache->setCached($url, $result);
        } else {
            $result = $this->fetcher->fetch($url);
        }
        $this->wasCached = false;
        return $result;
    }