<?php

/**
 * Dozent Pro Class Autoloader
 *
 * @since Dozent Pro 1.0.0
 */

namespace DOZENT_LMS_CERTIFICATE;

class Autoloader {

	/**
	 * Autoload function for registration with spl_autoload_register
	 *
	 * Looks recursively through project directory and loads class files based on
	 * filename match.
	 *
	 * @param  string  $className
	 */

	public static function loader( $className ) {

		if ( ! class_exists( $className ) && strpos( $className, "DOZENT_LMS_CERTIFICATE" ) !== false ) {
			$className = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $className );
			$className = str_replace( 'DOZENT_LMS_CERTIFICATE' . DIRECTORY_SEPARATOR, '', $className );
			$filename = $className . '.php';

			$classes_dir = __DIR__;

			$file_path = $classes_dir . DIRECTORY_SEPARATOR . $filename;
			$namespace_file_path = dirname( __DIR__ ) . DIRECTORY_SEPARATOR . $filename;

			if ( file_exists( $file_path ) ) {
				include_once $file_path;
			} elseif ( file_exists( $namespace_file_path ) ) {
				include_once $namespace_file_path;
			}

		}
	}

}

spl_autoload_register('\DOZENT_LMS_CERTIFICATE\Autoloader::loader');


/**
 * Load Classes
 */

Dozent_LMS_Certificate_Base::instance();