Welcome::viewEvents()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 10
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 18
rs 9.4285
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
}