DashboardController::dashboard()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 1
eloc 8
nc 1
nop 2
dl 0
loc 12
rs 10
c 2
b 1
f 0
1
<?php
2
3
namespace Jidaikobo\Kontiki\Controllers;
4
5
use Jidaikobo\Kontiki\Services\RoutesService;
6
use Psr\Http\Message\ResponseInterface as Response;
7
use Psr\Http\Message\ServerRequestInterface as Request;
8
use Slim\App;
9
use Slim\Routing\RouteCollectorProxy;
10
use Slim\Views\PhpRenderer;
11
12
class DashboardController
13
{
14
    private PhpRenderer $view;
15
    private array $routes;
16
17
    public function __construct(
18
        PhpRenderer $view,
19
        RoutesService $routesService
20
    ) {
21
        $this->view = $view;
22
        $this->routes = $routesService->getRoutesByType('dashboard');
23
        $this->setViewAttributes($routesService);
24
    }
25
26
    protected function setViewAttributes($routesService): void
27
    {
28
        $this->view->setAttributes([
29
                'lang' => env('APPLANG', 'en'),
30
                'sidebarItems' => $routesService->getRoutesByType('sidebar')
31
            ]);
32
    }
33
34
    public static function registerRoutes(App $app): void
35
    {
36
        $app->get('/dashboard', DashboardController::class . ':dashboard')
37
            ->setName('dashboard');
38
    }
39
40
    public function dashboard(Request $request, Response $response): Response
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

40
    public function dashboard(/** @scrutinizer ignore-unused */ Request $request, Response $response): Response

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

Loading history...
41
    {
42
        $content = $this->view->fetch(
43
            'dashboard/dashboard.php',
44
            ['dashboardItems' => $this->routes]
45
        );
46
        return $this->view->render(
47
            $response,
48
            'layout.php',
49
            [
50
                'pageTitle' => __('management_portal', 'Management Portal'),
51
                'content' => $content,
52
            ]
53
        );
54
    }
55
}
56