Limpieza de input de valor y filtro de datos a nivel Repo
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user