Issues (36)

src/API/APIController.php (2 issues)

1
<?php
2
3
/**
4
 * API Controller
5
 */
6
7
namespace Hepa19\Api;
8
9
use Anax\Commons\ContainerInjectableInterface;
10
use Anax\Commons\ContainerInjectableTrait;
11
12
/**
13
 * Controller for API page
14
 *
15
 */
16
class APIController implements ContainerInjectableInterface
17
{
18
    use ContainerInjectableTrait;
19
20
    /**
21
     * Index page
22
     *
23
     * @return object
24
     */
25 3
    public function indexActionGet() : object
26
    {
27 3
        $page = $this->di->get("page");
28 3
        $title = "Api";
29 3
        $request = $this->di->get("request");
30 3
        $location = $request->getGet("location");
0 ignored issues
show
The assignment to $location is dead and can be removed.
Loading history...
31 3
        $location = $request->getGet("ip");
32 3
        $type = $request->getGet("type");
33
34 3
        if ($type == "past") {
35 1
            $past = "checked";
36
        } else {
37 2
            $future = "checked";
38
        }
39
40 3
        if (empty($location)) {
41 1
            $ipgetcurrent = $this->di->get("ipgetcurrent");
42 1
            $location = $ipgetcurrent->getIP();
43
        }
44
45 3
        if (empty($ip)) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $ip seems to never exist and therefore empty should always be true.
Loading history...
46 3
            $ipgetcurrent = $this->di->get("ipgetcurrent");
47 3
            $ip = $ipgetcurrent->getIP();
48
        }
49
50
        $data = [
51 3
            "location" => $location ?? null,
52 3
            "checked1" => $future ?? null,
53 3
            "checked2" => $past ?? null,
54 3
            "ip" => $ip ?? null
55
        ];
56
57 3
        $page->add("api/json", $data);
58
59 3
        return $page->render([
60 3
            "title" => $title
61
        ]);
62
    }
63
}
64