File Coverage

blib/lib/Number/Phone/StubCountry/MV.pm
Criterion Covered Total %
statement 17 17 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 25 25 100.0


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::MV;
20 2     2   1289 use base qw(Number::Phone::StubCountry);
  2         10  
  2         241  
21              
22 2     2   15 use strict;
  2         6  
  2         48  
23 2     2   18 use warnings;
  2         11  
  2         60  
24 2     2   15 use utf8;
  2         5  
  2         17  
25             our $VERSION = 1.20230903131448;
26              
27             my $formatters = [
28             {
29             'format' => '$1-$2',
30             'leading_digits' => '[34679]',
31             'pattern' => '(\\d{3})(\\d{4})'
32             },
33             {
34             'format' => '$1 $2 $3',
35             'leading_digits' => '[89]',
36             'pattern' => '(\\d{3})(\\d{3})(\\d{4})'
37             }
38             ];
39              
40             my $validators = {
41             'fixed_line' => '
42             (?:
43             3(?:
44             0[0-3]|
45             3[0-59]
46             )|
47             6(?:
48             [58][024689]|
49             6[024-68]|
50             7[02468]
51             )
52             )\\d{4}
53             ',
54             'geographic' => '
55             (?:
56             3(?:
57             0[0-3]|
58             3[0-59]
59             )|
60             6(?:
61             [58][024689]|
62             6[024-68]|
63             7[02468]
64             )
65             )\\d{4}
66             ',
67             'mobile' => '
68             (?:
69             46[46]|
70             [79]\\d\\d
71             )\\d{4}
72             ',
73             'pager' => '',
74             'personal_number' => '',
75             'specialrate' => '(900\\d{7})|(
76             4(?:
77             0[01]|
78             50
79             )\\d{4}
80             )',
81             'toll_free' => '800\\d{7}',
82             'voip' => ''
83             };
84             my %areanames = ();
85             $areanames{en} = {"960654", "Shaviyani",
86             "960672", "Meemu",
87             "960301", "Malé\/Hulhulé\/Aarah",
88             "960332", "Malé\/Hulhulé\/Aarah",
89             "960656", "Noonu",
90             "960662", "Lhaviyani",
91             "960682", "Gaafu\ Alifu",
92             "960300", "Malé\/Hulhulé\/Aarah",
93             "960659", "Raa",
94             "960650", "Haa\ Alifu",
95             "960303", "Malé\ Region",
96             "960658", "Raa",
97             "960666", "Alifu\ Alifu",
98             "960652", "Haa\ Dhaalu",
99             "960335", "Hulhumalé",
100             "960686", "Gnaviyani",
101             "960674", "Faafu",
102             "960680", "Laamu",
103             "960331", "Malé\/Hulhulé\/Aarah",
104             "960660", "Baa",
105             "960689", "Addu",
106             "960688", "Addu",
107             "960334", "Malé\/Hulhulé\/Aarah",
108             "960668", "Alifu\ Dhaalu",
109             "960302", "Malé\ Region",
110             "960664", "Kaafu",
111             "960684", "Gaafu\ Dhaalu",
112             "960676", "Dhaalu",
113             "960330", "Malé\/Hulhulé\/Aarah",
114             "960339", "Vilimalé",
115             "960678", "Thaa",
116             "960665", "Kaafu",
117             "960333", "Malé\/Hulhulé\/Aarah",
118             "960670", "Vaavu",};
119              
120             sub new {
121 16     16 1 49 my $class = shift;
122 16         28 my $number = shift;
123 16         101 $number =~ s/(^\+960|\D)//g;
124 16         90 my $self = bless({ country_code => '960', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
125 16 100       89 return $self->is_valid() ? $self : undef;
126             }
127             1;