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

DevelopmentController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 44
ccs 0
cts 26
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A catchAll() 0 30 2
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