src/RunOpenCode/ExchangeRate/Repository/FileRepository.php
protected function load()
    {
        $this->rates = array();
        $this->latest = array();

        $handle = fopen($this->pathToFile, 'rb');

        if (!$handle) {
            throw new RuntimeException(sprintf('Error opening file on path "%s".', $this->pathToFile)); // @codeCoverageIgnore
        }

        while (($line = fgets($handle)) !== false) {

            $rate = $this->fromJson($line);

            $this->rates[$this->getRateKey($rate->getCurrencyCode(), $rate->getDate(), $rate->getRateType(), $rate->getSourceName())] = $rate;

            $latestKey = sprintf('%s_%s_%s', $rate->getCurrencyCode(), $rate->getRateType(), $rate->getSourceName());

            if (!isset($this->latest[$latestKey]) || ($this->latest[$latestKey]->getDate() < $rate->getDate())) {
                $this->latest[$latestKey] = $rate;
            }
        }

        fclose($handle);

        return $this->rates;
    }
protected function load()
    {
        $this->rates = array();
        $this->latest = array();

        $handle = fopen($this->pathToFile, 'rb');

        if (!$handle) {
            throw new RuntimeException(sprintf('Error opening file on path "%s".', $this->pathToFile)); // @codeCoverageIgnore
        }

        while (($line = fgets($handle)) !== false) {

            $rate = $this->fromJson($line);

            $this->rates[$this->getRateKey($rate->getCurrencyCode(), $rate->getDate(), $rate->getRateType(), $rate->getSourceName())] = $rate;

            $latestKey = sprintf('%s_%s_%s', $rate->getCurrencyCode(), $rate->getRateType(), $rate->getSourceName());

            if (!isset($this->latest[$latestKey]) || ($this->latest[$latestKey]->getDate() < $rate->getDate())) {
                $this->latest[$latestKey] = $rate;
            }
        }

        fclose($handle);

        return $this->rates;
    }
Load all rates from file.

@return RateInterface[]