forked from idealo/idealo-orders-api-php-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoload.php
29 lines (23 loc) · 904 Bytes
/
autoload.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
<?php
spl_autoload_register(function ($sClass) {
// project-specific namespace prefix
$sPrefix = 'idealo\\Direktkauf\\';
// base directory for the namespace prefix
$sBaseDir = __DIR__.'/idealo/Direktkauf/';
// does the class use the namespace prefix?
$iLength = strlen($sPrefix);
if (strncmp($sPrefix, $sClass, $iLength) !== 0) {
// no, move to the next registered autoloader
return;
}
// get the relative class name
$sRelativeClass = substr($sClass, $iLength);
// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$sFile = $sBaseDir . str_replace('\\', '/', $sRelativeClass) . '.php';
// if the file exists, require it
if (file_exists($sFile)) {
require $sFile;
}
});