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

Welcome   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A index() 0 11 1
A viewRoutePaths() 0 9 1
A viewEvents() 0 17 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
    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
}