'recaptcha', 'hcaptcha' => 'hcaptcha', default => 'turnstile', }; } public function isEnabled(): bool { return $this->resolveProvider()->isEnabled(); } public function inputName(): string { $configured = trim((string) config('forum_bot_protection.captcha.input', '')); if ($configured !== '') { return $configured; } return $this->resolveProvider()->inputName(); } public function verify(string $token, ?string $ip = null): bool { return $this->resolveProvider()->verify($token, $ip); } public function frontendConfig(): array { $provider = $this->resolveProvider(); return [ 'provider' => $provider->name(), 'siteKey' => $provider->isEnabled() ? $provider->siteKey() : '', 'inputName' => $this->inputName(), 'scriptUrl' => $provider->isEnabled() ? $provider->scriptUrl() : '', ]; } private function resolveProvider(): CaptchaProviderInterface { return match ($this->provider()) { 'recaptcha' => $this->recaptchaProvider, 'hcaptcha' => $this->hcaptchaProvider, default => $this->turnstileProvider, }; } }