Total Complexity | 8 |
Total Lines | 73 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
12 | class IpValidator |
||
13 | { |
||
14 | private $keys; |
||
15 | |||
16 | public function setKeys($config) |
||
17 | { |
||
18 | $this->keys = $config; |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * Curl from url |
||
23 | */ |
||
24 | public function curl($url) |
||
25 | { |
||
26 | $curl = curl_init($url); |
||
27 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
||
28 | $data = curl_exec($curl); |
||
29 | curl_close($curl); |
||
30 | |||
31 | return $data; |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Validate IP-adress |
||
36 | */ |
||
37 | public function validateIp($ipAdress) |
||
38 | { |
||
39 | $accessToken = $this->keys["ipValidator"]; |
||
40 | $stackUrl = 'http://api.ipstack.com/' . $ipAdress . '?access_key=' . $accessToken . ''; |
||
41 | |||
42 | $host = ""; |
||
43 | $stack = ""; |
||
44 | $type = ""; |
||
45 | $valid = ""; |
||
46 | |||
47 | if (filter_var($ipAdress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { |
||
48 | $host = gethostbyaddr($ipAdress); |
||
49 | $stack = json_decode($this->curl($stackUrl)); |
||
50 | $type = "IPv4"; |
||
51 | $valid = true; |
||
52 | } elseif (filter_var($ipAdress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { |
||
53 | $host = gethostbyaddr($ipAdress); |
||
54 | $stack = json_decode($this->curl($stackUrl)); |
||
55 | $type = "IPv6"; |
||
56 | $valid = true; |
||
57 | } else { |
||
58 | $valid = false; |
||
59 | } |
||
60 | |||
61 | $data = [ |
||
62 | "ip" => $ipAdress, |
||
63 | "valid" => $valid, |
||
64 | "type" => $type, |
||
65 | "host" => $host, |
||
66 | "stack" => $stack |
||
67 | ]; |
||
68 | return $data; |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * Get current IP-adress |
||
73 | */ |
||
74 | public function getYourIp($request) |
||
85 | } |
||
86 | } |
||
87 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths