File Coverage

blib/lib/Number/Phone/StubCountry/PM.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::PM;
20 2     2   1415 use base qw(Number::Phone::StubCountry);
  2         9  
  2         264  
21              
22 2     2   21 use strict;
  2         8  
  2         57  
23 2     2   14 use warnings;
  2         11  
  2         74  
24 2     2   16 use utf8;
  2         10  
  2         24  
25             our $VERSION = 1.20230307181422;
26              
27             my $formatters = [
28             {
29             'format' => '$1 $2 $3',
30             'leading_digits' => '[45]',
31             'national_rule' => '0$1',
32             'pattern' => '(\\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             (?:
45             4[1-356]|
46             50
47             )\\d{4}
48             ',
49             'geographic' => '
50             (?:
51             4[1-356]|
52             50
53             )\\d{4}
54             ',
55             'mobile' => '
56             (?:
57             4[02-4]|
58             5[056]
59             )\\d{4}
60             ',
61             'pager' => '',
62             'personal_number' => '',
63             'specialrate' => '',
64             'toll_free' => '80[0-5]\\d{6}',
65             'voip' => ''
66             };
67              
68             sub new {
69 10     10 1 26 my $class = shift;
70 10         20 my $number = shift;
71 10         68 $number =~ s/(^\+508|\D)//g;
72 10         51 my $self = bless({ country_code => '508', number => $number, formatters => $formatters, validators => $validators, }, $class);
73 10 100       45 return $self if ($self->is_valid());
74 1         4 $number =~ s/^(?:0)//;
75 1         10 $self = bless({ country_code => '508', number => $number, formatters => $formatters, validators => $validators, }, $class);
76 1 50       5 return $self->is_valid() ? $self : undef;
77             }
78             1;