File Coverage

blib/lib/Number/Phone/StubCountry/MQ.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::MQ;
20 3     3   1823 use base qw(Number::Phone::StubCountry);
  3         10  
  3         397  
21              
22 3     3   31 use strict;
  3         7  
  3         75  
23 3     3   16 use warnings;
  3         7  
  3         79  
24 3     3   16 use utf8;
  3         6  
  3         19  
25             our $VERSION = 1.20230903131448;
26              
27             my $formatters = [
28             {
29             'format' => '$1 $2 $3 $4',
30             'leading_digits' => '[569]',
31             'national_rule' => '0$1',
32             'pattern' => '(\\d{3})(\\d{2})(\\d{2})(\\d{2})'
33             },
34             {
35             'format' => '$1 $2 $3 $4',
36             'leading_digits' => '8',
37             'national_rule' => '0$1',
38             'pattern' => '(\\d{3})(\\d{2})(\\d{2})(\\d{2})'
39             }
40             ];
41              
42             my $validators = {
43             'fixed_line' => '
44             596(?:
45             [03-7]\\d|
46             10|
47             2[7-9]|
48             8[0-39]|
49             9[04-9]
50             )\\d{4}
51             ',
52             'geographic' => '
53             596(?:
54             [03-7]\\d|
55             10|
56             2[7-9]|
57             8[0-39]|
58             9[04-9]
59             )\\d{4}
60             ',
61             'mobile' => '
62             69(?:
63             6(?:
64             [0-46-9]\\d|
65             5[0-6]
66             )|
67             727
68             )\\d{4}
69             ',
70             'pager' => '',
71             'personal_number' => '',
72             'specialrate' => '',
73             'toll_free' => '80[0-5]\\d{6}',
74             'voip' => '
75             9(?:
76             397[0-2]|
77             477[0-5]|
78             76(?:
79             6\\d|
80             7[0-367]
81             )
82             )\\d{4}
83             '
84             };
85              
86             sub new {
87 27     27 1 61 my $class = shift;
88 27         43 my $number = shift;
89 27         170 $number =~ s/(^\+596|\D)//g;
90 27         125 my $self = bless({ country_code => '596', number => $number, formatters => $formatters, validators => $validators, }, $class);
91 27 100       119 return $self if ($self->is_valid());
92 3         14 $number =~ s/^(?:0)//;
93 3         32 $self = bless({ country_code => '596', number => $number, formatters => $formatters, validators => $validators, }, $class);
94 3 50       14 return $self->is_valid() ? $self : undef;
95             }
96             1;