Conditions | 5 |
Paths | 10 |
Total Lines | 19 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 5 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | 3 | public function getJson($ip) : array |
|
17 | { |
||
18 | 3 | $valid = filter_var($ip, FILTER_VALIDATE_IP) ? "true" : "false"; |
|
19 | 3 | if ($valid == "true") { |
|
20 | 3 | $protocol = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ? "ipv4" : "ipv6"; |
|
21 | 3 | $getHost = gethostbyaddr($ip); |
|
22 | 3 | $domain = ($getHost == $ip) ? null : $getHost; |
|
23 | } else { |
||
24 | 2 | $protocol = null; |
|
25 | 2 | $domain = null; |
|
26 | } |
||
27 | return [ |
||
28 | 3 | "ip" => $ip, |
|
29 | 3 | "type" => $protocol, |
|
30 | 3 | "domain" => $domain, |
|
31 | 3 | "latitude" => 57.70887, |
|
32 | 3 | "longitude" => 11.97456, |
|
33 | "country_name" => null, |
||
34 | "city" => null |
||
35 | ]; |
||
38 |