File Coverage

blib/lib/Number/Phone/StubCountry/TO.pm
Criterion Covered Total %
statement 17 17 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 25 25 100.0


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::TO;
20 2     2   1347 use base qw(Number::Phone::StubCountry);
  2         7  
  2         239  
21              
22 2     2   15 use strict;
  2         7  
  2         48  
23 2     2   16 use warnings;
  2         6  
  2         57  
24 2     2   11 use utf8;
  2         6  
  2         18  
25             our $VERSION = 1.20230903131448;
26              
27             my $formatters = [
28             {
29             'format' => '$1-$2',
30             'leading_digits' => '
31             [2-4]|
32             50|
33             6[09]|
34             7[0-24-69]|
35             8[05]
36             ',
37             'pattern' => '(\\d{2})(\\d{3})'
38             },
39             {
40             'format' => '$1 $2',
41             'pattern' => '(\\d{4})(\\d{3})'
42             },
43             {
44             'format' => '$1 $2',
45             'leading_digits' => '[5-9]',
46             'pattern' => '(\\d{3})(\\d{4})'
47             }
48             ];
49              
50             my $validators = {
51             'fixed_line' => '
52             (?:
53             2\\d|
54             3[0-8]|
55             4[0-4]|
56             50|
57             6[09]|
58             7[0-24-69]|
59             8[05]
60             )\\d{3}
61             ',
62             'geographic' => '
63             (?:
64             2\\d|
65             3[0-8]|
66             4[0-4]|
67             50|
68             6[09]|
69             7[0-24-69]|
70             8[05]
71             )\\d{3}
72             ',
73             'mobile' => '
74             (?:
75             55[4-6]|
76             6(?:
77             [09]\\d|
78             3[02]|
79             8[15-9]
80             )|
81             (?:
82             7\\d|
83             8[46-9]
84             )\\d|
85             999
86             )\\d{4}
87             ',
88             'pager' => '',
89             'personal_number' => '',
90             'specialrate' => '',
91             'toll_free' => '0800\\d{3}',
92             'voip' => '55[0-37-9]\\d{4}'
93             };
94             my %areanames = ();
95             $areanames{en} = {"67675", "Vava\’u",
96             "67637", "Vaini",
97             "67680", "Niuas",
98             "67634", "Kolonga",
99             "67636", "Nakolo",
100             "67685", "Niuas",
101             "67638", "Vaini",
102             "67650", "\‘Eua",
103             "67632", "Muʻa",
104             "67633", "Kolonga",
105             "67670", "Vava\’u",
106             "67640", "Kolovai",
107             "67631", "Muʻa",
108             "67629", "Pea",
109             "67679", "Vava\’u",
110             "67635", "Nakolo",
111             "67674", "Vava\’u",
112             "67669", "Ha\’apai",
113             "67660", "Ha\’apai",
114             "6762", "Nuku\'alofa",
115             "67676", "Vava\’u",
116             "67630", "Pea",
117             "67643", "Matangiake",
118             "67672", "Vava\’u",
119             "67642", "Masilamea",
120             "67671", "Vava\’u",
121             "67641", "Masilamea",};
122              
123             sub new {
124 13     13 1 38 my $class = shift;
125 13         29 my $number = shift;
126 13         80 $number =~ s/(^\+676|\D)//g;
127 13         73 my $self = bless({ country_code => '676', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
128 13 100       70 return $self->is_valid() ? $self : undef;
129             }
130             1;