WeatherJsonController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 27
c 0
b 0
f 0
ccs 14
cts 14
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A indexActionGet() 0 23 2
1
<?php
2
3
namespace Anax\Weather;
4
5
use Anax\Commons\ContainerInjectableInterface;
6
use Anax\Commons\ContainerInjectableTrait;
7
8
class WeatherJsonController implements ContainerInjectableInterface
9
{
10
    use ContainerInjectableTrait;
11
12 2
    public function indexActionGet() : array
13
    {
14 2
        $this->api = require ANAX_INSTALL_PATH . "/config/keys.php";
0 ignored issues
show
Bug Best Practice introduced by
The property api does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
15 2
        $address = $this->di->get("request")->getGet("address");
16 2
        $curl = $this->di->get("curl");
17 2
        $curl->getIpData($address, $this->api["ip_key"]);
18 2
        $curl->getWeatherData($this->api["weather_key"]);
19 2
        $resOne = $curl->weatherData;
20 2
        $resTwo = $curl->ipData;
21
22 2
        if (sizeOf($resOne) == 2) {
23
            $json = [
24 1
                "error" => $resOne["error"],
25
            ];
26
27 1
            return [$json];
28
        } else {
29
            $json = [
30 1
                "ip_data" => $resTwo,
31 1
                "daily_weather" => $resOne["daily"]["data"],
32
            ];
33
34 1
            return [$json];
35
        }
36
    }
37
}
38