| Conditions | 2 |
| Paths | 2 |
| Total Lines | 14 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 70 | private function fetchIpInfo(string $ip): array |
||
| 71 | { |
||
| 72 | ob_start(); |
||
| 73 | $ch = curl_init(); |
||
| 74 | curl_setopt($ch, CURLOPT_URL, "http://ip-api.com/json/{$ip}"); |
||
| 75 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
||
| 76 | $response = curl_exec($ch); |
||
| 77 | $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
||
| 78 | if ($httpStatus !== 200) { |
||
| 79 | throw new \Exception(self::FAILED_REQUEST); |
||
| 80 | } |
||
| 81 | $info = json_decode($response, true); |
||
| 82 | |||
| 83 | return $info; |
||
| 84 | } |
||
| 86 |