Total Complexity | 5 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5 | class Autoloader |
||
6 | { |
||
7 | private $directory; |
||
8 | private $prefix; |
||
9 | private $prefixLength; |
||
10 | |||
11 | /** |
||
12 | * @param string $baseDirectory Base directory where the source files are located. |
||
13 | */ |
||
14 | public function __construct($baseDirectory = __DIR__) |
||
15 | { |
||
16 | $this->directory = $baseDirectory; |
||
17 | $this->prefix = __NAMESPACE__ . '\\'; |
||
18 | $this->prefixLength = strlen($this->prefix); |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * Registers the autoloader class with the PHP SPL autoloader. |
||
23 | * |
||
24 | * @param bool $prepend Prepend the autoloader on the stack instead of appending it. |
||
25 | */ |
||
26 | public static function register($prepend = false) |
||
27 | { |
||
28 | spl_autoload_register(array(new self, 'autoload'), true, $prepend); |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * Loads a class from a file using its fully qualified name. |
||
33 | * |
||
34 | * @param string $className Fully qualified name of a class. |
||
35 | */ |
||
36 | public function autoload($className) |
||
44 | } |
||
45 | } |
||
46 | } |
||
48 |