src/AsYouTypeFormatter.php
private function ableToExtractLongerNdd()
    {
        if (mb_strlen($this->extractedNationalPrefix) > 0) {
            // Put the extracted NDD back to the national number before attempting to extract a new NDD.
            $this->nationalNumber = $this->extractedNationalPrefix . $this->nationalNumber;
            // Remove the previously extracted NDD from prefixBeforeNationalNumber. We cannot simply set
            // it to empty string because people sometimes incorrectly enter national prefix after the
            // country code, e.g. +44 (0)20-1234-5678.
            $indexOfPreviousNdd = mb_strrpos($this->prefixBeforeNationalNumber, $this->extractedNationalPrefix);
            $this->prefixBeforeNationalNumber = mb_substr(str_pad($this->prefixBeforeNationalNumber, $indexOfPreviousNdd), 0, $indexOfPreviousNdd);
        }
        return ($this->extractedNationalPrefix !== $this->removeNationalPrefixFromNationalNumber());
    }
private function ableToExtractLongerNdd()
    {
        if (mb_strlen($this->extractedNationalPrefix) > 0) {
            // Put the extracted NDD back to the national number before attempting to extract a new NDD.
            $this->nationalNumber = $this->extractedNationalPrefix . $this->nationalNumber;
            // Remove the previously extracted NDD from prefixBeforeNationalNumber. We cannot simply set
            // it to empty string because people sometimes incorrectly enter national prefix after the
            // country code, e.g. +44 (0)20-1234-5678.
            $indexOfPreviousNdd = mb_strrpos($this->prefixBeforeNationalNumber, $this->extractedNationalPrefix);
            $this->prefixBeforeNationalNumber = mb_substr(str_pad($this->prefixBeforeNationalNumber, $indexOfPreviousNdd), 0, $indexOfPreviousNdd);
        }
        return ($this->extractedNationalPrefix !== $this->removeNationalPrefixFromNationalNumber());
    }
private function ableToExtractLongerNdd ( ) { if ( mb_strlen ( $ this -> extractedNationalPrefix ) > 0 ) { // Put the extracted NDD back to the national number before attempting to extract a new NDD. $ this -> nationalNumber = $ this -> extractedNationalPrefix . $ this -> nationalNumber ; // Remove the previously extracted NDD from prefixBeforeNationalNumber. We cannot simply set // it to empty string because people sometimes incorrectly enter national prefix after the // country code, e.g. +44 (0)20-1234-5678. $ indexOfPreviousNdd = mb_strrpos ( $ this -> prefixBeforeNationalNumber , $ this -> extractedNationalPrefix ) ; $ this -> prefixBeforeNationalNumber = mb_substr ( str_pad ( $ this -> prefixBeforeNationalNumber , $ indexOfPreviousNdd ) , 0 , $ indexOfPreviousNdd ) ; } return ( $ this -> extractedNationalPrefix !== $ this -> removeNationalPrefixFromNationalNumber ( ) ) ; }
Some national prefixes are a substring of others. If extracting the shorter NDD doesn't result
in a number we can format, we try to see if we can extract a longer version here.
@return bool
Some national prefixes are a substring of others . If extracting the shorter NDD doesn t result in a number we can format we try to see if we can extract a longer version here .