supported($money_symbol)) { throw new EmptyResponse($money_symbol); } 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); } protected array $supportedMap = [ Money::IPC => 'ipc' ]; /** * @throws EmptyResponse */ public function getVar(DateTimeInterface $start, DateTimeInterface $end): float { $base = 1000000000; $request_query = [ 'mesInicio' => $start->format('m'), 'AnioInicio' => $start->format('Y'), 'mesTermino' => $end->format('m'), 'AnioTermino' => $end->format('Y'), 'valor_a_ajustar' => $base ]; $request_uri = implode('?', [ $this->uri, http_build_query($request_query), ]); try { $response = $this->client->get($request_uri); } catch (GuzzleException $exception) { throw new EmptyResponse($request_uri, $exception); } $body = $response->getBody(); $json = json_decode($body->getContents()); if (empty($json)) { throw new EmptyResponse($request_uri); } return ((int) str_replace('.', '', $json[0]->valorajustado) - $base) / $base; } }