NAME

Number::Phone::BR - Brazilian phone numbers

SYNOPSIS

    # valid phone
    my $phone = Number::Phone::BR->new('(19) 3333-3333');
    say $phone->areaname;   # SP - Região Metropolitana de Campinas
    say $phone->subscriber; # 33333333
    say $phone->is_fixed_line ? "It's fixed!" : "It's mobile!"; # It's fixed

    # invalid phone:
    my $phone = Number::Phone::BR->new('xxx');
    # throws exception: "Not a valid Brazilian phone number: xxx", with stack
    # trace.

DESCRIPTION

This module is based on Number::Phone. It implements most important features defined there.

INCOMPATIBILITIES WITH NUMBER::PHONE

Number::Phone requires the subclass to return undef from the constructor when the number is not valid. We think this is poorly designed, and not compatible with most modern Perl libraries in CPAN today. Additionally, we're using Moo, and we'd have to make ugly hacks to make the constructor behave like that. The same would've happened if we were using Moose. Seems logical to break compatibility on this point, and throw an exception when the number is not valid.

METHODS

country()

The country of the phone: 'BR'.

country_code()

The country code of the phone: 55.

subscriber()

The subscriber part of the phone number.

areacode()

The area code of the phone number (DDD).

areaname()

Gets the name of the region to which the areacode belongs.

is_mobile()

Boolean. Is the phone a mobile phone?

is_valid()

Boolean. Is the phone a valid number?

is_fixed_line()

Boolean. Is the phone a fixed line?

NOT IMPLEMENTED

Number::Phone defines the following methods, which are not implemented in this class:

is_tollfree()

is_network_service()

is_allocated()

is_in_use()

is_geographic()

is_pager()

is_ipphone()

is_isdn()

is_specialrate()

is_adult()

is_international()

is_personal()

is_corporate()

is_government()

SEE ALSO

Number::Phone

AUTHOR

André Walker <andre@andrewalker.net>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by André Walker.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.