WeatherController::indexAction()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 12
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 18
ccs 0
cts 13
cp 0
crap 2
rs 9.8666
1
<?php
2
3
namespace Anax\Controller;
4
5
use Anax\Commons\ContainerInjectableInterface;
6
use Anax\Commons\ContainerInjectableTrait;
7
8
class WeatherController implements ContainerInjectableInterface
9
{
10
11
    use ContainerInjectableTrait;
12
13
    /**
14
     * Request post and setup page.
15
     * @method indexAction
16
     * @return array
17
     */
18
    public function indexAction() : object
19
    {
20
        $title = "Weather";
21
22
        $location = htmlentities($this->di->get("request")->getPost("location"));
23
        $weather = $this->di->get("weather");
24
        $page = $this->di->get("page");
25
26
        $page->add("anax/weather/index", [
27
            "title" => $title,
28
            "location" => $location,
29
            "geolocation" => $weather->loadGeolocation($location),
30
            "weather" => $weather->loadWeather(),
31
            "historic" => $weather->multiCurl(),
32
        ]);
33
34
        return $page->render([
35
            "title" => $title,
36
        ]);
37
    }
38
}
39