src/AsYouTypeFormatter.php
private function removeNationalPrefixFromNationalNumber()
    {
        $startOfNationalNumber = 0;
        if ($this->isNanpaNumberWithNationalPrefix()) {
            $startOfNationalNumber = 1;
            $this->prefixBeforeNationalNumber .= '1' . self::$seperatorBeforeNationalNumber;
            $this->isCompleteNumber = true;
        } elseif ($this->currentMetadata->hasNationalPrefixForParsing()) {
            $m = new Matcher($this->currentMetadata->getNationalPrefixForParsing(), $this->nationalNumber);
            // Since some national prefix patterns are entirely optional, check that a national prefix
            // could actually be extracted.
            if ($m->lookingAt() && $m->end() > 0) {
                // When the national prefix is detected, we use international formatting rules instead of
                // national ones, because national formatting rules could contain local formatting rules
                // for numbers entered without area code.
                $this->isCompleteNumber = true;
                $startOfNationalNumber = $m->end();
                $this->prefixBeforeNationalNumber .= mb_substr($this->nationalNumber, 0, $startOfNationalNumber);
            }
        }
        $nationalPrefix = mb_substr($this->nationalNumber, 0, $startOfNationalNumber);
        $this->nationalNumber = mb_substr($this->nationalNumber, $startOfNationalNumber);
        return $nationalPrefix;
    }
private function removeNationalPrefixFromNationalNumber()
    {
        $startOfNationalNumber = 0;
        if ($this->isNanpaNumberWithNationalPrefix()) {
            $startOfNationalNumber = 1;
            $this->prefixBeforeNationalNumber .= '1' . self::$seperatorBeforeNationalNumber;
            $this->isCompleteNumber = true;
        } elseif ($this->currentMetadata->hasNationalPrefixForParsing()) {
            $m = new Matcher($this->currentMetadata->getNationalPrefixForParsing(), $this->nationalNumber);
            // Since some national prefix patterns are entirely optional, check that a national prefix
            // could actually be extracted.
            if ($m->lookingAt() && $m->end() > 0) {
                // When the national prefix is detected, we use international formatting rules instead of
                // national ones, because national formatting rules could contain local formatting rules
                // for numbers entered without area code.
                $this->isCompleteNumber = true;
                $startOfNationalNumber = $m->end();
                $this->prefixBeforeNationalNumber .= mb_substr($this->nationalNumber, 0, $startOfNationalNumber);
            }
        }
        $nationalPrefix = mb_substr($this->nationalNumber, 0, $startOfNationalNumber);
        $this->nationalNumber = mb_substr($this->nationalNumber, $startOfNationalNumber);
        return $nationalPrefix;
    }
private function removeNationalPrefixFromNationalNumber ( ) { $ startOfNationalNumber = 0 ; if ( $ this -> isNanpaNumberWithNationalPrefix ( ) ) { $ startOfNationalNumber = 1 ; $ this -> prefixBeforeNationalNumber .= '1' . self :: $ seperatorBeforeNationalNumber ; $ this -> isCompleteNumber = true ; } elseif ( $ this -> currentMetadata -> hasNationalPrefixForParsing ( ) ) { $ m = new Matcher ( $ this -> currentMetadata -> getNationalPrefixForParsing ( ) , $ this -> nationalNumber ) ; // Since some national prefix patterns are entirely optional, check that a national prefix // could actually be extracted. if ( $ m -> lookingAt ( ) && $ m -> end ( ) > 0 ) { // When the national prefix is detected, we use international formatting rules instead of // national ones, because national formatting rules could contain local formatting rules // for numbers entered without area code. $ this -> isCompleteNumber = true ; $ startOfNationalNumber = $ m -> end ( ) ; $ this -> prefixBeforeNationalNumber .= mb_substr ( $ this -> nationalNumber , 0 , $ startOfNationalNumber ) ; } } $ nationalPrefix = mb_substr ( $ this -> nationalNumber , 0 , $ startOfNationalNumber ) ; $ this -> nationalNumber = mb_substr ( $ this -> nationalNumber , $ startOfNationalNumber ) ; return $ nationalPrefix ; }
Returns the national prefix extracted, or an empty string if it is not present.
@return string
Returns the national prefix extracted or an empty string if it is not present .