WeatherApiController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A forecastAction() 0 12 1
A indexAction() 0 7 1
1
<?php
2
3
namespace H4MSK1\Weather;
4
5
use Anax\Commons\ContainerInjectableInterface;
6
use Anax\Commons\ContainerInjectableTrait;
7
use H4MSK1\IpLocator\IpLocator;
8
9
class WeatherApiController implements ContainerInjectableInterface
10
{
11
    use ContainerInjectableTrait;
12
13
    public function indexAction()
14
    {
15
        $page = $this->di->get('page');
16
        $page->add('anax/weather/api');
17
18
        return $page->render([
19
            'title' => 'Weather',
20
        ]);
21
    }
22
23
    public function forecastAction()
24
    {
25
        $request = $this->di->get('request');
26
        $curl = $this->di->get('curl');
27
28
        $ipAddr = (new IpLocator($request->getGet('ip')))->locateIp();
29
        $type = $request->getGet('type');
30
        $coords = $request->getGet('coords');
31
        $result = (new Weather)->processRequest($ipAddr, $coords, $type, $curl);
32
        unset($result['map']);
33
34
        return [$result];
35
    }
36
}
37