<?php
/**
 * PSR-4 Autoloader for the NeurogenesisTheme namespace.
 */
if(!function_exists('neurogenesis_theme_autoload')) {
    function neurogenesis_theme_autoload($class) {
        // project-specific namespace prefix
        $prefix = 'NeurogenesisTheme\\';

        // base directory for the namespace prefix
        $base_dir = NEUROGENESIS_THEME_PATH . '/';

        // get the relative class name
        $relative_class = substr($class, strlen($prefix));

        // replace the namespace prefix with the base directory, replace namespace
        // separators with directory separators in the relative class name, append .php
        $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';

        // if the file exists, require it
        if (file_exists($file)) {
            require $file;
        }
    }
}
spl_autoload_register('neurogenesis_theme_autoload');