diff --git a/app/src/Service/Money/Ine.php b/app/src/Service/Money/Ine.php index 07edfe0..24c693c 100644 --- a/app/src/Service/Money/Ine.php +++ b/app/src/Service/Money/Ine.php @@ -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);