*/ private array $providers = array(); private AiSettingsRepositoryInterface $settings; public function __construct( AiSettingsRepositoryInterface $settings ) { $this->settings = $settings; } /** * @return AiProviderInterface[] */ public function all(): array { if ( array() === $this->providers ) { $providers = array( new AnthropicProvider( $this->settings ), new OpenAiProvider( $this->settings ), new GeminiProvider( $this->settings ), new OpenRouterProvider( $this->settings ), ); /** * Filters the list of available AI providers. * * @param AiProviderInterface[] $providers */ $providers = (array) apply_filters( 'acez_seo_ai_providers', $providers ); foreach ( $providers as $provider ) { if ( $provider instanceof AiProviderInterface ) { $this->providers[ $provider->get_id() ] = $provider; } } } return $this->providers; } public function get( string $provider_id ): ?AiProviderInterface { return $this->all()[ $provider_id ] ?? null; } public function get_active(): ?AiProviderInterface { return $this->get( $this->settings->get_active_provider() ); } }