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
![]() |
|||
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 |