withHeaders($headers) ->send($httpMethod, $url); return match (true) { $response->noContent() => null, $response->failed() => throw ApiException::createFromResponse($response->toPsrResponse(), null), empty($response->body()) => throw new ApiException('Mollie response body is empty.'), default => $this->parseResponseBody($response), }; } private function parseResponseBody(Response $response): ?object { $body = $response->body(); $object = @json_decode($body); if (json_last_error() !== JSON_ERROR_NONE) { throw new ApiException("Unable to decode Mollie response: '{$body}'."); } return $object; } public function versionString(): string { return 'Laravel/HttpClient'; } }