Completed
Push — master ( 229d9d...1c9390 )
by Alberto
01:52
created

Autoloader::autoload()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 1 Features 0
Metric Value
c 4
b 1
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 5
nc 2
nop 1
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 - 2016  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
    private static $folder;
28
29
    /**
30
     * Registra el autoloader.
31
     *
32
     * @param bool $prepend
33
     */
34
    public static function register($prepend = false)
35
    {
36
        spl_autoload_register([__CLASS__, 'autoload'], true, $prepend);
37
        self::$folder = dirname(dirname(__DIR__)).'/';
38
    }
39
40
    /**
41
     * @param string $className
42
     */
43
    public static function autoload($className)
44
    {
45
        if (0 !== strpos($className, 'Kumbia\\ActiveRecord')) {
46
            return;
47
        }
48
49
        $fileName = str_replace(['_', '\\'], DIRECTORY_SEPARATOR, $className).'.php';
50
        require self::$folder.$fileName;
51
    }
52
}
53