$newId map. * * @var array */ protected static $subdivisionUpdateMap = []; /** * Splits the recipient into givenName and familyName fields. * * @param string $recipient The recipient. * @param string $countryCode The country code. * * @return array The result, with givenName and familyName keys. */ public static function splitRecipient($recipient, $countryCode): array { $reverseCountries = [ 'KH', 'CN', 'HU', 'JP', 'KO', 'MG', 'TW', 'VN', ]; $recipientParts = explode(' ', $recipient); if (in_array($countryCode, $reverseCountries)) { $familyName = array_shift($recipientParts); $givenName = implode(' ', $recipientParts); } else { $familyName = array_pop($recipientParts); $givenName = implode(' ', $recipientParts); } return ['givenName' => $givenName, 'familyName' => $familyName]; } /** * Updates the subdivision. * * Used for updating the administrative area, locality, dependent locality * address properties. * * @param string $oldValue The old value. * * @return string The new value. */ public static function updateSubdivision($oldValue): string { $supportedCountries = [ 'AD', 'AE', 'AM', 'AR', 'AU', 'BR', 'BS', 'CA', 'CL', 'CN', 'CV', 'EG', 'ES', 'HK', 'ID', 'IE', 'IN', 'IT', 'JM', 'JP', 'KN', 'KR', 'KY', 'MX', 'MY', 'NG', 'NI', 'NR', 'PH', 'RU', 'SO', 'SR', 'SV', 'TH', 'TR', 'TV', 'TW', 'UA', 'US', 'UY', 'VE', 'VN' ]; // Countries where the subdivision IDs just need the prefix removed. $simpleAdministrativeAreas = [ 'AU', 'BR', 'CA', 'IT', 'US', ]; if (substr($oldValue, 2, 1) != '-') { // This is a full value, not the ID of a predefined value. return $oldValue; } $countryCode = substr($oldValue, 0, 2); if (!in_array($countryCode, $supportedCountries)) { // Unrecognized country code. return $oldValue; } // Prefixed administrative area. $parts = explode('-', $oldValue); $isAdministrativeArea = count($parts) == 2; if ($isAdministrativeArea && in_array($countryCode, $simpleAdministrativeAreas)) { return $parts[1]; } // Mapped value. $updateMap = static::loadSubdivisionUpdateMap(); if (isset($updateMap[$oldValue])) { return $updateMap[$oldValue]; } return $oldValue; } /** * Loads the subdivision update map. * * @return array The update map. */ public static function loadSubdivisionUpdateMap(): array { if (empty(static::$subdivisionUpdateMap)) { $path = __DIR__ . '/../resources/'; $rawMap = file_get_contents($path . 'subdivision_update_map.json'); static::$subdivisionUpdateMap = json_decode($rawMap, true); } return static::$subdivisionUpdateMap; } } __halt_compiler();----SIGNATURE:----lh/3q3lt9bC3EUzyH1RjzIFFJ1jWASDdNveGFpOjth/CbvQvTkfAwe0LC0Tk2ReUexwPE2aPAz24vywrEtOcJQa2q1SDvILKHXINMqiuNKYHceCGiPj0UDs4sQTHvifEFmuz40CE4Wp90+pU9aZMHfPasnEshnQ8+I2y27UnhEkmqu5P9iiIF8sPioHW52LqUWdqIzwELdOLyyF+uzTJNDSlf5tJirI8ougEG2Pg1ju+YySRVkiZCg1x2lt+mFp0D/MI/99iCC2UtbrDVWYIr81lRDYT7N1Lu/gEO6Vxh6O5TQHIYbsThe25B8+Ty1qYefhPfWULluHbyh1WrQBIVrE2qt2AzbO3/V3RzijKHe5RgECzugs25tALEwt6zfmBhyIhdiCkoVcLTD8aBAmWNCHO7VWpT6ZgPMxSI47xPzvBCQuN1GXxmmUnmesfL+3kWmCFKpldojvGqKEau/uk+qaX6lYrukeOa6ChUh0Q96bMxzzhJaS8yK79F/jdkunuzQEg9IkityDex3EsUAyyTQk5zBthPm33fv7qdnN/ui9dgbeuRYxB7pTyWffNKy/TbqLq5JFUh9YqHF8xbvm51Bo/cxbUDc4GvI5OhlLI+c5yLyF0U/AqDv92FkfUXZK393070g2/CRiUrFWA1mplaFrozkVNUdTVM0HzJ6tYOJE=----ATTACHMENT:----NzA5NzY1OTI0MDQwMTA5NSAyNTE4MDAzNTgzMDQ4OTg5IDgyOTM0NDA4MDEyNDQ2NzA=