Passed
Push — master ( 786715...5dce3b )
by Fran
02:39
created

bootstrap::load()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 5
c 1
b 0
f 0
nc 5
nop 0
dl 0
loc 8
ccs 6
cts 6
cp 1
crap 4
rs 10
1
<?php
2
3
namespace PSFS;
4
5
defined('PSFS_START_MEM') or define('PSFS_START_MEM', memory_get_usage());
6
defined('PSFS_START_TS') or define('PSFS_START_TS', microtime(true));
7
// PHP under version 7.3 compatibility
8
defined('JSON_THROW_ON_ERROR') or define('JSON_THROW_ON_ERROR', 4194304);
9
defined('JSON_INVALID_UTF8_SUBSTITUTE') or define('JSON_INVALID_UTF8_SUBSTITUTE', 2097152);
10
11
if (defined('PSFS_PHAR_DIR') && file_exists(PSFS_PHAR_DIR . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'environment.php')) {
0 ignored issues
show
Bug introduced by
The constant PSFS\PSFS_PHAR_DIR was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
12
    @require_once PSFS_PHAR_DIR . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'environment.php';
13
}
14
15
defined('SOURCE_DIR') or define('SOURCE_DIR', __DIR__);
16
if (str_contains(SOURCE_DIR, 'vendor')) {
17
    defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..');
18
    defined('CORE_DIR') or define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'src');
19
} else {
20
    defined('BASE_DIR') or define('BASE_DIR', SOURCE_DIR . DIRECTORY_SEPARATOR . '..');
21
    defined('CORE_DIR') or define('CORE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'modules');
22
}
23
defined('VENDOR_DIR') or define('VENDOR_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'vendor');
24
defined('LOG_DIR') or define('LOG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'logs');
25
defined('CACHE_DIR') or define('CACHE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'cache');
26
defined('CONFIG_DIR') or define('CONFIG_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'config');
27
defined('WEB_DIR') or define('WEB_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'html');
28
defined('LOCALE_DIR') or define('LOCALE_DIR', BASE_DIR . DIRECTORY_SEPARATOR . 'locale');
29
30
if (!class_exists(bootstrap::class)) {
31
    /**
32
     * Class Bootstrap
33
     * @package PSFS
34
     */
35
    class bootstrap
36
    {
37
        public static bool $loaded = false;
38
39 2
        public static function load(): void
40
        {
41 2
            if (!self::$loaded) {
42 1
                defined('PSFS_BOOTSTRAP_LOADED') or define('PSFS_BOOTSTRAP_LOADED', true);
43 1
                if (class_exists("\\PSFS\\base\\Logger")) {
44 1
                    \PSFS\base\Logger::log('Bootstrap initialized', LOG_INFO);
45
                }
46 1
                self::$loaded = true;
47
            }
48
        }
49
    }
50
51
    require_once 'functions.php';
52
}
53