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::MG; |
20
|
2
|
|
|
2
|
|
1092
|
use base qw(Number::Phone::StubCountry); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
218
|
|
21
|
|
|
|
|
|
|
|
22
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
47
|
|
23
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
50
|
|
24
|
2
|
|
|
2
|
|
14
|
use utf8; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
13
|
|
25
|
|
|
|
|
|
|
our $VERSION = 1.20230307181421; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $formatters = [ |
28
|
|
|
|
|
|
|
{ |
29
|
|
|
|
|
|
|
'format' => '$1 $2 $3 $4', |
30
|
|
|
|
|
|
|
'leading_digits' => '[23]', |
31
|
|
|
|
|
|
|
'national_rule' => '0$1', |
32
|
|
|
|
|
|
|
'pattern' => '(\\d{2})(\\d{2})(\\d{3})(\\d{2})' |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
]; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $validators = { |
37
|
|
|
|
|
|
|
'fixed_line' => ' |
38
|
|
|
|
|
|
|
2072[29]\\d{4}| |
39
|
|
|
|
|
|
|
20(?: |
40
|
|
|
|
|
|
|
2\\d| |
41
|
|
|
|
|
|
|
4[47]| |
42
|
|
|
|
|
|
|
5[3467]| |
43
|
|
|
|
|
|
|
6[279]| |
44
|
|
|
|
|
|
|
7[35]| |
45
|
|
|
|
|
|
|
8[268]| |
46
|
|
|
|
|
|
|
9[245] |
47
|
|
|
|
|
|
|
)\\d{5} |
48
|
|
|
|
|
|
|
', |
49
|
|
|
|
|
|
|
'geographic' => ' |
50
|
|
|
|
|
|
|
2072[29]\\d{4}| |
51
|
|
|
|
|
|
|
20(?: |
52
|
|
|
|
|
|
|
2\\d| |
53
|
|
|
|
|
|
|
4[47]| |
54
|
|
|
|
|
|
|
5[3467]| |
55
|
|
|
|
|
|
|
6[279]| |
56
|
|
|
|
|
|
|
7[35]| |
57
|
|
|
|
|
|
|
8[268]| |
58
|
|
|
|
|
|
|
9[245] |
59
|
|
|
|
|
|
|
)\\d{5} |
60
|
|
|
|
|
|
|
', |
61
|
|
|
|
|
|
|
'mobile' => '3[2-47-9]\\d{7}', |
62
|
|
|
|
|
|
|
'pager' => '', |
63
|
|
|
|
|
|
|
'personal_number' => '', |
64
|
|
|
|
|
|
|
'specialrate' => '', |
65
|
|
|
|
|
|
|
'toll_free' => '', |
66
|
|
|
|
|
|
|
'voip' => '22\\d{7}' |
67
|
|
|
|
|
|
|
}; |
68
|
|
|
|
|
|
|
my %areanames = (); |
69
|
|
|
|
|
|
|
$areanames{en} = {"2612073", "Farafangana", |
70
|
|
|
|
|
|
|
"2612086", "Nosy\ Be", |
71
|
|
|
|
|
|
|
"26120722", "Manakara", |
72
|
|
|
|
|
|
|
"2612054", "Ambatondrazaka", |
73
|
|
|
|
|
|
|
"2612062", "Mahajanga", |
74
|
|
|
|
|
|
|
"2612067", "Antsohihy", |
75
|
|
|
|
|
|
|
"2612092", "TaolaƱaro", |
76
|
|
|
|
|
|
|
"2612088", "Sambava", |
77
|
|
|
|
|
|
|
"2612075", "Fianarantsoa", |
78
|
|
|
|
|
|
|
"2612056", "Moramanga", |
79
|
|
|
|
|
|
|
"2612047", "Ambositra", |
80
|
|
|
|
|
|
|
"2612069", "Maintirano", |
81
|
|
|
|
|
|
|
"2612053", "Toamasina", |
82
|
|
|
|
|
|
|
"2612095", "Morondava", |
83
|
|
|
|
|
|
|
"2612022", "Antananarivo", |
84
|
|
|
|
|
|
|
"2612082", "Antsiranana", |
85
|
|
|
|
|
|
|
"2612094", "Toliary", |
86
|
|
|
|
|
|
|
"26120729", "Mananjary", |
87
|
|
|
|
|
|
|
"2612044", "Antsirabe", |
88
|
|
|
|
|
|
|
"2612057", "Maroantsetra\/Sainte\ Marie",}; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub new { |
91
|
10
|
|
|
10
|
1
|
29
|
my $class = shift; |
92
|
10
|
|
|
|
|
29
|
my $number = shift; |
93
|
10
|
|
|
|
|
63
|
$number =~ s/(^\+261|\D)//g; |
94
|
10
|
|
|
|
|
53
|
my $self = bless({ country_code => '261', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class); |
95
|
10
|
100
|
|
|
|
54
|
return $self if ($self->is_valid()); |
96
|
1
|
|
|
|
|
11
|
my $prefix = qr/^(?:([24-9]\d{6})$|0)/; |
97
|
1
|
|
|
|
|
4
|
my @matches = $number =~ /$prefix/; |
98
|
1
|
50
|
|
|
|
4
|
if (defined $matches[-1]) { |
99
|
2
|
|
|
2
|
|
671
|
no warnings 'uninitialized'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
369
|
|
100
|
0
|
|
|
|
|
0
|
$number =~ s/$prefix/20$1/; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
else { |
103
|
1
|
|
|
|
|
5
|
$number =~ s/$prefix//; |
104
|
|
|
|
|
|
|
} |
105
|
1
|
|
|
|
|
11
|
$self = bless({ country_code => '261', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class); |
106
|
1
|
50
|
|
|
|
5
|
return $self->is_valid() ? $self : undef; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
1; |