| Conditions | 4 |
| Paths | 4 |
| Total Lines | 30 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 19 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 28 | 2 | public function indexActionGet() : array |
|
| 29 | { |
||
| 30 | 2 | $request = $this->di->get("request"); |
|
| 31 | //request to get GET-info |
||
| 32 | 2 | $userip = $request->getGet("ip", "Ingen ip angiven"); |
|
| 33 | |||
| 34 | 2 | if ($userip) { |
|
| 35 | 2 | $validation = $this->di->get("iptest"); |
|
| 36 | 2 | $validation->setInput($userip); |
|
| 37 | 2 | $ip4 = $validation->ip4test(); |
|
| 38 | 2 | $ip6 = $validation->ip6test(); |
|
| 39 | } |
||
| 40 | |||
| 41 | 2 | if ($ip6 || $ip4) { |
|
| 42 | 1 | $hostname = gethostbyaddr($userip); |
|
| 43 | 1 | $geoInfo = $this->getGeo($userip); |
|
| 44 | } else { |
||
| 45 | 1 | $hostname = "Ej korrekt ip"; |
|
| 46 | 1 | $geoInfo = "Inget att visa"; |
|
| 47 | } |
||
| 48 | |||
| 49 | $data = [ |
||
| 50 | 2 | "ip" => $userip, |
|
| 51 | 2 | "ip4" => $ip4, |
|
| 52 | 2 | "ip6" => $ip6, |
|
| 53 | 2 | "host" => $hostname, |
|
| 54 | 2 | "geoInfo" => $geoInfo, |
|
| 55 | ]; |
||
| 56 | |||
| 57 | 2 | return [$data]; |
|
| 58 | } |
||
| 69 |