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 ( f35c14...e8f958 )
by やかみ
03:06
created

App::__construct()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 24
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3.054

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 17
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 24
ccs 9
cts 11
cp 0.8182
crap 3.054
rs 8.9713
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
39
class App
40
{
41
    /**
42
     * Config Array
43
     *
44
     * @var array
45
     */
46
    protected $config = [];
47
48
    /**
49
     * Class constructor
50
     *
51
     * Initialize Framework.
52
     *
53
     * @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...
54
     */
55 1
    public function __construct($config = [])
56
    {
57 1
        if (version_compare(PHP_VERSION, '5.5.0', '<')) {
58
            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...
59
        }
60
61 1
        ini_set('display_errors', 'off');
62 1
        define('KOTORI_START_TIME', microtime(true));
63 1
        define('KOTORI_START_MEMORY', memory_get_usage());
64 1
        if (!empty($config)) {
65
            $this->config = $config;
66
        }
67
68 1
        Container::getInstance()->bind([
69 1
            'cache' => \Kotori\Core\Cache::class,
70
            'config' => \Kotori\Core\Config::class,
71
            'controller' => \Kotori\Core\Controller::class,
72
            'request' => \Kotori\Http\Request::class,
73
            'response' => \Kotori\Http\Response::class,
74
            'route' => \Kotori\Http\Route::class,
75
            'trace' => \Kotori\Debug\Trace::class,
76
            'model/provider' => \Kotori\Core\Model\Provider::class,
77
        ]);
78 1
    }
79
80
    /**
81
     * Start the App.
82
     *
83
     * @return void
84
     */
85
    public function run()
86
    {
87
        // Define a custom error handler so we can log PHP errors
88
        set_error_handler(['\\Kotori\Core\Handle', 'error']);
89
        set_exception_handler(['\\Kotori\Core\Handle', 'exception']);
90
        register_shutdown_function(['\\Kotori\Core\Handle', 'end']);
91
92
        Container::get('config')->initialize($this->config);
0 ignored issues
show
Bug introduced by
The method initialize() does not seem to exist on object<Kotori\Core\Facade>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
93
94
        ini_set('date.timezone', Container::get('config')->get('TIME_ZONE'));
0 ignored issues
show
Bug introduced by
The method get() does not seem to exist on object<Kotori\Core\Facade>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
95
96
        if (Container::get('config')->get('USE_SESSION')) {
0 ignored issues
show
Bug introduced by
The method get() does not seem to exist on object<Kotori\Core\Facade>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
97
            !session_id() && session_start();
98
        }
99
100
        // Load application's common functions
101
        Helper::import(Container::get('config')->get('APP_FULL_PATH') . '/common.php');
0 ignored issues
show
Bug introduced by
The method get() does not seem to exist on object<Kotori\Core\Facade>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
102
103
        // @codingStandardsIgnoreStart
104
        if (function_exists('spl_autoload_register')) {
105
            spl_autoload_register(['\\Kotori\\Core\\Helper', 'autoload']);
106
        } else {
107
            function __autoload($className)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
108
            {
109
                Helper::autoload($className);
110
            }
111
        }
112
        // @codingStandardsIgnoreEnd
113
114
        // Load route class
115
        Container::get('route')->dispatch();
0 ignored issues
show
Bug introduced by
The method dispatch() does not seem to exist on object<Kotori\Core\Facade>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
116
    }
117
118
}
119