> */ protected static array $mappers = []; /** * Register mapper with type-safe using enum ApiType */ public static function register(ApiType $type, string $mapperClass): void { static::$mappers[$type->value] = $mapperClass; } /** * @param ApiType $type * @throws InvalidArgumentException * @return DataPayloadMapper */ public static function resolve(ApiType $type): DataPayloadMapper { $mapperClass = static::$mappers[$type->value] ?? null; if (! $mapperClass || ! class_exists($mapperClass)) { throw new InvalidArgumentException("No DataMapper registered for ApiType: {$type->value}"); } return app($mapperClass); } }