<?php

class Edocman_Lite_Autoloader {
    
    public static function register() {
        spl_autoload_register(array(__CLASS__, 'autoload'));
    }
    
    public static function autoload($class) {
        // Check if this is our class
        if (strpos($class, 'Edocman_Lite_') !== 0) {
            return;
        }
        
        // Convert class name to file name
        $class_file = str_replace('_', '-', strtolower($class));
        $class_file = 'class-' . $class_file . '.php';
        
        // Define possible paths
        $paths = array(
            EDOCMAN_LITE_PLUGIN_DIR . 'includes/',
            EDOCMAN_LITE_PLUGIN_DIR . 'admin/',
            EDOCMAN_LITE_PLUGIN_DIR . 'public/',
        );
        
        // Try to load from each path
        foreach ($paths as $path) {
            $file = $path . $class_file;
            if (file_exists($file)) {
                require_once $file;
                return;
            }
        }
    }
}
