GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( f28312...62896a )
by
unknown
02:33
created

Kernel   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 121
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 38
dl 0
loc 121
rs 10
c 0
b 0
f 0
wmc 17

5 Methods

Rating   Name   Duplication   Size   Complexity  
A cliIO() 0 9 2
A httpIO() 0 10 2
B __construct() 0 30 9
A __isset() 0 3 1
A __get() 0 11 3
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System;
15
16
// ------------------------------------------------------------------------
17
18
/*
19
 *---------------------------------------------------------------
20
 * KERNEL PATH
21
 *---------------------------------------------------------------
22
 *
23
 * RealPath to application folder.
24
 *
25
 * WITH TRAILING SLASH!
26
 */
27
if ( ! defined('PATH_KERNEL')) {
28
    define('PATH_KERNEL', __DIR__ . DIRECTORY_SEPARATOR);
29
}
30
31
require_once 'Helpers/Kernel.php';
32
33
/**
34
 * Class Kernel
35
 *
36
 * @package O2System
37
 */
38
class Kernel extends Psr\Patterns\Creational\Singleton\AbstractSingleton
39
{
40
    /**
41
     * Kernel Services
42
     *
43
     * @var Kernel\Containers\Services
44
     */
45
    public $services;
46
47
    // ------------------------------------------------------------------------
48
49
    /**
50
     * Kernel::__construct
51
     */
52
    protected function __construct()
53
    {
54
        parent::__construct();
55
56
        $this->services = new Kernel\Containers\Services();
57
58
        if (isset($_ENV[ 'DEBUG_STAGE' ]) and $_ENV[ 'DEBUG_STAGE' ] === 'DEVELOPER') {
59
            $this->services->load(Gear\Profiler::class);
60
            if (profiler() !== false) {
61
                profiler()->watch('Starting Kernel Services');
62
            }
63
        }
64
65
        $services = [
66
            'Services\Language' => 'language'
67
        ];
68
69
        foreach ($services as $className => $classOffset) {
70
            $this->services->load($className, $classOffset);
71
        }
72
73
        if (profiler() !== false) {
74
            profiler()->watch('Starting Kernel I/O Service');
75
        }
76
77
        if (class_exists('O2System\Framework', false) or class_exists('O2System\Reactor', false)) {
78
            if (is_cli()) {
79
                $this->cliIO();
80
            } else {
81
                $this->httpIO();
82
            }
83
        }
84
    }
85
86
    // ------------------------------------------------------------------------
87
88
    /**
89
     * Kernel::cliIO
90
     *
91
     * Runs command line input/output services.
92
     */
93
    private function cliIO()
94
    {
95
        $services = [
96
            'Cli\Input'  => 'input',
97
            'Cli\Output' => 'output',
98
        ];
99
100
        foreach ($services as $className => $classOffset) {
101
            $this->services->load($className, $classOffset);
102
        }
103
    }
104
105
    // ------------------------------------------------------------------------
106
107
    /**
108
     * Kernel::httpIO
109
     *
110
     * Runs http input/output services.
111
     */
112
    private function httpIO()
113
    {
114
        $services = [
115
            'Http\Message\ServerRequest' => 'serverRequest',
116
            'Http\Input'                 => 'input',
117
            'Http\Output'                => 'output',
118
        ];
119
120
        foreach ($services as $className => $classOffset) {
121
            $this->services->load($className, $classOffset);
122
        }
123
    }
124
125
    // ------------------------------------------------------------------------
126
127
    /**
128
     * Kernel::__isset
129
     *
130
     * @param string $property
131
     *
132
     * @return bool
133
     */
134
    public function __isset($property)
135
    {
136
        return (bool)isset($this->{$property});
137
    }
138
139
    // ------------------------------------------------------------------------
140
141
    /**
142
     * Kernel::__get
143
     *
144
     * @param string $property
145
     *
146
     * @return mixed
147
     */
148
    public function &__get($property)
149
    {
150
        $get[ $property ] = null;
0 ignored issues
show
Comprehensibility Best Practice introduced by
$get was never initialized. Although not strictly required by PHP, it is generally a good practice to add $get = array(); before regardless.
Loading history...
151
152
        if (isset($this->{$property})) {
153
            $get[ $property ] =& $this->{$property};
154
        } elseif ($this->services->has($property)) {
155
            $get[ $property ] = $this->services->get($property);
156
        }
157
158
        return $get[ $property ];
159
    }
160
}