File Coverage

blib/lib/Number/Phone/StubCountry/AE.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::AE;
20 2     2   1156 use base qw(Number::Phone::StubCountry);
  2         4  
  2         221  
21              
22 2     2   19 use strict;
  2         5  
  2         42  
23 2     2   11 use warnings;
  2         4  
  2         75  
24 2     2   15 use utf8;
  2         4  
  2         16  
25             our $VERSION = 1.20230614174400;
26              
27             my $formatters = [
28             {
29             'format' => '$1 $2',
30             'leading_digits' => '
31             60|
32             8
33             ',
34             'pattern' => '(\\d{3})(\\d{2,9})'
35             },
36             {
37             'format' => '$1 $2 $3',
38             'leading_digits' => '
39             [236]|
40             [479][2-8]
41             ',
42             'national_rule' => '0$1',
43             'pattern' => '(\\d)(\\d{3})(\\d{4})'
44             },
45             {
46             'format' => '$1 $2 $3',
47             'leading_digits' => '[479]',
48             'pattern' => '(\\d{3})(\\d)(\\d{5})'
49             },
50             {
51             'format' => '$1 $2 $3',
52             'leading_digits' => '5',
53             'national_rule' => '0$1',
54             'pattern' => '(\\d{2})(\\d{3})(\\d{4})'
55             }
56             ];
57              
58             my $validators = {
59             'fixed_line' => '[2-4679][2-8]\\d{6}',
60             'geographic' => '[2-4679][2-8]\\d{6}',
61             'mobile' => '5[024-68]\\d{7}',
62             'pager' => '',
63             'personal_number' => '',
64             'specialrate' => '(700[05]\\d{5})|(900[02]\\d{5})|(600[25]\\d{5})',
65             'toll_free' => '
66             400\\d{6}|
67             800\\d{2,9}
68             ',
69             'voip' => ''
70             };
71             my %areanames = ();
72             $areanames{en} = {"97192", "Fujairah",
73             "97146", "Dubai",
74             "97145", "Dubai",
75             "9713", "Al\ Ain",
76             "97167", "Sharjah\,\ Ajman\,\ Umm\ Al\-Qaiwain",
77             "97143", "Dubai",
78             "97144", "Dubai",
79             "97168", "Sharjah\,\ Ajman\,\ Umm\ Al\-Qaiwain",
80             "97172", "Ras\ Alkhaimah",
81             "97166", "Sharjah\,\ Ajman\,\ Umm\ Al\-Qaiwain",
82             "9712", "Abu\ dhabi",
83             "97165", "Sharjah\,\ Ajman\,\ Umm\ Al\-Qaiwain",
84             "97147", "Dubai",
85             "97163", "Sharjah\,\ Ajman\,\ Umm\ Al\-Qaiwain",
86             "97164", "Sharjah\,\ Ajman\,\ Umm\ Al\-Qaiwain",
87             "97148", "Dubai",
88             "97176", "Ras\ Alkhaimah",
89             "97194", "Fujairah",
90             "97175", "Ras\ Alkhaimah",
91             "97173", "Ras\ Alkhaimah",
92             "97193", "Fujairah",
93             "97195", "Fujairah",
94             "97142", "Dubai",
95             "97196", "Fujairah",
96             "97174", "Ras\ Alkhaimah",
97             "97198", "Fujairah",
98             "97177", "Ras\ Alkhaimah",
99             "97197", "Fujairah",
100             "97162", "Sharjah\,\ Ajman\,\ Umm\ Al\-Qaiwain",
101             "97178", "Ras\ Alkhaimah",};
102              
103             sub new {
104 19     19 1 82 my $class = shift;
105 19         46 my $number = shift;
106 19         115 $number =~ s/(^\+971|\D)//g;
107 19         103 my $self = bless({ country_code => '971', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
108 19 100       78 return $self if ($self->is_valid());
109 1         4 $number =~ s/^(?:0)//;
110 1         11 $self = bless({ country_code => '971', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
111 1 50       5 return $self->is_valid() ? $self : undef;
112             }
113             1;