| 1 | # automatically generated file, don't edit | ||||||||||
| 2 | |||||||||||
| 3 | |||||||||||
| 4 | |||||||||||
| 5 | # Copyright 2026 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 | ▶ | use base qw(Number::Phone::StubCountry); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | |||||||||||
| 22 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 2 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 25 | 2 | our $VERSION = 1.20260904101550; | |||||||||
| 26 | |||||||||||
| 27 | 2 | 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 | 2 | 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[356]| | ||||||||||
| 45 | 8[268]| | ||||||||||
| 46 | 9[2457] | ||||||||||
| 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[356]| | ||||||||||
| 57 | 8[268]| | ||||||||||
| 58 | 9[2457] | ||||||||||
| 59 | )\\d{5} | ||||||||||
| 60 | ', | ||||||||||
| 61 | 'mobile' => '3[2-9]\\d{7}', | ||||||||||
| 62 | 'pager' => '', | ||||||||||
| 63 | 'personal_number' => '', | ||||||||||
| 64 | 'specialrate' => '', | ||||||||||
| 65 | 'toll_free' => '', | ||||||||||
| 66 | 'voip' => '22\\d{7}' | ||||||||||
| 67 | }; | ||||||||||
| 68 | 2 | my %areanames = (); | |||||||||
| 69 | 2 | $areanames{en} = {"2612082", "Antsiranana", | |||||||||
| 70 | "2612094", "Toliary", | ||||||||||
| 71 | "2612069", "Maintirano", | ||||||||||
| 72 | "2612047", "Ambositra", | ||||||||||
| 73 | "2612062", "Mahajanga", | ||||||||||
| 74 | "2612075", "Fianarantsoa", | ||||||||||
| 75 | "2612057", "Maroantsetra\/Sainte\ Marie", | ||||||||||
| 76 | "2612022", "Antananarivo", | ||||||||||
| 77 | "2612067", "Antsohihy", | ||||||||||
| 78 | "2612095", "Morondava", | ||||||||||
| 79 | "2612073", "Farafangana", | ||||||||||
| 80 | "2612053", "Toamasina", | ||||||||||
| 81 | "2612044", "Antsirabe", | ||||||||||
| 82 | "26120722", "Manakara", | ||||||||||
| 83 | "2612092", "TaolaƱaro", | ||||||||||
| 84 | "2612054", "Ambatondrazaka", | ||||||||||
| 85 | "2612088", "Sambava", | ||||||||||
| 86 | "2612076", "Antananarivo", | ||||||||||
| 87 | "2612056", "Moramanga", | ||||||||||
| 88 | "26120729", "Mananjary", | ||||||||||
| 89 | "2612086", "Nosy\ Be",}; | ||||||||||
| 90 | 2 | my $timezones = { | |||||||||
| 91 | '' => [ | ||||||||||
| 92 | 'Indian/Antananarivo' | ||||||||||
| 93 | ] | ||||||||||
| 94 | }; | ||||||||||
| 95 | |||||||||||
| 96 | 10 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||
| 97 | 10 | my $class = shift; | |||||||||
| 98 | 10 | my $number = shift; | |||||||||
| 99 | 10 | $number =~ s/(^\+261|\D)//g; | |||||||||
| 100 | 10 | my $self = bless({ country_code => '261', number => $number, formatters => $formatters, validators => $validators, timezones => $timezones, areanames => \%areanames}, $class); | |||||||||
| 101 | 10 | ▶ | return $self if ($self->is_valid()); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 102 | 1 | my $prefix = qr/^(?:([24-9]\d{6})$|0)/; | |||||||||
| 103 | 1 | my @matches = $number =~ /$prefix/; | |||||||||
| 104 | 1 | ▶ | if (defined $matches[-1]) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 105 | 2 | ▶ | no warnings 'uninitialized'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 106 | 0 | $number =~ s/$prefix/20$1/; | |||||||||
| 107 | } | ||||||||||
| 108 | else { | ||||||||||
| 109 | 1 | $number =~ s/$prefix//; | |||||||||
| 110 | } | ||||||||||
| 111 | 1 | $self = bless({ country_code => '261', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class); | |||||||||
| 112 | 1 | ▶ | return $self->is_valid() ? $self : undef; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 113 | } | ||||||||||
| 114 | 2 | 1; | |||||||||