DevelopmentController::catchAll()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 32

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 32
ccs 0
cts 12
cp 0
rs 9.408
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 6
1
<?php
2
3
namespace Anax\Controller;
4
5
use Anax\Commons\ContainerInjectableInterface;
6
use Anax\Commons\ContainerInjectableTrait;
7
use Anax\Route\Exception\NotFoundException;
8
9
/**
10
 * A controller to ease with development and debugging information.
11
 */
12
class DevelopmentController implements ContainerInjectableInterface
13
{
14
    use ContainerInjectableTrait;
15
16
17
18
    /**
19
     * Render views that are supported.
20
     *
21
     * @param array $args as a variadic to catch all arguments.
22
     *
23
     * @throws Anax\Route\Exception\NotFoundException when route is not found.
24
25
     * @return object as the response.
26
     *
27
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
28
     */
29
    public function catchAll(...$args) : object
0 ignored issues
show
Unused Code introduced by
The parameter $args is not used and could be removed.

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

Loading history...
30
    {
31
        $pages = [
32
            "" => "index",
33
            "di" => "di",
34
            "request" => "request",
35
            "router" => "router",
36
            "session" => "session",
37
            "session/increment" => "session_increment",
38
            "session/destroy" => "session_destroy",
39
            "view" => "view",
40
        ];
41
42
        $path = $this->di->get("router")->getMatchedPath();
43
44
        if (!array_key_exists($path, $pages)) {
45
            throw new NotFoundException("No such page '$path' in the development controller.");
46
        }
47
48
        $page = $this->di->get("page");
49
        $page->add(
50
            "anax/v2/dev/{$pages[$path]}",
51
            [
52
                "mount" => "dev/"
53
            ]
54
        );
55
56
        return $page->render([
57
            "title" => ucfirst($pages[$path]),
58
            "baseTitle" => " | Anax development utilities"
59
        ]);
60
    }
61
}
62