Welcome   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 50
rs 10
wmc 6
lcom 0
cbo 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A index() 0 12 1
A viewRoutePaths() 0 10 1
A viewEvents() 0 18 3
1
<?php
2
3
namespace App\Controller\Admin;
4
5
use Core\Application;
6
use Core\Utils\ArrayUtils;
7
use Core\ViewModel;
8
use Prob\ArrayUtil\KeyGlue;
9
10
class Welcome
11
{
12
    public function __construct(ViewModel $view, $urlPattern)
13
    {
14
        $view->set('nav', $urlPattern);
15
    }
16
17
    public function index(ViewModel $view)
18
    {
19
        $view->set('siteUrl', Application::getUrl());
20
        $view->set('sitePublicUrl', Application::getPublicUrl());
21
22
        $view->set('absolutePath', realpath(__DIR__ . '/../../'));
23
        $view->set('phpVersion', PHP_VERSION);
24
        $view->set('os', PHP_OS);
25
        $view->set('sapi', PHP_SAPI);
26
27
        return 'server';
28
    }
29
30
    public function viewRoutePaths(ViewModel $view)
31
    {
32
        $routePaths = AdminService::getRoutePaths();
33
        unset($routePaths['namespace']);
34
35
        $view->set('namespace', AdminService::getRoutePaths()['namespace']);
36
        $view->set('routePaths', $routePaths);
37
38
        return 'route';
39
    }
40
41
    public function viewEvents(ViewModel $view)
42
    {
43
        $glue = new KeyGlue();
44
        $glue->setGlueCharacter(' / ');
45
        $glue->setArray(AdminService::getEventHandlers());
46
47
        $events = $glue->glueKeyAndContainValue();
48
49
        foreach ($events as $k => $v) {
50
            if (is_string($events[$k]) == false) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
51
                $events[$k] = '{ Closure function }';
52
            }
53
        }
54
55
        $view->set('events', $events);
56
57
        return 'event';
58
    }
59
}