Issues (26)

src/Controller/IpCurl.php (3 issues)

Labels
Severity
1
<?php
2
3
4
namespace Anax\Controller;
5
6
class IpCurl
7
{
8
9
    /**
10
11
     * Curls the ip address to an api
12
13
     */
14
15
    public function curl($ip)
16
    {
17
18
19
        $access_key = "5f23ea8bea3969482c26bb6b2d8249bf";
20
21
        $url = 'http://api.ipstack.com/'.$ip.'?access_key='.$access_key.'';
22
23
24
        // Initialize CURL request:
25
        $ch = curl_init($url);
26
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
0 ignored issues
show
It seems like $ch can also be of type false; however, parameter $ch of curl_setopt() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

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

26
        curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_RETURNTRANSFER, true);
Loading history...
27
28
29
        // Store the data in a var:
30
        $json = curl_exec($ch);
0 ignored issues
show
It seems like $ch can also be of type false; however, parameter $ch of curl_exec() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

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

30
        $json = curl_exec(/** @scrutinizer ignore-type */ $ch);
Loading history...
31
        curl_close($ch);
0 ignored issues
show
It seems like $ch can also be of type false; however, parameter $ch of curl_close() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

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

31
        curl_close(/** @scrutinizer ignore-type */ $ch);
Loading history...
32
33
34
        // Decode the JSON response:
35
        $api_result = json_decode($json, true);
36
        return $api_result;
37
    }
38
}
39