/** * Appends the formatted extension of a phone number to formattedNumber, if the phone number had * an extension specified. * * @param PhoneNumber $number * @param PhoneMetadata|null $metadata * @param int $numberFormat PhoneNumberFormat * @param string $formattedNumber */ private function maybeAppendFormattedExtension(PhoneNumber $number, $metadata, $numberFormat, &$formattedNumber) { if ($number->hasExtension() && mb_strlen($number->getExtension()) > 0) { if ($numberFormat === PhoneNumberFormat::RFC3966) { $formattedNumber .= self::RFC3966_EXTN_PREFIX . $number->getExtension(); } else { if (!empty($metadata) && $metadata->hasPreferredExtnPrefix()) { $formattedNumber .= $metadata->getPreferredExtnPrefix() . $number->getExtension(); } else { $formattedNumber .= self::DEFAULT_EXTN_PREFIX . $number->getExtension(); } } } }