public function format(PhoneNumber $phoneNumber, $format = PhoneNumberFormat::INTERNATIONAL)
    {
        if (true === is_string($format)) {
            $constant = '\libphonenumber\PhoneNumberFormat::' . $format;

            if (false === defined($constant)) {
                throw new InvalidArgumentException('The format must be either a constant value or name in libphonenumber\PhoneNumberFormat');
            }

            $format = constant('\libphonenumber\PhoneNumberFormat::' . $format);
        }

        return $this->phoneNumberUtil->format($phoneNumber, $format);
    }
public function format(PhoneNumber $phoneNumber, $format = PhoneNumberFormat::INTERNATIONAL)
    {
        if (true === is_string($format)) {
            $constant = '\libphonenumber\PhoneNumberFormat::' . $format;

            if (false === defined($constant)) {
                throw new InvalidArgumentException('The format must be either a constant value or name in libphonenumber\PhoneNumberFormat');
            }

            $format = constant('\libphonenumber\PhoneNumberFormat::' . $format);
        }

        return $this->phoneNumberUtil->format($phoneNumber, $format);
    }
public function format ( PhoneNumber $ phoneNumber , $ format = PhoneNumberFormat :: INTERNATIONAL ) { if ( true === is_string ( $ format ) ) { $ constant = '\libphonenumber\PhoneNumberFormat::' . $ format ; if ( false === defined ( $ constant ) ) { throw new InvalidArgumentException ( 'The format must be either a constant value or name in libphonenumber\PhoneNumberFormat' ) ; } $ format = constant ( '\libphonenumber\PhoneNumberFormat::' . $ format ) ; } return $ this -> phoneNumberUtil -> format ( $ phoneNumber , $ format ) ; }
Format a phone number.

@param PhoneNumber $phoneNumber Phone number.
@param int|string  $format      Format, or format constant name.

@return string Formatted phone number.

@throws InvalidArgumentException If an argument is invalid.
Format a phone number .