Completed
Push — master ( 9df9c8...3f2069 )
by Park Jong-Hun
02:16
created

Welcome::viewEvents()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 10
nc 3
nop 1
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
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
    public function __construct(ViewModel $view, $urlPattern)
12
    {
13
        $view->set('nav', $urlPattern);
14
    }
15
16
    public function index(ViewModel $view) {
17
        $view->set('siteUrl', Application::getUrl());
18
        $view->set('sitePublicUrl', Application::getPublicUrl());
19
20
        $view->set('absolutePath', realpath(__DIR__ . '/../../'));
21
        $view->set('phpVersion', PHP_VERSION);
22
        $view->set('os', PHP_OS);
23
        $view->set('sapi', PHP_SAPI);
24
25
        return 'server';
26
    }
27
28
    public function viewRoutePaths(ViewModel $view) {
29
        $routePaths = AdminService::getRoutePaths();
30
        unset($routePaths['namespace']);
31
32
        $view->set('namespace', AdminService::getRoutePaths()['namespace']);
33
        $view->set('routePaths', $routePaths);
34
35
        return 'route';
36
    }
37
38
    public function viewEvents(ViewModel $view) {
39
        $glue = new KeyGlue();
40
        $glue->setGlueCharacter(' / ');
41
        $glue->setArray(AdminService::getEventHandlers());
42
43
        $events = $glue->glueKeyAndContainValue();
44
45
        foreach($events as $k => $v) {
46
            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...
47
                $events[$k] = '{ Closure function }';
48
            }
49
        }
50
51
        $view->set('events', $events);
52
53
        return 'event';
54
    }
55
}