<?php

/**
 * PSR-4 style autoloader for the BulkAltText namespace.
 *
 * @package BulkAltText
 */

declare(strict_types=1);

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

spl_autoload_register(static function (string $class): void {
    $prefix  = 'BulkAltText\\';
    $baseDir = __DIR__ . '/';
    $len     = strlen($prefix);

    if (strncmp($class, $prefix, $len) !== 0) {
        return;
    }

    $relative = substr($class, $len);
    $file     = $baseDir . str_replace('\\', '/', $relative) . '.php';

    if (is_readable($file)) {
        require $file;
    }
});
