Issues (13)

src/Models/Locator.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Jodn14\Models;
4
5
/**
6
 * Model for IP Locator logic
7
 */
8
class Locator
9
{
10
    /*
11
     * Private $access_key contains key to third party API - ipstack.com
12
     */
13
14
    private $accessKey = "26ac05fc6257e7fc03c369cec5552b0a";
15
16
    /**
17
     * calls ipstack with ip parameter
18
     *
19
     * @param string ipAddress
0 ignored issues
show
The type Jodn14\Models\ipAddress was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
     * @return array
21
     */
22 6
    public function getLocation($ipAddress) : array
23
    {
24 6
        $apiCall = curl_init('http://api.ipstack.com/'.$ipAddress.'?access_key='.$this->accessKey.'');
25 6
        curl_setopt($apiCall, CURLOPT_RETURNTRANSFER, true);
26
27 6
        $json = curl_exec($apiCall);
28 6
        curl_close($apiCall);
29
30 6
        $apiResult = json_decode($json, true);
31
        $filtered = [
32 6
            "ip"           => $apiResult["ip"],
33 6
            "type"         => $apiResult["type"],
34 6
            "country_name" => $apiResult["country_name"],
35 6
            "city"         => $apiResult["city"],
36 6
            "latitude"     => $apiResult["latitude"],
37 6
            "longitud"     => $apiResult["longitude"]
38
        ];
39
40 6
        return $filtered;
41
    }
42
}
43