<?php
namespace TeknoTok\AiTranslator\Providers;

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

/**
 * Factory class to instantiate AI translation providers.
 */
class ProviderFactory {
	/**
	 * Build active provider instance.
	 *
	 * @return ProviderInterface
	 * @throws \Exception
	 */
	public static function get_provider() {
		$settings = get_option( 'teknotok_ait_settings', array() );
		$provider = $settings['api_provider'] ?? 'teknotok';

		switch ( $provider ) {
			case 'teknotok':
			case 'openai':
				return new TeknoTokProvider();
			default:
				throw new \Exception( sprintf( __( 'Unsupported AI provider: %s', 'teknotok-ai-translator-pro' ), $provider ) );
		}
	}
}
