You've already forked Epicnabbo-Catalogus-Updated-Daily
🆙 More fixes 🆙
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user