$names The map of region codes to names. * @param array $relationships The map of region codes to their child region codes. * @param array $topLevels A list of top-level region codes. */ public function __construct( private array $names, private array $relationships, private array $topLevels ) { // } public static function createFromBuiltIn(): static { return new self( require __DIR__.'/../resources/names.php', require __DIR__.'/../resources/relationships.php', require __DIR__.'/../resources/top-levels.php' ); } public function getName(int $code): string { return $this->names[$this->groupKey($code)] ?? throw new RegionException('The region code does not exist.'); } /** * @return int[] */ public function getTopLevelNodes(): array { return $this->topLevels; } /** * @return int[] */ public function getNodes(int $code): array { return $this->relationships[$this->groupKey($code)] ?? throw new RegionException('Could not find any nodes under the region code.'); } private function groupKey(int $code): string { return '_'.$code; } }