Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| ActiveLanguageRegion | |
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 regions registered in the IANA Language Subtag Registry. |
| 10 | * |
| 11 | * Only active language regions can be used. |
| 12 | */ |
| 13 | final class ActiveLanguageRegion implements StringValueObjectInterface, LimitedOptionsInterface |
| 14 | { |
| 15 | use IsLanguageSubtag; |
| 16 | |
| 17 | private static StringSet $activeOptions; |
| 18 | |
| 19 | public static function getOptions(): StringSet |
| 20 | { |
| 21 | if (!isset(static::$activeOptions)) { |
| 22 | static::$activeOptions = new StringSet(array_map('strval', array_keys(static::getActiveData()))); |
| 23 | } |
| 24 | return static::$activeOptions; |
| 25 | } |
| 26 | |
| 27 | protected static function requiresActive(): bool |
| 28 | { |
| 29 | return true; |
| 30 | } |
| 31 | |
| 32 | protected static function getData(): array |
| 33 | { |
| 34 | return require __DIR__ . '/../../fixtures/language-regions.php'; |
| 35 | } |
| 36 | } |