blob: e3884d935b7afe7f017da82d9a8d9c37e28b0bfe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
<?php
/**
* Part of bdrem
*
* PHP version 5
*
* @category Tools
* @package Bdrem
* @author Christian Weiske <cweiske@cweiske.de>
* @copyright 2014 Christian Weiske
* @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
* @link http://cweiske.de/bdrem.htm
*/
namespace bdrem;
/**
* Class autoloader, PSR-0 compliant.
*
* @category Tools
* @package Bdrem
* @author Christian Weiske <cweiske@cweiske.de>
* @copyright 2014 Christian Weiske
* @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3
* @version Release: @package_version@
* @link http://cweiske.de/bdrem.htm
*/
class Autoloader
{
/**
* Load the given class
*
* @param string $class Class name
*
* @return void
*/
public function load($class)
{
$file = strtr($class, '_\\', '//') . '.php';
if (stream_resolve_include_path($file)) {
include $file;
}
}
/**
* Register this autoloader
*
* @return void
*/
public static function register()
{
set_include_path(
get_include_path() . PATH_SEPARATOR . __DIR__ . '/../'
);
spl_autoload_register(array(new self(), 'load'));
if (file_exists(__DIR__ . '/../../vendor/autoload.php')) {
require_once __DIR__ . '/../../vendor/autoload.php';
}
}
}
?>
|