Number::Phone::NANP - NANP-specific methods for Number::Phone
This is a base class which encapsulates that information about phone numbers in the North American Numbering Plan (NANP) which are common to all NANP countries - that is, those whose international dialling code is +1.
Country-specific modules should inherit from this module and provide their own versions of methods as necessary.
they should not provide an
is_valid method or a constructor.
This module should not be used directly. It will be loaded as necessary by Number::Phone:
use Number::Phone; my $phone_number = Number::Phone->new('+1 202 418 1440'); # $phone_number is now a Number::Phone::NANP::US my $other_phone_number = Number::Phone->new('+1 866 623 2282'); # $phone_number is non-geographic so is a Number::Phone::NANP
The following methods from Number::Phone are overridden:
The constructor, you should never have to call this yourself. To create an object the canonical incantation is
The number is valid within the numbering scheme. It may or may not yet be allocated, or it may be reserved.
NANP-globals like 1-800 aren't geographic, the rest are.
NANP-globals like 1-800 aren't mobile. For most others we just don't know because the data isn't published. libphonenumber has data for *some* countries, so we use that if we can.
NANP-globals are fixed lines, for the rest we generally don't know with some exceptions as per is_mobile above.
The number is a '555' number. Numbers with the D, E, and F digits set to 555 are not allocated to real customers, and are intended for use in fiction. eg 212 555 2368 for Ghostbusters.
NB, despite Ghostbusters above, only 555-0100 to 555-0199 are actually reserved.
The number is free to the caller. 800, 844, 855, 866, 877 and 888 "area codes"
The number is charged at a higher rate than normal. The 900 "area code".
The number is a "personal" number. The 500, 533, 544, 566 and 577 "area codes".
Returns informational text relevant to the whole NANP. Note that when this method is inherited by a subclass it returns undef meaning "not known", but returns information about the NANPA when called on an object of class Number::Phone::NANP.
Return the area code for the number.
Return the name for the area code, if applicable, otherwise returns undef. For instance, for a number beginning with +1 201 200 it would return "Jersey City, NJ".
Return the subscriber part of the number.
Return a sanely formatted version of the number, complete with IDD code.
Please report bugs at https://github.com/DrHyde/perl-modules-Number-Phone/issues, including, if possible, a test case.
I welcome feedback from users.
You may use, modify and distribute this software under the same terms as perl itself.
David Cantrell <email@example.com>