Autoloader::register()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * KumbiaPHP web & app Framework.
4
 *
5
 * LICENSE
6
 *
7
 * This source file is subject to the new BSD license that is bundled
8
 * with this package in the file LICENSE.txt.
9
 * It is also available through the world-wide-web at this URL:
10
 * http://wiki.kumbiaphp.com/Licencia
11
 * If you did not receive a copy of the license and are unable to
12
 * obtain it through the world-wide-web, please send an email
13
 * to [email protected] so we can send you a copy immediately.
14
 *
15
 * @category   Kumbia
16
 *
17
 * @copyright  2005 - 2020  Kumbia Team (http://www.kumbiaphp.com)
18
 * @license    http://wiki.kumbiaphp.com/Licencia     New BSD License
19
 */
20
namespace Kumbia\ActiveRecord;
21
22
/**
23
 * Autoload de las clases.
24
 */
25
class Autoloader
26
{
27
    /**
28
     * Registra el autoloader.
29
     *
30
     * @param bool $prepend
31
     */
32
    public static function register($prepend = false)
33
    {
34
        \spl_autoload_register([__CLASS__, 'autoload'], true, $prepend);
35
    }
36
37
    /**
38
     * @param string $className
39
     */
40
    public static function autoload($className)
41
    {
42
        if (0 !== \strpos($className, 'Kumbia\\ActiveRecord')) {
43
            return;
44
        }
45
46
        $fileName = \str_replace('\\', \DIRECTORY_SEPARATOR, \substr($className, 19)).'.php';
47
        require __DIR__.$fileName;
48
    }
49
}
50