🆙 More fixes 🆙

This commit is contained in:
Remco
2026-01-19 20:43:46 +01:00
parent deed2158ca
commit 7b9849c159
77 changed files with 1084 additions and 13612 deletions
+8 -2
View File
@@ -10,12 +10,18 @@ class IpLookupService
public function __construct(private readonly string $apiKey) {}
/**
* @return array<string, mixed>
*/
public function ipLookup(string $ip): array
{
$response = Http::acceptJson()->get(sprintf('%s/%s?api-key=%s', $this->baseUrl, $ip, $this->apiKey));
/** @var array<string, mixed> $json */
$json = $response->json() ?? [];
if (! $response->ok()) {
$message = array_key_exists('message', $response->json()) ? $response->json()['message'] : 'Unknown error';
$message = array_key_exists('message', $json) ? $json['message'] : 'Unknown error';
return [
'message' => $message,
@@ -23,6 +29,6 @@ class IpLookupService
];
}
return $response->json();
return $json;
}
}