Voodoo\Core\Autoloader::__construct PHP Method

__construct() public method

Intiate the autoload
public __construct ( string $includePath )
$includePath string
    public function __construct($includePath)
    {
        $this->includePath = $includePath;
        spl_autoload_register(function ($className) {
            $className = ltrim($className, '\\');
            $fileName = '';
            $namespace = '';
            if ($lastNsPos = strripos($className, '\\')) {
                $namespace = substr($className, 0, $lastNsPos);
                $className = substr($className, $lastNsPos + 1);
                $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
            }
            $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
            $file = $this->includePath . DIRECTORY_SEPARATOR . $fileName;
            if (file_exists($file)) {
                require_once $file;
            }
        });
    }