| Total Complexity | 7 |
| Total Lines | 59 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | final class LocaleId |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Whether a locale ID is available. |
||
| 9 | * |
||
| 10 | * @param string $value |
||
| 11 | * A locale identifier; for example, fr-BE |
||
| 12 | */ |
||
| 13 | public static function is_available(string $value): bool |
||
| 14 | { |
||
| 15 | if (isset(LocaleData::PARENT_LOCALES[$value])) { |
||
| 16 | return true; |
||
| 17 | } |
||
| 18 | |||
| 19 | return in_array($value, LocaleData::AVAILABLE_LOCALES); |
||
| 20 | } |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @param string $value |
||
| 24 | * A locale identifier; for example, fr-BE |
||
| 25 | * |
||
| 26 | * @throws LocaleNotAvailable |
||
| 27 | */ |
||
| 28 | public static function assert_is_available(string $value): void |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Returns a {@see LocaleId} of a value. |
||
| 36 | * |
||
| 37 | * Note: If the locale has a parent locale, that locale is used instead. |
||
| 38 | * |
||
| 39 | * @param string $value |
||
| 40 | * A locale identifier; for example, fr-BE |
||
| 41 | * |
||
| 42 | * @throws LocaleNotAvailable |
||
| 43 | */ |
||
| 44 | public static function of(string $value): self |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @param string $value |
||
| 59 | * A locale identifier; for example, fr-BE. |
||
| 60 | */ |
||
| 61 | private function __construct( |
||
| 66 |