File Coverage

blib/lib/Number/Phone/StubCountry/EG.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::EG;
20 2     2   1143 use base qw(Number::Phone::StubCountry);
  2         8  
  2         214  
21              
22 2     2   16 use strict;
  2         5  
  2         47  
23 2     2   16 use warnings;
  2         5  
  2         49  
24 2     2   55 use utf8;
  2         9  
  2         15  
25             our $VERSION = 1.20230307181420;
26              
27             my $formatters = [
28             {
29             'format' => '$1 $2',
30             'leading_digits' => '[23]',
31             'national_rule' => '0$1',
32             'pattern' => '(\\d)(\\d{7,8})'
33             },
34             {
35             'format' => '$1 $2',
36             'leading_digits' => '
37             1[35]|
38             [4-6]|
39             8[2468]|
40             9[235-7]
41             ',
42             'national_rule' => '0$1',
43             'pattern' => '(\\d{2})(\\d{6,7})'
44             },
45             {
46             'format' => '$1 $2 $3',
47             'leading_digits' => '[189]',
48             'national_rule' => '0$1',
49             'pattern' => '(\\d{3})(\\d{3})(\\d{4})'
50             }
51             ];
52              
53             my $validators = {
54             'fixed_line' => '
55             13[23]\\d{6}|
56             (?:
57             15|
58             57
59             )\\d{6,7}|
60             (?:
61             2[2-4]|
62             3|
63             4[05-8]|
64             5[05]|
65             6[24-689]|
66             8[2468]|
67             9[235-7]
68             )\\d{7}
69             ',
70             'geographic' => '
71             13[23]\\d{6}|
72             (?:
73             15|
74             57
75             )\\d{6,7}|
76             (?:
77             2[2-4]|
78             3|
79             4[05-8]|
80             5[05]|
81             6[24-689]|
82             8[2468]|
83             9[235-7]
84             )\\d{7}
85             ',
86             'mobile' => '1[0-25]\\d{8}',
87             'pager' => '',
88             'personal_number' => '',
89             'specialrate' => '(900\\d{7})',
90             'toll_free' => '800\\d{7}',
91             'voip' => ''
92             };
93             my %areanames = ();
94             $areanames{en} = {"2086", "Minia",
95             "2048", "Monufia",
96             "2092", "Wadi\ El\-Gedid",
97             "2045", "Damanhur",
98             "20554", "10th\ of\ Ramadan",
99             "2062", "Suez",
100             "2015", "10th\ of\ Ramadan",
101             "202", "Cairo\/Giza\/Qalyubia",
102             "2046", "Marsa\ Matruh",
103             "2088", "Assiout",
104             "2084", "Fayoum",
105             "2097", "Aswan",
106             "2055", "Zagazig",
107             "2093", "Sohag",
108             "2040", "Tanta",
109             "2082", "Beni\ Suef",
110             "2013", "Banha",
111             "2047", "Kafr\ El\-Sheikh",
112             "2096", "Qena",
113             "2066", "Port\ Said",
114             "2065", "Red\ Sea",
115             "2050", "Mansoura",
116             "2095", "Luxor",
117             "2069", "El\-Tor",
118             "2057", "Damietta",
119             "203", "Alexandria",
120             "2068", "El\-Arish",
121             "2064", "Ismailia",};
122              
123             sub new {
124 13     13 1 28 my $class = shift;
125 13         37 my $number = shift;
126 13         81 $number =~ s/(^\+20|\D)//g;
127 13         83 my $self = bless({ country_code => '20', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
128 13 100       62 return $self if ($self->is_valid());
129 1         4 $number =~ s/^(?:0)//;
130 1         12 $self = bless({ country_code => '20', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
131 1 50       8 return $self->is_valid() ? $self : undef;
132             }
133             1;