writeMetadataToFile($metadataCollection, $savePath); $countryCodeToRegionCodeMap = BuildMetadataFromXml::buildCountryCodeToRegionCodeMap($metadataCollection); // Sort $countryCodeToRegionCodeMap just to have the regions in order ksort($countryCodeToRegionCodeMap); $this->writeCountryCallingCodeMappingToFile($countryCodeToRegionCodeMap, $mappingClassLocation, $mappingClass); } /** * @param $metadataCollection PhoneMetadata[] * @param $filePrefix */ private function writeMetadataToFile($metadataCollection, $filePrefix) { foreach ($metadataCollection as $metadata) { /** @var $phoneMetadata PhoneMetadata */ $regionCode = $metadata->getId(); // For non-geographical country calling codes (e.g. +800), use the country calling codes // instead of the region code to form the file name. if ($regionCode === '001' || $regionCode == '') { $regionCode = $metadata->getCountryCode(); } $data = 'toArray(), true ) . ';' . PHP_EOL; file_put_contents($filePrefix . "_" . $regionCode . '.php', $data); } } private function writeCountryCallingCodeMappingToFile($countryCodeToRegionCodeMap, $outputDir, $mappingClass) { // Find out whether the countryCodeToRegionCodeMap has any region codes or country // calling codes listed in it. $hasRegionCodes = false; foreach ($countryCodeToRegionCodeMap as $key => $listWithRegionCode) { if (count($listWithRegionCode) > 0) { $hasRegionCodes = true; break; } } $hasCountryCodes = (count($countryCodeToRegionCodeMap) > 1); $variableName = lcfirst($mappingClass); $data = '