Lines
100.00%
8 / 8
Methods
100.00%
1 / 1
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| create | 100.00% | 8 / 8 | 100.00% | 1 / 1 | 7 | ||
| 35 | class TranslationProviderFactory | |
| 36 | { | |
| 37 | /** | |
| 38 | * Create a translation provider instance. | |
| 39 | * | |
| 40 | * @param Configuration $configuration phpMyFAQ configuration | |
| 41 | * @param HttpClientInterface $httpClient HTTP client for API requests | |
| 42 | * @return TranslationProviderInterface|null Provider instance or null if none configured | |
| 43 | */ | |
| 44 | public static function create( | |
| 45 | Configuration $configuration, | |
| 46 | HttpClientInterface $httpClient, | |
| 47 | ): ?TranslationProviderInterface { | |
| 48 | $provider = $configuration->get('translation.provider'); | |
| 49 | ||
| 50 | return match ($provider) { | |
| 51 | 'google' => new GoogleTranslationProvider($configuration, $httpClient), | |
| 52 | 'deepl' => new DeepLTranslationProvider($configuration, $httpClient), | |
| 53 | 'azure' => new AzureTranslationProvider($configuration, $httpClient), | |
| 54 | 'amazon' => new AmazonTranslationProvider($configuration, $httpClient), | |
| 55 | 'libretranslate' => new LibreTranslationProvider($configuration, $httpClient), | |
| 56 | default => null, | |
| 57 | }; | |
| 58 | } | |
| 59 | } |