Skip to content

Extension points

phil/phone

The library is plain PHP: it declares no service and no port, and its classes are final. What an application chooses goes through arguments.

PointHow
The country of a number typed without its prefixThe $region argument of PhoneNumber::parse(): the visitor's country, the shop's, or none to require a +
Which numbers are acceptedisValid(), type() and region() give what a number is; the application decides which types and countries it takes
How a number is writtenformat() with a PhoneFormat: E.164 to store, international or national to show, tel: to link
The numbering plansThe PHP data in data/, imported from a release of libphonenumber by Metadata\MetadataImporter through bin/import-metadata.php; a newer release is imported, never edited by hand — see Metadata
Catching the library's errorsEvery exception implements Phil\Phone\Exception\PhoneException: one catch covers InvalidPhoneNumber and InvalidMetadata

Carriers, short numbers and example numbers are not read: an application that needs them looks them up elsewhere from the E.164 form.