Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| ActiveLanguageVariant | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
4 | |
100.00% |
1 / 1 |
| getOptions | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| requiresActive | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getData | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\IanaValueObjects\LanguageTag; |
| 3 | |
| 4 | use Apie\Core\Lists\StringSet; |
| 5 | use Apie\Core\ValueObjects\Interfaces\LimitedOptionsInterface; |
| 6 | use Apie\Core\ValueObjects\Interfaces\StringValueObjectInterface; |
| 7 | |
| 8 | /** |
| 9 | * All language variants registered in the IANA Language Subtag Registry. |
| 10 | * |
| 11 | * @see https://www.iana.org/assignments/language-subtag-registry |
| 12 | * |
| 13 | * Only active language variants can be used. |
| 14 | */ |
| 15 | final class ActiveLanguageVariant implements StringValueObjectInterface, LimitedOptionsInterface |
| 16 | { |
| 17 | use IsLanguageSubtag; |
| 18 | |
| 19 | private static StringSet $activeOptions; |
| 20 | |
| 21 | public static function getOptions(): StringSet |
| 22 | { |
| 23 | if (!isset(static::$activeOptions)) { |
| 24 | static::$activeOptions = new StringSet(array_map('strval', array_keys(static::getActiveData()))); |
| 25 | } |
| 26 | return static::$activeOptions; |
| 27 | } |
| 28 | |
| 29 | protected static function requiresActive(): bool |
| 30 | { |
| 31 | return true; |
| 32 | } |
| 33 | |
| 34 | protected static function getData(): array |
| 35 | { |
| 36 | return require __DIR__ . '/../../fixtures/language-variants.php'; |
| 37 | } |
| 38 | } |