WeatherController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Test Coverage

Coverage 32.5%

Importance

Changes 0
Metric Value
wmc 4
eloc 38
dl 0
loc 91
ccs 13
cts 40
cp 0.325
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A resultActionGet() 0 23 1
A restinfoActionGet() 0 7 1
A indexActionGet() 0 6 1
A restActionGet() 0 18 1
1
<?php
2
3
namespace KW\KWcontroller;
4
5
use Anax\Commons\ContainerInjectableInterface;
6
use Anax\Commons\ContainerInjectableTrait;
7
8
class WeatherController implements ContainerInjectableInterface
9
{
10
    use ContainerInjectableTrait;
11
12
13
    /**
14
     * This is the index method action, it handles:
15
     * GET METHOD mountpoint
16
     * GET METHOD mountpoint/
17
     * GET METHOD mountpoint/index
18
     *
19
     * @return object
20
     */
21
    public function indexActionGet()
22
    {
23
        $page = $this->di->get("page");
24
        $page->add("anax/v2/weather/formular");
25
        return $page->render([
26
            "title"=>"Väder"
27
        ]);
28
    }
29
30
    /*
31
    * @return object
32
    */
33
    public function restinfoActionGet()
34
    {
35
        $page = $this->di->get("page");
36
        $page->add("anax/v2/weather/restinfo");
37
38
        return $page->render([
39
            "title"=>"Väder"
40
        ]);
41
    }
42
43
44
    /**
45
    * Return weather from darkSky
46
    *
47
    * @return object
48
    */
49
    public function resultActionGet()
50
    {
51
        $longitude = null;
0 ignored issues
show
Unused Code introduced by
The assignment to $longitude is dead and can be removed.
Loading history...
52
        $latitude = null;
0 ignored issues
show
Unused Code introduced by
The assignment to $latitude is dead and can be removed.
Loading history...
53
        $ipn = "";
0 ignored issues
show
Unused Code introduced by
The assignment to $ipn is dead and can be removed.
Loading history...
54
        $longitude = $this->di->get("request")->getGet("longitude");
55
        $latitude = $this->di->get("request")->getGet("latitude");
56
        $type = $this->di->get("request")->getGet("type");
57
        $ipn = $this->di->get("request")->getGet("ipnummer");
58
59
        $darkSkyUmbrella = new \KW\Models\DarkSkyUmbrella($this->di);
60
61
        $res = $darkSkyUmbrella->input($longitude, $latitude, $type, $ipn);
62
63
        $page = $this->di->get("page");
64
        $page->add("anax/v2/weather/result", [
65
            "res" => $res,
66
            "longitude" => $longitude,
67
            "latitude" => $latitude,
68
            ]);
69
70
        return $page->render([
71
            "title" => "Väderresultat"
72
            ]);
73
    }
74
75
76
    /**
77
    * Return weather from restfully
78
    *
79
    * @return object
80
    */
81 1
    public function restActionGet() : array
82
    {
83 1
        $longitude = null;
0 ignored issues
show
Unused Code introduced by
The assignment to $longitude is dead and can be removed.
Loading history...
84 1
        $latitude = null;
0 ignored issues
show
Unused Code introduced by
The assignment to $latitude is dead and can be removed.
Loading history...
85 1
        $ipn = "";
0 ignored issues
show
Unused Code introduced by
The assignment to $ipn is dead and can be removed.
Loading history...
86 1
        $longitude = $this->di->get("request")->getGet("lon");
87 1
        $latitude = $this->di->get("request")->getGet("lat");
88 1
        $type = $this->di->get("request")->getGet("type");
89 1
        $ipn = $this->di->get("request")->getGet("ipn");
90
91 1
        $darkSkyUmbrella = new \KW\Models\DarkSkyUmbrella($this->di);
92
        //$jsonWeather = new \KW\Models\JsonWeather;
93 1
        $jsonWeather = $this->di->get("jsonWeather");
94
95 1
        $res1 = $darkSkyUmbrella->input($longitude, $latitude, $type, $ipn);
96 1
        $res = $jsonWeather->jsonify($res1);
97
98 1
        return $res;
99
    }
100
}
101