libphonenumber\PhoneNumberUtil::normalizeHelper PHP 메소드

normalizeHelper() 보호된 정적인 메소드

Normalizes a string of characters representing a phone number by replacing all characters found in the accompanying map with the values therein, and stripping all other characters if removeNonMatches is true.
protected static normalizeHelper ( string $number, array $normalizationReplacements, boolean $removeNonMatches ) : string
$number string a string of characters representing a phone number
$normalizationReplacements array a mapping of characters to what they should be replaced by in the normalized version of the phone number
$removeNonMatches boolean indicates whether characters that are not able to be replaced should be stripped from the number. If this is false, they will be left unchanged in the number.
리턴 string the normalized string version of the phone number
    protected static function normalizeHelper($number, array $normalizationReplacements, $removeNonMatches)
    {
        $normalizedNumber = "";
        $strLength = mb_strlen($number, 'UTF-8');
        for ($i = 0; $i < $strLength; $i++) {
            $character = mb_substr($number, $i, 1, 'UTF-8');
            if (isset($normalizationReplacements[mb_strtoupper($character, 'UTF-8')])) {
                $normalizedNumber .= $normalizationReplacements[mb_strtoupper($character, 'UTF-8')];
            } else {
                if (!$removeNonMatches) {
                    $normalizedNumber .= $character;
                }
            }
            // If neither of the above are true, we remove this character.
        }
        return $normalizedNumber;
    }
PhoneNumberUtil