src/PhoneNumberMatcher.php
protected static function getNationalNumberGroups(
        PhoneNumberUtil $util,
        PhoneNumber $number,
        NumberFormat $formattingPattern = null
    ) {
        if ($formattingPattern === null) {
            // This will be in the format +CC-DG;ext=EXT where DG represents groups of digits.
            $rfc3966Format = $util->format($number, PhoneNumberFormat::RFC3966);
            // We remove the extension part from the formatted string before splitting it into different
            // groups.
            $endIndex = mb_strpos($rfc3966Format, ';');
            if ($endIndex === false) {
                $endIndex = mb_strlen($rfc3966Format);
            }

            // The country-code will have a '-' following it.
            $startIndex = mb_strpos($rfc3966Format, '-') + 1;
            return explode('-', mb_substr($rfc3966Format, $startIndex, $endIndex - $startIndex));
        }

        // If a format is provided, we format the NSN only, and split that according to the separator.
        $nationalSignificantNumber = $util->getNationalSignificantNumber($number);
        return explode('-', $util->formatNsnUsingPattern($nationalSignificantNumber, $formattingPattern,
            PhoneNumberFormat::RFC3966));
    }
protected static function getNationalNumberGroups(
        PhoneNumberUtil $util,
        PhoneNumber $number,
        NumberFormat $formattingPattern = null
    ) {
        if ($formattingPattern === null) {
            // This will be in the format +CC-DG;ext=EXT where DG represents groups of digits.
            $rfc3966Format = $util->format($number, PhoneNumberFormat::RFC3966);
            // We remove the extension part from the formatted string before splitting it into different
            // groups.
            $endIndex = mb_strpos($rfc3966Format, ';');
            if ($endIndex === false) {
                $endIndex = mb_strlen($rfc3966Format);
            }

            // The country-code will have a '-' following it.
            $startIndex = mb_strpos($rfc3966Format, '-') + 1;
            return explode('-', mb_substr($rfc3966Format, $startIndex, $endIndex - $startIndex));
        }

        // If a format is provided, we format the NSN only, and split that according to the separator.
        $nationalSignificantNumber = $util->getNationalSignificantNumber($number);
        return explode('-', $util->formatNsnUsingPattern($nationalSignificantNumber, $formattingPattern,
            PhoneNumberFormat::RFC3966));
    }
protected static function getNationalNumberGroups ( PhoneNumberUtil $ util , PhoneNumber $ number , NumberFormat $ formattingPattern = null ) { if ( $ formattingPattern === null ) { // This will be in the format +CC-DG;ext=EXT where DG represents groups of digits. $ rfc3966Format = $ util -> format ( $ number , PhoneNumberFormat :: RFC3966 ) ; // We remove the extension part from the formatted string before splitting it into different // groups. $ endIndex = mb_strpos ( $ rfc3966Format , ';' ) ; if ( $ endIndex === false ) { $ endIndex = mb_strlen ( $ rfc3966Format ) ; } // The country-code will have a '-' following it. $ startIndex = mb_strpos ( $ rfc3966Format , '-' ) + 1 ; return explode ( '-' , mb_substr ( $ rfc3966Format , $ startIndex , $ endIndex - $ startIndex ) ) ; } // If a format is provided, we format the NSN only, and split that according to the separator. $ nationalSignificantNumber = $ util -> getNationalSignificantNumber ( $ number ) ; return explode ( '-' , $ util -> formatNsnUsingPattern ( $ nationalSignificantNumber , $ formattingPattern , PhoneNumberFormat :: RFC3966 ) ) ; }
Helper method to get the national-number part of a number, formatted without any national
prefix, and return it as a set of digit blocks that would be formatted together.

@param PhoneNumberUtil $util
@param PhoneNumber $number
@param NumberFormat $formattingPattern
@return string[]
Helper method to get the national - number part of a number formatted without any national prefix and return it as a set of digit blocks that would be formatted together .