Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ResourceNameTranslationProvider | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
| provideStringTranslations | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | namespace Apie\Common\Translator; |
| 3 | |
| 4 | use Apie\Core\BoundedContext\BoundedContextHashmap; |
| 5 | use Apie\Core\Context\ApieContext; |
| 6 | use Apie\Core\Translator\Enums\Pluralization; |
| 7 | use Apie\Core\Translator\Lists\TranslationStringSet; |
| 8 | use Apie\Core\Translator\ValueObjects\ResourceName; |
| 9 | use Apie\Core\Translator\ValueObjects\TranslationStringSuffix; |
| 10 | |
| 11 | class ResourceNameTranslationProvider implements TranslationStringProviderInterface |
| 12 | { |
| 13 | public function provideStringTranslations(ApieContext $apieContext): TranslationStringSet |
| 14 | { |
| 15 | $items = []; |
| 16 | $boundedContextHashmap = $apieContext->getContext(BoundedContextHashmap::class, false); |
| 17 | if ($boundedContextHashmap instanceof BoundedContextHashmap) { |
| 18 | foreach ($boundedContextHashmap->getTupleIterator() as $tuple) { |
| 19 | $items[] = ResourceName::createFromTuple($tuple, new TranslationStringSuffix(Pluralization::Singular, false)); |
| 20 | $items[] = ResourceName::createFromTuple($tuple, new TranslationStringSuffix(Pluralization::Singular, true)); |
| 21 | |
| 22 | $items[] = ResourceName::createFromTuple($tuple, new TranslationStringSuffix(Pluralization::Plural, false)); |
| 23 | $items[] = ResourceName::createFromTuple($tuple, new TranslationStringSuffix(Pluralization::Plural, true)); |
| 24 | } |
| 25 | } |
| 26 | return new TranslationStringSet($items); |
| 27 | } |
| 28 | } |