<?php
/**
 * Lookup table for available AI providers.
 *
 * @package WPLens
 */

namespace WPLens\AI;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

final class ProviderRegistry {

	/**
	 * @return array<string, Provider>
	 */
	public static function all(): array {
		$providers = array(
			'openai' => new OpenAIProvider(),
		);

		/**
		 * Filter the list of providers.
		 *
		 * @param array<string, Provider> $providers
		 */
		return apply_filters( 'wplens/providers', $providers );
	}

	public static function get( string $slug ): ?Provider {
		$providers = self::all();
		return $providers[ $slug ] ?? null;
	}

	public static function default(): ?Provider {
		$settings = \WPLens\Utils\Options::all();
		$slug     = $settings['scans']['default_provider'] ?? 'openai';
		return self::get( $slug );
	}
}
