dfdsf
This commit is contained in:
@@ -267,37 +267,6 @@ final class FxRatesService
|
||||
return [];
|
||||
}
|
||||
|
||||
$direct = $this->repository->listDirectHistory($fromCurrency, $toCurrency, $this->normalizeTimestamp($from), $this->normalizeTimestamp($to), $limit);
|
||||
if ($direct !== []) {
|
||||
return array_map(fn (array $row): array => $this->localizeRateResult($row), $direct);
|
||||
}
|
||||
|
||||
$inverse = $this->repository->listDirectHistory($toCurrency, $fromCurrency, $this->normalizeTimestamp($from), $this->normalizeTimestamp($to), $limit);
|
||||
if ($inverse !== []) {
|
||||
$result = [];
|
||||
foreach ($inverse as $row) {
|
||||
$inverseRate = is_numeric($row['rate'] ?? null) ? (float) $row['rate'] : null;
|
||||
if ($inverseRate === null || $inverseRate <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result[] = [
|
||||
'fetch_id' => $row['fetch_id'] ?? null,
|
||||
'base_currency' => $fromCurrency,
|
||||
'target_currency' => $toCurrency,
|
||||
'rate' => 1 / $inverseRate,
|
||||
'rate_date' => $row['rate_date'] ?? null,
|
||||
'provider' => $row['provider'] ?? null,
|
||||
'fetched_at' => $row['fetched_at'] ?? null,
|
||||
'is_exact_pair' => false,
|
||||
];
|
||||
}
|
||||
|
||||
if ($result !== []) {
|
||||
return array_map(fn (array $row): array => $this->localizeRateResult($row), $result);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->crossHistory($fromCurrency, $toCurrency, $from, $to, $limit);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user