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