PasswordLoginService::class ]; /** * @param ContainerInterface $container */ public function __construct( private readonly ContainerInterface $container ) {} /** * @param string $type * @return PasswordLoginService * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public function get(string $type): PasswordLoginService { $handlerClass = self::HANDLER_MAP[$type] ?? null; return match (true) { $handlerClass !== null => $this->container->get($handlerClass), default => throw new ErrException('类不存在') }; } }