# automatically generated file, don't edit



# Copyright 2011 David Cantrell, derived from data from libphonenumber
# http://code.google.com/p/libphonenumber/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
package Number::Phone::StubCountry::BR;
use base qw(Number::Phone::StubCountry);

use strict;
use warnings;
use utf8;
our $VERSION = 1.20160304153310;

my $formatters = [
                {
                  'pattern' => '(\\d{4})(\\d{4})',
                  'leading_digits' => '
            [2-9](?:
              [1-9]|
              0[1-9]
            )
          '
                },
                {
                  'leading_digits' => '
            9(?:
              [1-9]|
              0[1-9]
            )
          ',
                  'pattern' => '(\\d{5})(\\d{4})'
                },
                {
                  'pattern' => '(\\d{3,5})',
                  'leading_digits' => '1[125689]'
                },
                {
                  'pattern' => '(\\d{2})(\\d{5})(\\d{4})',
                  'leading_digits' => '
            (?:
              [189][1-9]|
              2[12478]|
              3[1-578]|
              7[13-579]
            )9
          '
                },
                {
                  'leading_digits' => '[1-9][1-9]',
                  'pattern' => '(\\d{2})(\\d{4})(\\d{4})'
                },
                {
                  'pattern' => '(\\d{4})(\\d{4})',
                  'leading_digits' => '
            (?:
             300|
             40(?:
                0|
                20
             )
            )
          '
                },
                {
                  'pattern' => '([3589]00)(\\d{2,3})(\\d{4})',
                  'leading_digits' => '[3589]00'
                }
              ];

my $validators = {
                'toll_free' => '800\\d{6,7}',
                'geographic' => '
          1[1-9][2-5]\\d{7}|
          (?:
            [4689][1-9]|
            2[12478]|
            3[1-578]|
            5[1-5]|
            7[13-579]
          )[2-5]\\d{7}
        ',
                'mobile' => '
          1[1-9](?:
            7|
            9\\d
          )\\d{7}|
          (?:
            2[12478]|
            3[1-578]|
            7[13-579]|
            [89][1-9]
          )9?[6-9]\\d{7}|
          (?:
            [46][1-9]|
            5[1-5]
          )[6-9]\\d{7}
        ',
                'pager' => '',
                'personal_number' => '',
                'voip' => '',
                'specialrate' => '(
          (?:
           300\\d|
           40(?:
              0\\d|
              20
           )
          )\\d{4}
        )|([359]00\\d{6,7})',
                'fixed_line' => '
          1[1-9][2-5]\\d{7}|
          (?:
            [4689][1-9]|
            2[12478]|
            3[1-578]|
            5[1-5]|
            7[13-579]
          )[2-5]\\d{7}
        '
              };
sub areaname { my $self = shift; my $number = $self->{number}; my %map = (
  5511 => "São\ Paulo\ \-\ SP",
  5512 => "São\ José\ dos\ Campos\ \-\ SP",
  5513 => "Santos\ \-\ SP",
  5514 => "Bauru\ \-\ SP",
  5515 => "Sorocaba\ \-\ SP",
  5516 => "Ribeirão\ Prêto\ \-\ SP",
  5517 => "São\ José\ do\ Rio\ Prêto\ \-\ SP",
  5518 => "Presidente\ Prudente\ \-\ SP",
  5519 => "Campinas\ \-\ SP",
  5521 => "Rio\ de\ Janeiro",
  5522 => "Rio\ de\ Janeiro",
  5524 => "Petrópolis\ \-\ RJ",
  5527 => "Vitória\ \-\ ES",
  5528 => "Cachoeiro\ de\ Itapemirim\ \-\ ES",
  5531 => "Minas\ Gerais",
  5532 => "Juiz\ de\ Fora\ \-\ MG",
  5533 => "Governador\ Valadares\ \-\ MG",
  5534 => "Minas\ Gerais",
  5535 => "Minas\ Gerais",
  5537 => "Divinópolis\ \-\ MG",
  5538 => "Montes\ Claros\ \-\ MG",
  5541 => "Curitiba\ \-\ PR",
  5542 => "Paraná",
  5543 => "Londrina\ \-\ PR",
  5544 => "Maringá\ \-\ PR",
  5545 => "Foz\ do\ Iguaçu\ \-\ PR",
  5546 => "Francisco\ Beltrão\ \-\ PR",
  5547 => "Santa\ Catarina",
  5548 => "Florianópolis\ \-\ SC",
  5549 => "Santa\ Catarina",
  5551 => "Rio\ Grande\ do\ Sul",
  5552 => "Rio\ Grande\ do\ Sul",
  5553 => "Pelotas\ \-\ RS",
  5554 => "Caxias\ do\ Sul\ \-\ RS",
  5555 => "Rio\ Grande\ do\ Sul",
  5561 => "Brasília\ \-\ DF",
  5562 => "Goiânia\ \-\ GO",
  5563 => "Palmas\ \-\ TO",
  5564 => "Itumbiara\ \-\ GO",
  5565 => "Cuiabá\ \-\ MT",
  5566 => "Mato\ Grosso",
  5567 => "Campo\ Grande\ \-\ MS",
  5568 => "Rio\ Branco\ \-\ AC",
  5569 => "Rondônia",
  5571 => "Salvador\ \-\ BA",
  5573 => "Itabuna\ \-\ BA",
  5574 => "Irecê\ \-\ BA",
  5575 => "Feira\ de\ Santana\ \-\ BA",
  5577 => "Vitória\ da\ Conquista\ \-\ BA",
  5579 => "Aracaju\ \-\ SE",
  5581 => "Pernambuco",
  5582 => "Maceió\ \-\ AL",
  5583 => "João\ Pessoa\ \-\ PB",
  5584 => "Natal\ \-\ RN",
  5585 => "Fortaleza\ \-\ CE",
  5586 => "Teresina\ \-\ PI",
  5587 => "Petrolina\ \-\ PE",
  5588 => "Ceará",
  5589 => "Picos\ \-\ PI",
  5591 => "Belém\ \-\ PA",
  5592 => "Manaus\ \-\ AM",
  5593 => "Santarém\ \-\ PA",
  5594 => "Pará",
  5595 => "Boa\ Vista\ \-\ RR",
  5596 => "Macapá\ \-\ AP",
  5597 => "Amazonas",
  5598 => "São\ Luís\ \-\ MA",
  5599 => "Imperatriz\ \-\ MA",
);
      foreach my $prefix (map { substr($number, 0, $_) } reverse(1..length($number))) {
        return $map{"55$prefix"} if exists($map{"55$prefix"});
      }
      return undef;
    }
sub new {
  my $class = shift;
  my $number = shift;
  $number =~ s/(^\+55|\D)//g;
  my $self = bless({ number => $number, formatters => $formatters, validators => $validators }, $class);
  return $self if ($self->is_valid());
  $number =~ s/(^0)//g;
  $self = bless({ number => $number, formatters => $formatters, validators => $validators }, $class);
  return $self->is_valid() ? $self : undef;
}

1;
