<?php
/*
 * Copyright 2014 Florian "Bluewind" Pritz <bluewind@server-speed.net>
 *
 * Licensed under AGPLv3
 * (see COPYING for full license text)
 *
 */

// Original source: http://stackoverflow.com/a/9526005/953022
class CustomAutoloader{
	public function __construct()
	{
		spl_autoload_register(array($this, 'loader'));
	}

	public function loader($className)
	{
		$base_paths = array(
			APPPATH,
			APPPATH."/third_party/mockery/library/",
		);

		foreach ($base_paths as $base_path) {
			$path = $base_path.str_replace('\\', DIRECTORY_SEPARATOR, $className).'.php';
			if (file_exists($path)) {
				require $path;
				return;
			}
		}
	}
}

<?php
/*
 * Copyright 2014 Florian "Bluewind" Pritz <bluewind@server-speed.net>
 *
 * Licensed under AGPLv3
 * (see COPYING for full license text)
 *
 */

// Original source: http://stackoverflow.com/a/9526005/953022
class CustomAutoloader{
	public function __construct()
	{
		spl_autoload_register(array($this, 'loader'));
	}

	public function loader($className)
	{
		$namespaces = array(
			'' => [
				["path" => APPPATH],
				["path" => APPPATH."/third_party/mockery/library/"]
			],
		);

		foreach ($namespaces as $namespace => $search_items) {
			if ($namespace === '' || strpos($className, $namespace) === 0) {
				foreach ($search_items as $search_item) {
					$nameToLoad = str_replace($namespace, '', $className);
					$path = $search_item['path'].str_replace('\\', DIRECTORY_SEPARATOR, $nameToLoad).'.php';
					if (file_exists($path)) {
						require $path;
						return;
					}
				}
			}
		}
	}
}

Support PSR-4 style namespace/directory mapping
Autoloader: Support PSR-4 style namespace/directory mapping

Signed-off-by: Florian Pritz <753f544d2d01592750fb4bd29251b78abcfc8ecd@xinu.at>
