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   1431 use base qw(Number::Phone::StubCountry);
  2         6  
  2         283  
21              
22 2     2   24 use strict;
  2         6  
  2         71  
23 2     2   11 use warnings;
  2         5  
  2         62  
24 2     2   14 use utf8;
  2         9  
  2         14  
25             our $VERSION = 1.20230614174403;
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} = {"2048", "Monufia",
95             "203", "Alexandria",
96             "2055", "Zagazig",
97             "2050", "Mansoura",
98             "2097", "Aswan",
99             "2046", "Marsa\ Matruh",
100             "2065", "Red\ Sea",
101             "2069", "El\-Tor",
102             "2095", "Luxor",
103             "2057", "Damietta",
104             "20554", "10th\ of\ Ramadan",
105             "2013", "Banha",
106             "2068", "El\-Arish",
107             "2084", "Fayoum",
108             "2040", "Tanta",
109             "2092", "Wadi\ El\-Gedid",
110             "2045", "Damanhur",
111             "2082", "Beni\ Suef",
112             "2066", "Port\ Said",
113             "202", "Cairo\/Giza\/Qalyubia",
114             "2062", "Suez",
115             "2086", "Minia",
116             "2015", "10th\ of\ Ramadan",
117             "2096", "Qena",
118             "2047", "Kafr\ El\-Sheikh",
119             "2088", "Assiout",
120             "2064", "Ismailia",
121             "2093", "Sohag",};
122              
123             sub new {
124 13     13 1 29 my $class = shift;
125 13         23 my $number = shift;
126 13         81 $number =~ s/(^\+20|\D)//g;
127 13         105 my $self = bless({ country_code => '20', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
128 13 100       70 return $self if ($self->is_valid());
129 1         3 $number =~ s/^(?:0)//;
130 1         10 $self = bless({ country_code => '20', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
131 1 50       4 return $self->is_valid() ? $self : undef;
132             }
133             1;