<?php
namespace IcreatorCookieConsent;

if (!defined('ABSPATH')) exit;

class Autoloader {
    public static function register(string $prefix, string $baseDir): void {
        spl_autoload_register(function ($class) use ($prefix, $baseDir) {
            if (strpos($class, $prefix . '\\') !== 0) return;
            $rel = substr($class, strlen($prefix) + 1);
            $file = $baseDir . '/' . str_replace('\\', '/', $rel) . '.php';
            // Skip underscore-named classes
            if (strpos(basename($file), '_') === 0) return;
            if (file_exists($file)) require $file;
        });
    }
}