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   1625 use base qw(Number::Phone::StubCountry);
  3         10  
  3         389  
21              
22 3     3   24 use strict;
  3         7  
  3         66  
23 3     3   16 use warnings;
  3         6  
  3         76  
24 3     3   20 use utf8;
  3         12  
  3         32  
25             our $VERSION = 1.20230307181421;
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[09]|
49             9[4-9]
50             )\\d{4}
51             ',
52             'geographic' => '
53             596(?:
54             [03-7]\\d|
55             10|
56             2[7-9]|
57             8[09]|
58             9[4-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             (?:
77             39|
78             47
79             )7[01]|
80             76(?:
81             6\\d|
82             7[0-367]
83             )
84             )\\d{4}
85             '
86             };
87              
88             sub new {
89 27     27 1 52 my $class = shift;
90 27         46 my $number = shift;
91 27         162 $number =~ s/(^\+596|\D)//g;
92 27         126 my $self = bless({ country_code => '596', number => $number, formatters => $formatters, validators => $validators, }, $class);
93 27 100       125 return $self if ($self->is_valid());
94 3         8 $number =~ s/^(?:0)//;
95 3         36 $self = bless({ country_code => '596', number => $number, formatters => $formatters, validators => $validators, }, $class);
96 3 50       15 return $self->is_valid() ? $self : undef;
97             }
98             1;