Conditions | 1 |
Paths | 1 |
Total Lines | 19 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 1 |
Changes | 0 |
1 | <?php |
||
30 | 3 | public function request() |
|
31 | { |
||
32 | // Get API key from configuration file |
||
33 | 3 | $cfg = $this->di->get("configuration"); |
|
34 | 3 | $config = $cfg->load("apikeys.php"); |
|
35 | 3 | $apikey = $config["config"]["ipstack"]; |
|
36 | |||
37 | // Initialize curl |
||
38 | 3 | $curl = curl_init('http://api.ipstack.com/' . $this->ipadd . '?access_key='. $apikey . ''); |
|
39 | 3 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
|
40 | |||
41 | // Store the data |
||
42 | 3 | $json = curl_exec($curl); |
|
43 | 3 | curl_close($curl); |
|
44 | |||
45 | // Decode JSON response |
||
46 | 3 | $res = json_decode($json, true); |
|
47 | |||
48 | 3 | return $res; |
|
49 | } |
||
65 |