$providers provider name => provider */ public function __construct( private array $providers, ) { } public function hasProvider(string $name): bool { return isset($this->providers[$name]); } /** * @throws InvalidArgumentException if the provider isn't registered */ public function getProvider(string $name): ProviderInterface { return $this->providers[$name] ?? throw new InvalidArgumentException(sprintf('The "%s" captcha provider isn\'t registered', $name)); } /** * @return array> provider name => its public params */ public function getPublicParams(): array { return array_map(fn(ProviderInterface $provider): array => $provider->getPublicParams(), $this->providers); } }