<?php

/**
 * @author Vas Fedorov
 * @copyright 11-2010
 */
 


class Autoloader
{
 
    static public function register()
    {
        ini_set('unserialize_callback_func', 'spl_autoload_call');
        spl_autoload_register(array(new self, 'autoload'));
    }

    /**
     * Handles autoloading of classes.
     *
     * @param  string  $class  A class name.
     *
     * @return boolean Returns true if the class has been loaded
     */
    static public function autoload($class)
    {

        if (class_exists($class, FALSE))
		{
			return;
		}
       
        if (dirname($file) == '' or 0 !== strpos($file, 'HaloMVC'))
		{
			return;
		}
        $file = $class.'.class.php';
		if (!file_exists($file))
		{
			eval('class ' . $class . '{}');
			throw new Exception('File ' . $file . ' not found.');
		}  
		unset($file);
		if (!class_exists($class, FALSE))
		{
			eval('class ' . $class . '{}');
			throw new ClassNotFoundException('Class ' . $class . ' not found.');
		}
    }
}

?>