diff --git a/generator/src/Command/GenerateLocaleId.php b/generator/src/Command/GenerateLocaleId.php index 9057839..3795520 100644 --- a/generator/src/Command/GenerateLocaleId.php +++ b/generator/src/Command/GenerateLocaleId.php @@ -56,8 +56,6 @@ public function render( namespace ICanBoogie\CLDR; - use InvalidArgumentException; - final class LocaleId { /** diff --git a/lib/GitHub/UrlResolver.php b/lib/GitHub/UrlResolver.php index 5e378b8..8f99a01 100644 --- a/lib/GitHub/UrlResolver.php +++ b/lib/GitHub/UrlResolver.php @@ -12,9 +12,8 @@ class UrlResolver { public const DEFAULT_ORIGIN = "https://raw.githubusercontent.com/unicode-org/cldr-json/"; public const DEFAULT_VERSION = "45.0.0"; - public const DEFAULT_VARIATION = self::VARIATION_MODERN; + public const DEFAULT_VARIATION = self::VARIATION_FULL; - public const VARIATION_MODERN = 'modern'; public const VARIATION_FULL = 'full'; /** diff --git a/lib/LocaleId.php b/lib/LocaleId.php index f9b9c52..b6669e5 100644 --- a/lib/LocaleId.php +++ b/lib/LocaleId.php @@ -8,12 +8,13 @@ namespace ICanBoogie\CLDR; -use InvalidArgumentException; - final class LocaleId { /** * Whether a locale ID is available. + * + * @param string $value + * A locale identifier; for example, fr-BE */ public static function is_available(string $value): bool { @@ -25,6 +26,9 @@ public static function is_available(string $value): bool } /** + * @param string $value + * A locale identifier; for example, fr-BE + * * @throws LocaleNotAvailable */ public static function assert_is_available(string $value): void @@ -33,31 +37,27 @@ public static function assert_is_available(string $value): void or throw new LocaleNotAvailable($value); } - /** - * @var array - * Where _key_ is a locale identifier. - */ - private static array $instances = []; - /** * Returns a {@see LocaleId} of a value. * * Note: If the locale has a parent locale, that locale is used instead. * * @param string $value - * A locale identifier. + * A locale identifier; for example, fr-BE * - * @throws InvalidArgumentException if the locale is not available. + * @throws LocaleNotAvailable */ public static function of(string $value): self { + static $instances; + self::assert_is_available($value); if (isset(self::PARENT_LOCALES[$value])) { $value = self::PARENT_LOCALES[$value]; } - return self::$instances[$value] ??= new self($value); + return $instances[$value] ??= new self($value); } private function __construct( diff --git a/tests/GitHub/UrlResolverTest.php b/tests/GitHub/UrlResolverTest.php index 36197c6..817a69e 100644 --- a/tests/GitHub/UrlResolverTest.php +++ b/tests/GitHub/UrlResolverTest.php @@ -24,12 +24,12 @@ public static function provide_resolve(): array "annotations-derived/{locale}/annotations" => [ "annotations-derived/fr-CA/annotations", - "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-annotations-derived-modern/annotationsDerived/fr-CA/annotations.json" + "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-annotations-derived-full/annotationsDerived/fr-CA/annotations.json" ], "annotations/{locale}/annotations" => [ "annotations/hi-Latn/annotations", - "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-annotations-modern/annotations/hi-Latn/annotations.json" + "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-annotations-full/annotations/hi-Latn/annotations.json" ], "bcp47/calendar" => [ @@ -44,7 +44,7 @@ public static function provide_resolve(): array "cal-buddhist/{locale}/ca-buddhist" => [ "cal-buddhist/de-BE/ca-buddhist", - "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-cal-buddhist-modern/main/de-BE/ca-buddhist.json" + "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-cal-buddhist-full/main/de-BE/ca-buddhist.json" ], "core/supplemental/plurals" => [ @@ -64,32 +64,32 @@ public static function provide_resolve(): array "dates/{locale}/ca-gregorian" => [ "dates/ko-KP/ca-gregorian", - "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-dates-modern/main/ko-KP/ca-gregorian.json" + "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-dates-full/main/ko-KP/ca-gregorian.json" ], "dates/{locale}/dateFields" => [ "dates/ko-KP/dateFields", - "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-dates-modern/main/ko-KP/dateFields.json" + "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-dates-full/main/ko-KP/dateFields.json" ], "localnames/{locale}/languages" => [ "localenames/fr-MA/languages", - "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-localenames-modern/main/fr-MA/languages.json" + "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-localenames-full/main/fr-MA/languages.json" ], "misc/{locale}/listPatterns" => [ "misc/ms-SG/listPatterns", - "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-misc-modern/main/ms-SG/listPatterns.json" + "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-misc-full/main/ms-SG/listPatterns.json" ], "numbers/{locale}/currencies" => [ "numbers/en-150/currencies", - "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-numbers-modern/main/en-150/currencies.json" + "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-numbers-full/main/en-150/currencies.json" ], "numbers/{locale}/numbers" => [ "numbers/en-150/numbers", - "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-numbers-modern/main/en-150/numbers.json" + "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-numbers-full/main/en-150/numbers.json" ], "rbnf/{language}" => [ @@ -99,12 +99,12 @@ public static function provide_resolve(): array "segments/{language}/suppressions" => [ "segments/de/suppressions", - "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-segments-modern/segments/de/suppressions.json" + "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-segments-full/segments/de/suppressions.json" ], "units/{locale}/units" => [ "units/pt-MO/units", - "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-units-modern/main/pt-MO/units.json" + "https://raw.githubusercontent.com/unicode-org/cldr-json/$v/cldr-json/cldr-units-full/main/pt-MO/units.json" ], ];