src/PhoneNumberUtil.php
public static function setItalianLeadingZerosForPhoneNumber($nationalNumber, PhoneNumber $phoneNumber)
    {
        if (strlen($nationalNumber) > 1 && substr($nationalNumber, 0, 1) == '0') {
            $phoneNumber->setItalianLeadingZero(true);
            $numberOfLeadingZeros = 1;
            // Note that if the national number is all "0"s, the last "0" is not counted as a leading
            // zero.
            while ($numberOfLeadingZeros < (strlen($nationalNumber) - 1) &&
                substr($nationalNumber, $numberOfLeadingZeros, 1) == '0') {
                $numberOfLeadingZeros++;
            }

            if ($numberOfLeadingZeros != 1) {
                $phoneNumber->setNumberOfLeadingZeros($numberOfLeadingZeros);
            }
        }
    }
public static function setItalianLeadingZerosForPhoneNumber($nationalNumber, PhoneNumber $phoneNumber)
    {
        if (strlen($nationalNumber) > 1 && substr($nationalNumber, 0, 1) == '0') {
            $phoneNumber->setItalianLeadingZero(true);
            $numberOfLeadingZeros = 1;
            // Note that if the national number is all "0"s, the last "0" is not counted as a leading
            // zero.
            while ($numberOfLeadingZeros < (strlen($nationalNumber) - 1) &&
                substr($nationalNumber, $numberOfLeadingZeros, 1) == '0') {
                $numberOfLeadingZeros++;
            }

            if ($numberOfLeadingZeros != 1) {
                $phoneNumber->setNumberOfLeadingZeros($numberOfLeadingZeros);
            }
        }
    }
public static function setItalianLeadingZerosForPhoneNumber ( $ nationalNumber , PhoneNumber $ phoneNumber ) { if ( strlen ( $ nationalNumber ) > 1 && substr ( $ nationalNumber , 0 , 1 ) == '0' ) { $ phoneNumber -> setItalianLeadingZero ( true ) ; $ numberOfLeadingZeros = 1 ; // Note that if the national number is all "0"s, the last "0" is not counted as a leading // zero. while ( $ numberOfLeadingZeros < ( strlen ( $ nationalNumber ) - 1 ) && substr ( $ nationalNumber , $ numberOfLeadingZeros , 1 ) == '0' ) { $ numberOfLeadingZeros ++ ; } if ( $ numberOfLeadingZeros != 1 ) { $ phoneNumber -> setNumberOfLeadingZeros ( $ numberOfLeadingZeros ) ; } } }
A helper function to set the values related to leading zeros in a PhoneNumber.
@param string $nationalNumber
@param PhoneNumber $phoneNumber
A helper function to set the values related to leading zeros in a PhoneNumber .