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   1113 use base qw(Number::Phone::StubCountry);
  2         4  
  2         217  
21              
22 2     2   13 use strict;
  2         10  
  2         460  
23 2     2   17 use warnings;
  2         5  
  2         56  
24 2     2   12 use utf8;
  2         4  
  2         10  
25             our $VERSION = 1.20230903131440;
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} = {"97166", "Sharjah\,\ Ajman\,\ Umm\ Al\-Qaiwain",
73             "97168", "Sharjah\,\ Ajman\,\ Umm\ Al\-Qaiwain",
74             "97175", "Ras\ Alkhaimah",
75             "97145", "Dubai",
76             "97198", "Fujairah",
77             "97196", "Fujairah",
78             "97162", "Sharjah\,\ Ajman\,\ Umm\ Al\-Qaiwain",
79             "97163", "Sharjah\,\ Ajman\,\ Umm\ Al\-Qaiwain",
80             "97192", "Fujairah",
81             "97193", "Fujairah",
82             "97197", "Fujairah",
83             "97167", "Sharjah\,\ Ajman\,\ Umm\ Al\-Qaiwain",
84             "9713", "Al\ Ain",
85             "97164", "Sharjah\,\ Ajman\,\ Umm\ Al\-Qaiwain",
86             "97194", "Fujairah",
87             "97147", "Dubai",
88             "97177", "Ras\ Alkhaimah",
89             "97174", "Ras\ Alkhaimah",
90             "97144", "Dubai",
91             "97165", "Sharjah\,\ Ajman\,\ Umm\ Al\-Qaiwain",
92             "97176", "Ras\ Alkhaimah",
93             "97146", "Dubai",
94             "97195", "Fujairah",
95             "97148", "Dubai",
96             "97178", "Ras\ Alkhaimah",
97             "9712", "Abu\ dhabi",
98             "97172", "Ras\ Alkhaimah",
99             "97143", "Dubai",
100             "97142", "Dubai",
101             "97173", "Ras\ Alkhaimah",};
102              
103             sub new {
104 19     19 1 71 my $class = shift;
105 19         32 my $number = shift;
106 19         115 $number =~ s/(^\+971|\D)//g;
107 19         98 my $self = bless({ country_code => '971', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
108 19 100       90 return $self if ($self->is_valid());
109 1         4 $number =~ s/^(?:0)//;
110 1         15 $self = bless({ country_code => '971', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
111 1 50       4 return $self->is_valid() ? $self : undef;
112             }
113             1;