szurubooru/src/AutoLoader.php

27 lines
677 B
PHP
Raw Normal View History

<?php
namespace Szurubooru;
final class AutoLoader
{
public static function init()
{
2014-09-09 12:34:57 +02:00
spl_autoload_register([__CLASS__, 'includeClassName']);
}
2014-09-09 12:34:57 +02:00
public static function includeClassName($className)
{
if (strpos($className, 'Szurubooru') === false)
return;
$className = str_replace('\\', DIRECTORY_SEPARATOR, $className);
$className = str_replace('Szurubooru', '', $className);
if (strpos($className, 'Tests') !== false)
$className = dirname(__DIR__) . DIRECTORY_SEPARATOR . str_replace('Tests', 'tests', $className);
else
$className = __DIR__ . DIRECTORY_SEPARATOR . $className;
$className .= '.php';
2014-09-09 12:34:57 +02:00
include($className);
}
}
AutoLoader::init();