Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
80.00% |
4 / 5 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| DefaultLabelPropertyTranslator | |
80.00% |
4 / 5 |
|
0.00% |
0 / 1 |
3.07 | |
0.00% |
0 / 1 |
| getGeneralTranslation | |
80.00% |
4 / 5 |
|
0.00% |
0 / 1 |
3.07 | |||
| 1 | <?php |
| 2 | namespace Apie\Core\Translator; |
| 3 | |
| 4 | use Apie\Core\Context\ApieContext; |
| 5 | use Apie\Core\ContextConstants; |
| 6 | use Apie\Core\Translator\Lists\TranslationStringSet; |
| 7 | use Apie\Core\Translator\ValueObjects\AbstractTranslation; |
| 8 | |
| 9 | /** |
| 10 | * Adds default translation for properties |
| 11 | */ |
| 12 | class DefaultLabelPropertyTranslator implements ApieTranslatorInterface |
| 13 | { |
| 14 | public function getGeneralTranslation(ApieContext $context, AbstractTranslation|TranslationStringSet $translations): ?string |
| 15 | { |
| 16 | if ($translations instanceof AbstractTranslation) { |
| 17 | // @phpstan-ignore-next-line argument.count |
| 18 | return $translations->getFallbackText($context->getContext(ContextConstants::ACCEPT_LOCALE, false)); |
| 19 | } |
| 20 | foreach ($translations as $translation) { |
| 21 | // @phpstan-ignore-next-line argument.count |
| 22 | return $translation->getFallbackText($context->getContext(ContextConstants::ACCEPT_LOCALE, false)); |
| 23 | } |
| 24 | return null; |
| 25 | } |
| 26 | } |