Grabar UF y capacidad de obtener hoy.

This commit is contained in:
Juan Pablo Vial
2025-05-05 16:45:00 -04:00
parent 972e57b6f1
commit 7d04b406ab
3 changed files with 8 additions and 5 deletions

View File

@ -33,11 +33,12 @@ class Money
return 0; return 0;
} }
} }
public function getUF(DateTimeInterface $dateTime): float public function getUF(?DateTimeInterface $dateTime = null): float
{ {
try { try {
return $this->getProvider('uf')->get(MiIndicador::UF, $dateTime); return $this->getProvider('uf')->get(MiIndicador::UF, $dateTime);
} catch (EmptyResponse) { } catch (EmptyResponse $exception) {
$this->logger->debug($exception);
return 0; return 0;
} }
} }

View File

@ -18,9 +18,12 @@ class MiIndicador implements Provider
/** /**
* @throws EmptyResponse * @throws EmptyResponse
*/ */
public function get(string $money_symbol, DateTimeInterface $dateTime): float public function get(string $money_symbol, ?DateTimeInterface $dateTime = null): float
{ {
$request_uri = "{$money_symbol}";
if ($dateTime !== null) {
$request_uri = "{$money_symbol}/{$dateTime->format('d-m-Y')}"; $request_uri = "{$money_symbol}/{$dateTime->format('d-m-Y')}";
}
try { try {
$response = $this->client->get($request_uri); $response = $this->client->get($request_uri);
} catch (GuzzleException) { } catch (GuzzleException) {

View File

@ -76,7 +76,6 @@ class UF
$uf = $this->get($date); $uf = $this->get($date);
return $input * (($from === 'uf') ? $uf : 1/$uf); return $input * (($from === 'uf') ? $uf : 1/$uf);
} }
protected array $redisUFs; protected array $redisUFs;
public function getRedisUFs(): array public function getRedisUFs(): array
{ {