File Coverage

blib/lib/Number/Phone/StubCountry/GA.pm
Criterion Covered Total %
statement 26 27 96.3
branch 4 6 66.6
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 37 40 92.5


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::GA;
20 2     2   1362 use base qw(Number::Phone::StubCountry);
  2         5  
  2         330  
21              
22 2     2   21 use strict;
  2         4  
  2         54  
23 2     2   15 use warnings;
  2         6  
  2         58  
24 2     2   16 use utf8;
  2         6  
  2         14  
25             our $VERSION = 1.20230614174403;
26              
27             my $formatters = [
28             {
29             'format' => '$1 $2 $3 $4',
30             'leading_digits' => '[2-7]',
31             'national_rule' => '0$1',
32             'pattern' => '(\\d)(\\d{2})(\\d{2})(\\d{2})'
33             },
34             {
35             'format' => '$1 $2 $3 $4',
36             'pattern' => '(\\d{2})(\\d{2})(\\d{2})(\\d{2})'
37             },
38             {
39             'format' => '$1 $2 $3 $4',
40             'leading_digits' => '
41             11|
42             [67]
43             ',
44             'national_rule' => '0$1',
45             'pattern' => '(\\d{2})(\\d{2})(\\d{2})(\\d{2})'
46             }
47             ];
48              
49             my $validators = {
50             'fixed_line' => '[01]1\\d{6}',
51             'geographic' => '[01]1\\d{6}',
52             'mobile' => '
53             (?:
54             (?:
55             0[2-7]|
56             7[467]
57             )\\d|
58             6(?:
59             0[0-4]|
60             10|
61             [256]\\d
62             )
63             )\\d{5}|
64             [2-7]\\d{6}
65             ',
66             'pager' => '',
67             'personal_number' => '',
68             'specialrate' => '',
69             'toll_free' => '',
70             'voip' => ''
71             };
72             my %areanames = ();
73             $areanames{en} = {"2410182", "Tchibanga",
74             "2410198", "Oyem",
75             "2410144", "Libreville",
76             "2410154", "Omboué",
77             "24101424", "Cocobeach",
78             "2410165", "Koulamoutou",
79             "2411159", "Ndjolé",
80             "2411148", "Libreville",
81             "2411158", "Lambaréné",
82             "2410167", "Franceville",
83             "2411160", "Ngouoni",
84             "2410192", "Mékambo",
85             "2410166", "Moanda",
86             "2411190", "Makokou",
87             "2410162", "Mounana",
88             "2410196", "Bitam",
89             "2410183", "Mayumba",
90             "2411164", "Lastoursville",
91             "2411155", "Port\-Gentil",
92             "2411145", "Libreville",
93             "24111420", "Ntoum",
94             "2410169", "Léconi\/Akiéni\/Okondja",
95             "2410193", "Booué",
96             "2411147", "Libreville",
97             "2410140", "Kango",
98             "2410186", "Mouila",
99             "2410150", "Gamba",
100             "241017", "Libreville",
101             "2411146", "Libreville",
102             "2411156", "Port\-Gentil",
103             "2411192", "Mékambo",
104             "2410160", "Ngouoni",
105             "2411166", "Moanda",
106             "2410158", "Lambaréné",
107             "2410148", "Libreville",
108             "2410159", "Ndjolé",
109             "2411167", "Franceville",
110             "24111424", "Cocobeach",
111             "2411154", "Omboué",
112             "2411198", "Oyem",
113             "2411144", "Libreville",
114             "2411165", "Koulamoutou",
115             "2411182", "Tchibanga",
116             "2411150", "Gamba",
117             "2411140", "Kango",
118             "2411186", "Mouila",
119             "2410156", "Port\-Gentil",
120             "241117", "Libreville",
121             "2410146", "Libreville",
122             "2411169", "Léconi\/Akiéni\/Okondja",
123             "24101420", "Ntoum",
124             "2410147", "Libreville",
125             "2411193", "Booué",
126             "2410164", "Lastoursville",
127             "2411183", "Mayumba",
128             "2410145", "Libreville",
129             "2410155", "Port\-Gentil",
130             "2411162", "Mounana",
131             "2410190", "Makokou",
132             "2411196", "Bitam",};
133              
134             sub new {
135 7     7 1 17 my $class = shift;
136 7         19 my $number = shift;
137 7         44 $number =~ s/(^\+241|\D)//g;
138 7         49 my $self = bless({ country_code => '241', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
139 7 100       44 return $self if ($self->is_valid());
140 1         26 my $prefix = qr/^(?:0(11\d{6}|60\d{6}|61\d{6}|6[256]\d{6}|7[467]\d{6}))/;
141 1         4 my @matches = $number =~ /$prefix/;
142 1 50       4 if (defined $matches[-1]) {
143 2     2   994 no warnings 'uninitialized';
  2         8  
  2         347  
144 0         0 $number =~ s/$prefix/$1/;
145             }
146             else {
147 1         3 $number =~ s/$prefix//;
148             }
149 1         11 $self = bless({ country_code => '241', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
150 1 50       6 return $self->is_valid() ? $self : undef;
151             }
152             1;