-
Notifications
You must be signed in to change notification settings - Fork 3
/
AutoLoader.php
49 lines (46 loc) · 1.05 KB
/
AutoLoader.php
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
<?php
/**
* PSR-0 compatible class AutoLoader
*
* ATTENTION! Libraries dir must be in includes:
* set_include_path(implode(PATH_SEPARATOR, [$path, get_include_path()]));
*
* @file AutoLoader.php
*
* PHP version 7.1+
*
* @author Alexander Yancharuk <alex at itvault dot info>
* @copyright © 2012-2021 Alexander Yancharuk
* @date Fri Jun 01 10:19:04 2012
* @license The BSD 3-Clause License
* <https://tldrlegal.com/license/bsd-3-clause-license-(revised)>
*/
namespace Veles;
/**
* Class AutoLoader
*
* @author Alexander Yancharuk <alex at itvault dot info>
*/
class AutoLoader
{
/**
* Initialisation
*/
public static function init()
{
spl_autoload_register(__NAMESPACE__ . '\AutoLoader::load');
}
/**
* AutoLoader
*
* @param string $class
*/
public static function load($class)
{
$file = preg_replace('/\\\|_(?!.+\\\)/', DIRECTORY_SEPARATOR, $class) . '.php';
if (false !== ($full_path = stream_resolve_include_path($file))) {
/** @noinspection PhpIncludeInspection */
require $full_path;
}
}
}