39 lines
724 B
PHP
39 lines
724 B
PHP
<?php
|
|
|
|
/**
|
|
* Loader controller.
|
|
*
|
|
* @author Ivan Filipov <ivan@web-lab.solutions>
|
|
*
|
|
* @version 1.0
|
|
* @date updated Jan 26, 2023
|
|
*/
|
|
|
|
namespace wlsrm;
|
|
|
|
class Loader {
|
|
|
|
private static $defaultNamespace = 'wlsrm';
|
|
|
|
private function __construct() {
|
|
|
|
}
|
|
|
|
public static function registerAutoLoad() {
|
|
spl_autoload_register(array('\wlsrm\Loader', 'autoload'));
|
|
}
|
|
|
|
public static function autoload($class) {
|
|
self::loadClass($class);
|
|
}
|
|
|
|
public static function loadClass($class) {
|
|
$file = realpath(substr_replace(str_replace('\\', DIRECTORY_SEPARATOR, $class), WLSRM_PATH, 0, strlen(self::$defaultNamespace)) . '.php');
|
|
|
|
if ($file && is_readable($file)) {
|
|
include $file;
|
|
}
|
|
}
|
|
|
|
}
|
|
|