ylvarw /
module
| 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
|
|||
| 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 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.