for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Anax\Controller;
use Anax\Commons\ContainerInjectableInterface;
use Anax\Commons\ContainerInjectableTrait;
use Anax\Models\IpValidator;
use Anax\Models\GeoApi;
/**
* Controllerclass for the JSON-return of IP validation
*/
class IpToJSONController implements ContainerInjectableInterface
{
use ContainerInjectableTrait;
* validation of ip address and finding location based on ip
* using the api model classes IpValidator and GeoApi
public function validateIpApiAction()
$ipAdress = $_GET["ipAdress"];
// create instance of class GeoApi which inherits from IpValidator
$ipAndLocation = $this->di->get("geoapi");
$data = [
"valid" => $ipAndLocation->validateIp($ipAdress)["res"],
"domain" => $ipAndLocation->validateIp($ipAdress)["domain"] ?? null,
"location" => $ipAndLocation->findGeoLocation($ipAdress) ?? null
];
// rendering the result as formatted json
json_encode($data, true);
true
integer
$options
json_encode()
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
ignore-type
json_encode($data, /** @scrutinizer ignore-type */ true);
return [[ $data ]];
}