Limpieza de input de valor y filtro de datos a nivel Repo

This commit is contained in:
Juan Pablo Vial
2024-07-03 15:13:13 -04:00
parent d5b9be0196
commit d68eba5697
28 changed files with 436 additions and 189 deletions

View File

@ -15,6 +15,9 @@ class MiIndicador implements Provider
public function __construct(protected ClientInterface $client) {}
/**
* @throws EmptyResponse
*/
public function get(string $money_symbol, DateTimeInterface $dateTime): float
{
$request_uri = "{$money_symbol}/{$dateTime->format('d-m-Y')}";
@ -31,7 +34,7 @@ class MiIndicador implements Provider
$body = $response->getBody();
$json = json_decode($body->getContents());
if ($json->codigo !== $money_symbol or count($json->serie) === 0) {
if (empty($json) or $json->codigo !== $money_symbol or count($json->serie) === 0) {
throw new EmptyResponse($request_uri);
}
return $json->serie[0]->valor;