src/RunOpenCode/ExchangeRate/Repository/DoctrineDbalRepository.php
public function get($sourceName, $currencyCode, \DateTime $date = null, $rateType = RateType::MEDIAN)
    {
        if ($date === null) {
            $date = new \DateTime('now');
        }

        $key = $this->getRateKey($currencyCode, $date, $rateType, $sourceName);

        if (!isset($this->identityMap[$key])) {

            /**
             * @var array $result
             */
            $result = $this->connection->fetchAll(
                sprintf('SELECT R.* FROM %s R WHERE R.source_name = :source_name AND R.currency_code = :currency_code AND R.rate_date = :rate_date AND R.rate_type = :rate_type;', $this->tableName),
                [
                    'source_name'   => $sourceName,
                    'currency_code' => $currencyCode,
                    'rate_date'     => $date->format('Y-m-d'),
                    'rate_type'     => $rateType,
                ]
            );

            if (0 === count($result)) {
                throw new ExchangeRateException(sprintf('Could not fetch rate for rate currency code "%s" and rate type "%s" on date "%s".', $currencyCode, $rateType, $date->format('Y-m-d')));
            }

            $this->identityMap[$key] = $this->buildRateFromTableRowData($result[0]);
        }

        return $this->identityMap[$key];
    }
public function get($sourceName, $currencyCode, \DateTime $date = null, $rateType = RateType::MEDIAN)
    {
        if ($date === null) {
            $date = new \DateTime('now');
        }

        $key = $this->getRateKey($currencyCode, $date, $rateType, $sourceName);

        if (!isset($this->identityMap[$key])) {

            /**
             * @var array $result
             */
            $result = $this->connection->fetchAll(
                sprintf('SELECT R.* FROM %s R WHERE R.source_name = :source_name AND R.currency_code = :currency_code AND R.rate_date = :rate_date AND R.rate_type = :rate_type;', $this->tableName),
                [
                    'source_name'   => $sourceName,
                    'currency_code' => $currencyCode,
                    'rate_date'     => $date->format('Y-m-d'),
                    'rate_type'     => $rateType,
                ]
            );

            if (0 === count($result)) {
                throw new ExchangeRateException(sprintf('Could not fetch rate for rate currency code "%s" and rate type "%s" on date "%s".', $currencyCode, $rateType, $date->format('Y-m-d')));
            }

            $this->identityMap[$key] = $this->buildRateFromTableRowData($result[0]);
        }

        return $this->identityMap[$key];
    }
{@inheritdoc}