WeatherController::indexActionPost()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 11
rs 10
c 0
b 0
f 0
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 WeatherController implements ContainerInjectableInterface
10
{
11
    use ContainerInjectableTrait;
12
13
    public function indexAction($result = null)
14
    {
15
        $page = $this->di->get('page');
16
        $page->add('anax/weather/index', compact('result'));
17
18
        return $page->render([
19
            'title' => 'Weather',
20
        ]);
21
    }
22
23
    public function indexActionPost()
24
    {
25
        $request = $this->di->get('request');
26
        $curl = $this->di->get('curl');
27
28
        $ipAddr = (new IpLocator($request->getPost('ip')))->locateIp();
29
        $type = $request->getPost('type');
30
        $coords = $request->getPost('coords');
31
        $result = (new Weather)->processRequest($ipAddr, $coords, $type, $curl);
32
33
        return $this->indexAction($result);
34
    }
35
}
36