Passed
Push — main ( c42d70...1b364a )
by Åsa
02:29
created

WeatherRequestController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 13
ccs 6
cts 6
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A indexAction() 0 9 1
1
<?php
2
3
namespace Asti\Weather;
4
5
use Anax\Commons\ContainerInjectableInterface;
6
use Anax\Commons\ContainerInjectableTrait;
7
8
// use Anax\Route\Exception\ForbiddenException;
9
// use Anax\Route\Exception\NotFoundException;
10
// use Anax\Route\Exception\InternalErrorException;
11
12
/**
13
 * A sample controller to show how a controller class can be implemented.
14
 * The controller will be injected with $di if implementing the interface
15
 * ContainerInjectableInterface, like this sample class does.
16
 * The controller is mounted on a particular route and can then handle all
17
 * requests for that mount point.
18
 *
19
 * @SuppressWarnings(PHPMD.TooManyPublicMethods)
20
 */
21
class WeatherRequestController implements ContainerInjectableInterface
22
{
23
    use ContainerInjectableTrait;
24
25 1
    public function indexAction(): object
26
    {
27 1
        $ip = $_SERVER['REMOTE_ADDR'] ?? "127.0.0.1";
28 1
        $page = $this->di->get("page");
29
        $data = [
30 1
            "ipAdress" => $ip
31
        ];
32 1
        $page->add("weather_api/weather_request", $data);
33 1
        return $page->render($data);
34
    }
35
36
37
}
38