<?php
	namespace sven\sys;
	/**
	 * Autoloader
	 *
	 * A simple autoloader that loads class files recursively starting in the directory
	 * where this class resides.
	 *
	 * @todo lel
	 * @package sven\sys
	 * @copyright 2018 Ruben Meyer
	 * @author Ruben Meyer <contact@rxbn.de>
	 * @version 0.1.0
	 * @see http://php.net/manual/en/language.oop5.autoload.php	<Documentation>
	 *
	 */
	class Autoloader {
		public static function register() {
			spl_autoload_register(
				function($class) {
					$file = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $class).'.class.php';
					if(substr($file, 0, 5) == 'sven\\') $file = substr($file, 5);

					if(!class_exists($class) && file_exists($file)) {
						require $file;
						return true;
					}

					return false;
				}
			);
		}
	}

	Autoloader::register();
?>
