Ine null date

This commit is contained in:
Juan Pablo Vial
2025-05-05 18:14:20 -04:00
parent ea8f483dd5
commit af68c4b8ec

View File

@ -5,8 +5,8 @@ use Exception;
use DateTimeInterface;
use DateTimeImmutable;
use DateInterval;
use GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Client\ClientInterface;
use GuzzleHttp\Exception\GuzzleException;
use Incoviba\Common\Implement\Exception\EmptyResponse;
use Incoviba\Common\Define\Money\Provider;
@ -19,8 +19,11 @@ class Ine implements Provider
* @throws EmptyResponse
* @throws Exception
*/
public function get(string $money_symbol, DateTimeInterface $dateTime): float
public function get(string $money_symbol, ?DateTimeInterface $dateTime = null): float
{
if ($dateTime === null) {
$dateTime = new DateTimeImmutable();
}
$end = new DateTimeImmutable($dateTime->format('Y-m-1'));
$start = $end->sub(new DateInterval('P1M'));
return $this->getVar($start, $end);
@ -42,9 +45,6 @@ class Ine implements Provider
$request_uri = implode('?', [
$this->uri,
http_build_query($request_query),
/*implode('&', array_map(function($val, $key) {
return "{$key}={$val}";
}, $request_query, array_keys($request_query)))*/
]);
try {
$response = $this->client->get($request_uri);