Passed
Push — master ( be88e3...87c6b6 )
by Fran
04:17
created

PSFSAutoloader()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 24
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 11
nc 5
nop 1
dl 0
loc 24
rs 9.9
c 1
b 0
f 0
1
<?php
2
/**
3
 * Simple, Fast & Secure Framework
4
 * @author Fran Lopez <[email protected]>
5
 * @version 0.1
6
 */
7
defined("BASE_DIR") or define("BASE_DIR", dirname(dirname(__DIR__)));
8
\PSFS\bootstrap::load();
9
if (!function_exists("PSFSAutoloader")) {
10
    // autoloader
11
    function PSFSAutoloader($class)
12
    {
13
        // it only autoload class into the Rain scope
14
        if (strpos($class, 'PSFS') !== false) {
15
16
            // Change order src
17
            $class = str_replace('PSFS', '', $class);
18
            // transform the namespace in path
19
            $path = str_replace("\\", DIRECTORY_SEPARATOR, $class);
20
21
            // filepath
22
            $abs_path = SOURCE_DIR . DIRECTORY_SEPARATOR . $path . ".php";
23
            if (!file_exists($abs_path)) {
24
                pre('&rarr;&nbsp;' . $class);
25
                pre('&rarr;&nbsp;' . $path);
26
                pre('&rarr;&nbsp;' . $abs_path);
27
            }
28
29
            // require the file
30
            if (file_exists($abs_path)) {
31
                require_once $abs_path;
32
            }
33
        }
34
        return false;
35
    }
36
37
    // register the autoloader
38
    spl_autoload_register("PSFSAutoloader");
39
}
40