File Coverage

blib/lib/Number/Phone/StubCountry/TZ.pm
Criterion Covered Total %
statement 20 20 100.0
branch 3 4 75.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 29 30 96.6


line stmt bran cond sub pod time code
1             # automatically generated file, don't edit
2              
3              
4              
5             # Copyright 2023 David Cantrell, derived from data from libphonenumber
6             # http://code.google.com/p/libphonenumber/
7             #
8             # Licensed under the Apache License, Version 2.0 (the "License");
9             # you may not use this file except in compliance with the License.
10             # You may obtain a copy of the License at
11             #
12             # http://www.apache.org/licenses/LICENSE-2.0
13             #
14             # Unless required by applicable law or agreed to in writing, software
15             # distributed under the License is distributed on an "AS IS" BASIS,
16             # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17             # See the License for the specific language governing permissions and
18             # limitations under the License.
19             package Number::Phone::StubCountry::TZ;
20 2     2   1232 use base qw(Number::Phone::StubCountry);
  2         6  
  2         229  
21              
22 2     2   23 use strict;
  2         13  
  2         64  
23 2     2   14 use warnings;
  2         9  
  2         57  
24 2     2   11 use utf8;
  2         8  
  2         15  
25             our $VERSION = 1.20230903131448;
26              
27             my $formatters = [
28             {
29             'format' => '$1 $2 $3',
30             'leading_digits' => '[89]',
31             'national_rule' => '0$1',
32             'pattern' => '(\\d{3})(\\d{2})(\\d{4})'
33             },
34             {
35             'format' => '$1 $2 $3',
36             'leading_digits' => '[24]',
37             'national_rule' => '0$1',
38             'pattern' => '(\\d{2})(\\d{3})(\\d{4})'
39             },
40             {
41             'format' => '$1 $2',
42             'leading_digits' => '5',
43             'pattern' => '(\\d{2})(\\d{7})'
44             },
45             {
46             'format' => '$1 $2 $3',
47             'leading_digits' => '[67]',
48             'national_rule' => '0$1',
49             'pattern' => '(\\d{3})(\\d{3})(\\d{3})'
50             }
51             ];
52              
53             my $validators = {
54             'fixed_line' => '2[2-8]\\d{7}',
55             'geographic' => '2[2-8]\\d{7}',
56             'mobile' => '
57             77[2-9]\\d{6}|
58             (?:
59             6[125-9]|
60             7[13-689]
61             )\\d{7}
62             ',
63             'pager' => '',
64             'personal_number' => '',
65             'specialrate' => '(
66             8(?:
67             40|
68             6[01]
69             )\\d{6}
70             )|(90\\d{7})',
71             'toll_free' => '80[08]\\d{6}',
72             'voip' => '41\\d{7}'
73             };
74             my %areanames = ();
75             $areanames{en} = {"25528", "Mwanza\/Shinyanga\/Mara\/Geita\/Simiyu\/Kagera\/Kigoma",
76             "25524", "Zanzibar",
77             "25523", "Coast\/Morogoro\/Lindi\/Mtwara",
78             "25526", "Dodoma\/Iringa\/Njombe\/Singida\/Tabora",
79             "25522", "Dar\-Es\-Salaam",
80             "25525", "Mbeya\/Songwe\/Ruvuma\/Katavi\/Rukwa",
81             "25527", "Arusha\/Manyara\/Kilimanjaro\/Tanga",};
82              
83             sub new {
84 19     19 1 47 my $class = shift;
85 19         38 my $number = shift;
86 19         139 $number =~ s/(^\+255|\D)//g;
87 19         108 my $self = bless({ country_code => '255', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
88 19 100       98 return $self if ($self->is_valid());
89 1         6 $number =~ s/^(?:0)//;
90 1         11 $self = bless({ country_code => '255', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
91 1 50       6 return $self->is_valid() ? $self : undef;
92             }
93             1;