Passed
Push — master ( 6215ec...1255dc )
by Darío
01:47
created

ClassMap   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A autoload() 0 11 3
1
<?php
2
/**
3
 * DronePHP (http://www.dronephp.com)
4
 *
5
 * @link      http://github.com/Pleets/DronePHP
6
 * @copyright Copyright (c) 2016-2018 Pleets. (http://www.pleets.org)
7
 * @license   http://www.dronephp.com/license
8
 * @author    Darío Rivera <[email protected]>
9
 */
10
11
namespace Drone\Loader;
12
13
/**
14
 * AbstractModule class
15
 *
16
 * This class is an autoloader
17
 */
18
class ClassMap
19
{
20
    /**
21
     * The class path
22
     *
23
     * @var string
24
     */
25
    public static $path;
26
27
    /**
28
     * Creates an autoloader for module classes
29
     *
30
     * @param string $name
31
     * @param string $path
32
     *
33
     * @return null
34
     */
35
    public static function autoload($name)
36
    {
37
        $nm = explode('\\', $name);
38
        $module = array_shift($nm);
39
40
        $path = is_null(self::$path) ? '' : self::$path . DIRECTORY_SEPARATOR;
0 ignored issues
show
introduced by
The condition is_null(self::path) is always false.
Loading history...
41
42
        $class = $path . implode(DIRECTORY_SEPARATOR, $nm) . ".php";
43
44
        if (file_exists($class))
45
            include $class;
46
    }
47
}