includes/Tools/Posts/Posts_Create_Tool.php). * * @package GripMCP */ declare( strict_types=1 ); namespace GripMCP; defined( 'ABSPATH' ) || exit; final class Autoloader { private const PREFIX = 'GripMCP\\'; private const BASEDIR = 'includes/'; /** * Register the autoloader with the SPL stack. */ public static function register(): void { spl_autoload_register( array( __CLASS__, 'autoload' ) ); } /** * Resolve a fully-qualified class name to a file and require it. * * @param string $class Fully-qualified class name. */ public static function autoload( string $class ): void { if ( 0 !== strncmp( $class, self::PREFIX, strlen( self::PREFIX ) ) ) { return; } $relative = substr( $class, strlen( self::PREFIX ) ); $path = GRIPMCP_DIR . self::BASEDIR . str_replace( '\\', '/', $relative ) . '.php'; if ( is_readable( $path ) ) { require $path; } } }