libphonenumber\PhoneNumberUtil::parsePrefixAsIdd PHP Method

parsePrefixAsIdd() protected method

Strips the IDD from the start of the number if present. Helper function used by maybeStripInternationalPrefixAndNormalize.
protected parsePrefixAsIdd ( string $iddPattern, string &$number ) : boolean
$iddPattern string
$number string
return boolean
    protected function parsePrefixAsIdd($iddPattern, &$number)
    {
        $m = new Matcher($iddPattern, $number);
        if ($m->lookingAt()) {
            $matchEnd = $m->end();
            // Only strip this if the first digit after the match is not a 0, since country calling codes
            // cannot begin with 0.
            $digitMatcher = new Matcher(static::$CAPTURING_DIGIT_PATTERN, substr($number, $matchEnd));
            if ($digitMatcher->find()) {
                $normalizedGroup = static::normalizeDigitsOnly($digitMatcher->group(1));
                if ($normalizedGroup == "0") {
                    return false;
                }
            }
            $number = substr($number, $matchEnd);
            return true;
        }
        return false;
    }
PhoneNumberUtil