Issues (29)

src/Controller/IpToJSONController.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Anax\Controller;
4
5
use Anax\Commons\ContainerInjectableInterface;
6
use Anax\Commons\ContainerInjectableTrait;
7
use Anax\Models\IpValidator;
8
use Anax\Models\GeoApi;
9
10
/**
11
 * Controllerclass for the JSON-return of IP validation
12
 */
13
class IpToJSONController implements ContainerInjectableInterface
14
{
15
    use ContainerInjectableTrait;
16
17
    /**
18
     * validation of ip address and finding location based on ip
19
     * using the api model classes IpValidator and GeoApi
20
     */
21
    public function validateIpApiAction()
22
    {
23
        $ipAdress = $_GET["ipAdress"];
24
25
        // create instance of class GeoApi which inherits from IpValidator
26
        $ipAndLocation = $this->di->get("geoapi");
27
28
        $data = [
29
            "valid" => $ipAndLocation->validateIp($ipAdress)["res"],
30
            "domain" => $ipAndLocation->validateIp($ipAdress)["domain"] ?? null,
31
            "location" => $ipAndLocation->findGeoLocation($ipAdress) ?? null
32
        ];
33
34
        // rendering the result as formatted json
35
        json_encode($data, true);
0 ignored issues
show
true of type true is incompatible with the type integer expected by parameter $options of json_encode(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

35
        json_encode($data, /** @scrutinizer ignore-type */ true);
Loading history...
36
        return [[ $data ]];
37
    }
38
}
39