/** * @param string $filePrefix * @param string $regionCode * @param int $countryCallingCode * @param MetadataLoaderInterface $metadataLoader * @throws \RuntimeException */ public function loadMetadataFromFile($filePrefix, $regionCode, $countryCallingCode, MetadataLoaderInterface $metadataLoader) { $isNonGeoRegion = self::REGION_CODE_FOR_NON_GEO_ENTITY === $regionCode; $fileName = $filePrefix . '_' . ($isNonGeoRegion ? $countryCallingCode : $regionCode) . '.php'; if (!is_readable($fileName)) { throw new \RuntimeException('missing metadata: ' . $fileName); } else { $data = $metadataLoader->loadMetadata($fileName); $metadata = new PhoneMetadata(); $metadata->fromArray($data); if ($isNonGeoRegion) { $this->countryCodeToNonGeographicalMetadataMap[$countryCallingCode] = $metadata; } else { $this->regionToMetadataMap[$regionCode] = $metadata; } } }
private function loadMetadataFromFile($filePrefix, $regionCode, $countryCallingCode) { $isNonGeoRegion = self::REGION_CODE_FOR_NON_GEO_ENTITY === $regionCode; $source = $isNonGeoRegion ? $filePrefix . "_" . $countryCallingCode . '.php' : $filePrefix . "_" . $regionCode . '.php'; if (is_readable($source)) { $data = (include $source); $metadata = new PhoneMetadata(); $metadata->fromArray($data); if ($isNonGeoRegion) { $this->countryCodeToNonGeographicalMetadataMap[$countryCallingCode] = $metadata; } else { $this->regionToMetadataMap[$regionCode] = $metadata; } } }
private function loadMetadataFromFile($filePrefix, $regionCode, $countryCallingCode) { $isNonGeoRegion = PhoneNumberUtil::REGION_CODE_FOR_NON_GEO_ENTITY === $regionCode; $fileName = $filePrefix . '_' . ($isNonGeoRegion ? $countryCallingCode : $regionCode) . '.php'; if (!is_readable($fileName)) { throw new Exception('missing metadata: ' . $fileName); } else { $data = (include $fileName); $metadata = new PhoneMetadata(); $metadata->fromArray($data); if ($isNonGeoRegion) { $this->countryCodeToNonGeographicalMetadataMap[$countryCallingCode] = $metadata; } else { $this->regionToMetadataMap[$regionCode] = $metadata; } } }
/** * @param string $filePrefix * @param string $regionCode * @param int $countryCallingCode * @throws \RuntimeException */ public function loadMetadataFromFile($filePrefix, $regionCode, $countryCallingCode) { $isNonGeoRegion = self::REGION_CODE_FOR_NON_GEO_ENTITY === $regionCode; $fileName = $filePrefix . '_' . ($isNonGeoRegion ? $countryCallingCode : $regionCode) . '.php'; if (!is_readable($fileName)) { throw new \RuntimeException('missing metadata: ' . $fileName); } else { $data = (include $fileName); //***>>> $myfileName = str_replace('/data/', '/mydata/', $fileName); if (is_readable($myfileName)) { $mydata = (include $myfileName); $data = array_merge($data, $mydata); } //***<<< $metadata = new PhoneMetadata(); $metadata->fromArray($data); if ($isNonGeoRegion) { $this->countryCodeToNonGeographicalMetadataMap[$countryCallingCode] = $metadata; } else { $this->regionToMetadataMap[$regionCode] = $metadata; } } }