mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
76 lines
1.8 KiB
PHP
76 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* Orange Management
|
|
*
|
|
* PHP Version 7.1
|
|
*
|
|
* @category TBD
|
|
* @package TBD
|
|
* @author OMS Development Team <dev@oms.com>
|
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
* @copyright Dennis Eichhorn
|
|
* @license OMS License 1.0
|
|
* @version 1.0.0
|
|
* @link http://orange-management.com
|
|
*/
|
|
declare(strict_types=1);
|
|
|
|
namespace phpOMS;
|
|
|
|
spl_autoload_register('\phpOMS\Autoloader::default_autoloader');
|
|
|
|
/**
|
|
* Autoloader class.
|
|
*
|
|
* @category Framework
|
|
* @package Framework
|
|
* @author OMS Development Team <dev@oms.com>
|
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
* @license OMS License 1.0
|
|
* @link http://orange-management.com
|
|
* @since 1.0.0
|
|
*/
|
|
class Autoloader
|
|
{
|
|
|
|
/**
|
|
* Loading classes by namespace + class name.
|
|
*
|
|
* @param string $class Class path
|
|
*
|
|
* @return void
|
|
*
|
|
* @throws AutoloadException Throws this exception if the class to autoload doesn't exist. This could also be related to a wrong namespace/file path correlation.
|
|
*
|
|
* @since 1.0.0
|
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
*/
|
|
public static function default_autoloader(string $class) /* : void */
|
|
{
|
|
$class = ltrim($class, '\\');
|
|
$class = str_replace(['_', '\\'], '/', $class);
|
|
|
|
/** @noinspection PhpIncludeInspection */
|
|
include_once __DIR__ . '/../' . $class . '.php';
|
|
}
|
|
|
|
/**
|
|
* Check if class exists.
|
|
*
|
|
* @param string $class Class path
|
|
*
|
|
* @return false|string
|
|
*
|
|
* @since 1.0.0
|
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
|
*/
|
|
public static function exists(string $class)
|
|
{
|
|
$class = ltrim($class, '\\');
|
|
$class = str_replace(['_', '\\'], '/', $class);
|
|
|
|
return file_exists(__DIR__ . '/../' . $class . '.php');
|
|
}
|
|
|
|
}
|