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.
Completed
Push — master ( 859d66...4f628a )
by やかみ
01:26
created

App::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3.0987

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 8
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 13
ccs 7
cts 9
cp 0.7778
crap 3.0987
rs 9.4285
1
<?php
2
/**
3
 * Kotori.php
4
 *
5
 * A Tiny Model-View-Controller PHP Framework
6
 *
7
 * This content is released under the Apache 2 License
8
 *
9
 * Copyright (c) 2015-2017 Kotori Technology. All rights reserved.
10
 *
11
 * Licensed under the Apache License, Version 2.0 (the "License");
12
 * you may not use this file except in compliance with the License.
13
 * You may obtain a copy of the License at
14
 *
15
 *     http://www.apache.org/licenses/LICENSE-2.0
16
 *
17
 * Unless required by applicable law or agreed to in writing, software
18
 * distributed under the License is distributed on an "AS IS" BASIS,
19
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
 * See the License for the specific language governing permissions and
21
 * limitations under the License.
22
 */
23
24
/**
25
 * Kotori Initialization Class
26
 *
27
 * Loads the base classes and executes the request.
28
 *
29
 * @package     Kotori
30
 * @subpackage  Kotori
31
 * @author      Kokororin
32
 * @link        https://kotori.love
33
 */
34
namespace Kotori;
35
36
use Kotori\Core\Container;
37
use Kotori\Core\Helper;
38
use Kotori\Core\Middleware;
39
40
class App
41
{
42
    /**
43
     * Config Array
44
     *
45
     * @var array
46
     */
47
    protected $config = [];
48
49
    /**
50
     * Class constructor
51
     *
52
     * Initialize Framework.
53
     *
54
     * @param  array $config
55
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
56
     */
57 1
    public function __construct($config = [])
58
    {
59 1
        if (version_compare(PHP_VERSION, '5.5.0', '<')) {
60
            exit('Kotori.php requires PHP >= 5.5.0 !');
0 ignored issues
show
Coding Style Compatibility introduced by
The method __construct() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
61
        }
62
63 1
        ini_set('display_errors', 'off');
64 1
        define('KOTORI_START_TIME', microtime(true));
65 1
        define('KOTORI_START_MEMORY', memory_get_usage());
66 1
        if (!empty($config)) {
67
            $this->config = $config;
68
        }
69 1
    }
70
71
    /**
72
     * Start the App.
73
     *
74
     * @return void
75
     */
76
    public function run()
77
    {
78
        // Define a custom error handler so we can log PHP errors
79
        set_error_handler([\Kotori\Core\Handle::class, 'error']);
80
        set_exception_handler([\Kotori\Core\Handle::class, 'exception']);
81
        register_shutdown_function([\Kotori\Core\Handle::class, 'end']);
82
83
        Container::get('config')->initialize($this->config);
84
        Middleware::register('before_app');
85
86
        ini_set('date.timezone', Container::get('config')->get('time_zone'));
87
88
        // Load application's common functions
89
        Helper::import(Container::get('config')->get('app_full_path') . '/common.php');
90
91
        // @codingStandardsIgnoreStart
92
        if (function_exists('spl_autoload_register')) {
93
            spl_autoload_register(['\\Kotori\\Core\\Helper', 'autoload']);
94
        } else {
95
            function __autoload($className)
96
            {
97
                Helper::autoload($className);
98
            }
99
        }
100
        // @codingStandardsIgnoreEnd
101
102
        // Init session
103
        Container::get('request')->sessionInit();
104
105
        Middleware::register('after_app');
106
        // Load route class
107
        Container::get('route')->dispatch();
108
    }
109
110
}
111