<?php
/**
 * PSR-4 autoloader (no Composer needed in production).
 *
 * @package Vist360
 */

namespace Vist360\Core;

defined( 'ABSPATH' ) || exit;

/**
 * Maps the Vist360\ namespace to the src/ directory.
 */
class Autoloader {

	/**
	 * Register the autoloader.
	 */
	public static function register() {
		spl_autoload_register(
			function ( $class_name ) {
				if ( 0 !== strpos( $class_name, 'Vist360\\' ) ) {
					return;
				}

				$relative = substr( $class_name, strlen( 'Vist360\\' ) );
				$path     = VIST360_DIR . 'src/' . str_replace( '\\', '/', $relative ) . '.php';

				if ( is_readable( $path ) ) {
					require_once $path;
				}
			}
		);
	}
}
