StartController::dumpDiActionGet()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
nc 1
nop 0
dl 0
loc 5
c 0
b 0
f 0
cc 1
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Pamo\Start;
4
5
use Anax\Commons\ContainerInjectableInterface;
6
use Anax\Commons\ContainerInjectableTrait;
7
8
/**
9
 * Start controller.
10
 */
11
class StartController implements ContainerInjectableInterface
12
{
13
    use ContainerInjectableTrait;
14
15
16
17
    /**
18
     * The initialize method is optional and will always be called before the
19
     * target method/action. This is a convienient method where you could
20
     * setup internal properties that are commonly used by several methods.
21
     *
22
     * @return void
23
     */
24 3
    public function initialize() : void
25
    {
26 3
        $this->base = "start";
0 ignored issues
show
Bug Best Practice introduced by
The property base does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
27 3
        $this->title = "Overview";
0 ignored issues
show
Bug Best Practice introduced by
The property title does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
28 3
        $this->game = $this->di->get("game");
0 ignored issues
show
Bug Best Practice introduced by
The property game does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
29 3
        $this->page = $this->di->get("page");
0 ignored issues
show
Bug Best Practice introduced by
The property page does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
30 3
    }
31
32
33
34
    /**
35
     * Landing page.
36
     *
37
     * @return object as a response object
38
     */
39 1
    public function indexActionGet() : object
40
    {
41 1
        $this->page = $this->di->get("page");
0 ignored issues
show
Bug Best Practice introduced by
The property page does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
42 1
        $sql = "*, COUNT(tagname) AS cnt";
43
44
        $data = [
45 1
            "title" => $this->title,
46 1
            "questionCount" => $this->game->question->count()->count,
47 1
            "tagCount" => $this->game->tag->count()->count,
48 1
            "userCount" => $this->game->user->count()->count,
49 1
            "question" => $this->game->question->findAllOrder("created DESC", 3),
50 1
            "tags" => $this->game->tagQuestion->findAllGroupOrder($sql, "tagname", "cnt DESC", 3),
51 1
            "users" => $this->game->user->findAllOrder("rank DESC", 3),
52 1
            "gravatar" => $this->game->gravatar
53
        ];
54
55 1
        $this->page->add("block/nav-admin", $this->game->getNav());
56 1
        $this->page->add($this->base . "/index", $data);
57
58 1
        return $this->page->render([
59 1
            "title" => $this->title,
60
        ]);
61
    }
62
63
64
65
    /**
66
     * This sample method dumps the content of $di.
67
     * GET mountpoint/dump-app
68
     *
69
     * @return string
70
     */
71 1
    public function dumpDiActionGet() : string
72
    {
73
        // Deal with the action and return a response.
74 1
        $services = implode(", ", $this->di->getServices());
75 1
        return __METHOD__ . "<p>\$di contains: $services";
76
    }
77
78
79
80
    /**
81
     * Adding an optional catchAll() method will catch all actions sent to the
82
     * router. You can then reply with an actual response or return void to
83
     * allow for the router to move on to next handler.
84
     * A catchAll() handles the following, if a specific action method is not
85
     * created:
86
     * ANY METHOD mountpoint/**
87
     *
88
     * @param array $args as a variadic parameter.
89
     *
90
     * @return mixed
91
     *
92
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
93
     */
94 1
    public function catchAll(...$args)
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

94
    public function catchAll(/** @scrutinizer ignore-unused */ ...$args)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
95
    {
96
        // Deal with the request and send an actual response, or not.
97
        //return __METHOD__ . ", \$db is {$this->db}, got '" . count($args) . "' arguments: " . implode(", ", $args);
98 1
        return;
99
    }
100
}
101