Completed
Push — master ( b8b690...4f6cf9 )
by Mikael
10:54
created

DevelopmentController::catchAll()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 30

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 30
ccs 0
cts 26
cp 0
rs 9.44
c 0
b 0
f 0
cc 2
nc 2
nop 0
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
     * @throws Anax\Route\Exception\NotFoundException when route is not found.
22
23
     * @return object as the response.
24
     */
25
    public function catchAll() : object
26
    {
27
        $title = " | Anax development utilities";
28
        $pages = [
29
            "" => "index",
30
            "di" => "di",
31
            "request" => "request",
32
            "router" => "router",
33
            "session" => "session",
34
            "view" => "view",
35
        ];
36
37
        $path = $this->di->get("router")->getMatchedPath();
38
39
        if (!array_key_exists($path, $pages)) {
40
            throw new NotFoundException();
41
        }
42
43
        $page = $this->di->get("page");
44
        $page->add(
45
            "anax/v2/dev/{$pages[$path]}",
46
            [
47
                "mount" => "dev/"
48
            ]
49
        );
50
51
        return $page->render([
52
            "title" => ucfirst($pages[$path]) . $title
53
        ]); 
54
    }
55
}
56