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   1151 use base qw(Number::Phone::StubCountry);
  2         8  
  2         218  
21              
22 2     2   14 use strict;
  2         5  
  2         44  
23 2     2   10 use warnings;
  2         7  
  2         50  
24 2     2   13 use utf8;
  2         4  
  2         10  
25             our $VERSION = 1.20230903131447;
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} = {"241117", "Libreville",
74             "2411145", "Libreville",
75             "2410165", "Koulamoutou",
76             "2411146", "Libreville",
77             "2410166", "Moanda",
78             "2411154", "Omboué",
79             "2411183", "Mayumba",
80             "2411156", "Port\-Gentil",
81             "2410164", "Lastoursville",
82             "2410186", "Mouila",
83             "2411144", "Libreville",
84             "2410196", "Bitam",
85             "2411193", "Booué",
86             "2411155", "Port\-Gentil",
87             "241017", "Libreville",
88             "2410145", "Libreville",
89             "2411165", "Koulamoutou",
90             "2410146", "Libreville",
91             "2411166", "Moanda",
92             "2410154", "Omboué",
93             "2410183", "Mayumba",
94             "2410156", "Port\-Gentil",
95             "2411186", "Mouila",
96             "2411164", "Lastoursville",
97             "2410144", "Libreville",
98             "2411196", "Bitam",
99             "2410155", "Port\-Gentil",
100             "2410193", "Booué",
101             "2411148", "Libreville",
102             "24111424", "Cocobeach",
103             "24101420", "Ntoum",
104             "2410198", "Oyem",
105             "2411158", "Lambaréné",
106             "2410148", "Libreville",
107             "24101424", "Cocobeach",
108             "24111420", "Ntoum",
109             "2411198", "Oyem",
110             "2410158", "Lambaréné",
111             "2411160", "Ngouoni",
112             "2410140", "Kango",
113             "2411190", "Makokou",
114             "2410167", "Franceville",
115             "2411147", "Libreville",
116             "2410150", "Gamba",
117             "2410160", "Ngouoni",
118             "2411140", "Kango",
119             "2410190", "Makokou",
120             "2411167", "Franceville",
121             "2410147", "Libreville",
122             "2411150", "Gamba",
123             "2410182", "Tchibanga",
124             "2410192", "Mékambo",
125             "2410159", "Ndjolé",
126             "2411169", "Léconi\/Akiéni\/Okondja",
127             "2410162", "Mounana",
128             "2411182", "Tchibanga",
129             "2411192", "Mékambo",
130             "2411159", "Ndjolé",
131             "2410169", "Léconi\/Akiéni\/Okondja",
132             "2411162", "Mounana",};
133              
134             sub new {
135 7     7 1 25 my $class = shift;
136 7         13 my $number = shift;
137 7         48 $number =~ s/(^\+241|\D)//g;
138 7         55 my $self = bless({ country_code => '241', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
139 7 100       39 return $self if ($self->is_valid());
140 1         5 my $prefix = qr/^(?:0(11\d{6}|60\d{6}|61\d{6}|6[256]\d{6}|7[467]\d{6}))/;
141 1         8 my @matches = $number =~ /$prefix/;
142 1 50       4 if (defined $matches[-1]) {
143 2     2   1060 no warnings 'uninitialized';
  2         7  
  2         380  
144 0         0 $number =~ s/$prefix/$1/;
145             }
146             else {
147 1         3 $number =~ s/$prefix//;
148             }
149 1         12 $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;