Download the PHP package blobfolio/blob-phone without Composer
On this page you can find all versions of the php package blobfolio/blob-phone. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download blobfolio/blob-phone
More information about blobfolio/blob-phone
Files in blobfolio/blob-phone
Package blob-phone
Short Description A light(er)weight implementation of Google's amazing libphonenumber for PHP.
License WTFPL
Homepage https://github.com/Blobfolio/blob-phone
Informations about the package blob-phone
blob-phone
blob-phone is a light(er)-weight implementation of Google's amazing libphonenumber for PHP.
Table of Contents
- Features
- Installation
- Use
- Javascript
- License
Features
blob-phone is primarily concerned with validating and formatting arbitrary telephone numbers in international format (e.g. +1 201-555-0123
). Along the way it also manages to gather information about a number's:
- Country
- Continent
- Type (e.g.
mobile
,voip
, etc.)
Other data and formatting features from libphonenumber
have been stripped out to reduce the library's size. For a more comprehensive implementation of libphonenumber
written for PHP, take a look at libphonenumber-for-php.
Installation
The PHP library for blob-phone requires:
- PHP 7.0+
- blobfolio/blob-common
Install with Composer:
Use
Get started
The constructor accepts two arguments:
- (string) Phone number (pre-formatted or not);
- (string) (optional) ISO country code (suspected); Default:
"US"
Providing a probable country of origin will help with identification, so is recommended. Otherwise your number may end up on the wrong side of the planet.
blob-phone uses a brute-force technique to identify and format a phone number, prioritizing tests as follows:
- The country provided;
- Other countries with the same prefix;
- Other countries on the same continent;
- Everywhere else, alphabetically;
Check it
This method accepts an optional array of types of phone numbers in case you are looking for something specific. Type detection is hit or miss, so if you require high accuracy, you should verify this some other way.
The possible types are:
"fixed"
, i.e. landline"mobile"
"pager"
"personal_number"
"premium_rate"
, e.g. your favorite party line"shared_cost"
"toll_free"
"voicemail"
"voip"
, e.g. Google Voice
This method returns TRUE
or FALSE
.
Pull It
All Together Now...
Javascript
blob-phone is also available as a dependency-free Javascript library. To use it, simply include lib/js/blob-phone.min.js
in your project.
This library has a single method: blobPhone.parse()
, which takes two arguments:
- (string) Phone number (pre-formatted or not);
- (string) (optional) ISO country code (suspected); Default:
"US"
Providing a probable country of origin will help with identification, so is recommended. Otherwise your number may end up on the wrong side of the planet.
This will return FALSE
if the number could not be parsed, or an object containing the number details, like:
License
Copyright © 2018 Blobfolio, LLC <[email protected]>
This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <[email protected]>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
Donations
If you have found this work useful and would like to contribute financially, Bitcoin tips are always welcome! 1Af56Nxauv8M1ChyQxtBe1yvdp2jtaB1GF |
All versions of blob-phone with dependencies
ext-filter Version *
ext-dom Version *
ext-mbstring Version *
ext-json Version *
ext-bcmath Version *
ext-hash Version *
blobfolio/blob-common Version *