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