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