Passed
Push — master ( fa46b3...ce6672 )
by Ylva
05:16 queued 02:30
created

DevelopmentController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 21
dl 0
loc 47
c 1
b 0
f 0
rs 10
wmc 2

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;
0 ignored issues
show
Bug introduced by
The type Anax\Commons\ContainerInjectableInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Anax\Commons\ContainerInjectableTrait;
0 ignored issues
show
Bug introduced by
The type Anax\Commons\ContainerInjectableTrait was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Anax\Route\Exception\NotFoundException;
0 ignored issues
show
Bug introduced by
The type Anax\Route\Exception\NotFoundException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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
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