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   1177 use base qw(Number::Phone::StubCountry);
  2         5  
  2         218  
21              
22 2     2   17 use strict;
  2         6  
  2         55  
23 2     2   18 use warnings;
  2         18  
  2         52  
24 2     2   14 use utf8;
  2         5  
  2         10  
25             our $VERSION = 1.20230903131448;
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',
36             'leading_digits' => '7',
37             'pattern' => '(\\d{3})(\\d{3})(\\d{3})'
38             },
39             {
40             'format' => '$1 $2 $3 $4',
41             'leading_digits' => '8',
42             'national_rule' => '0$1',
43             'pattern' => '(\\d{3})(\\d{2})(\\d{2})(\\d{2})'
44             }
45             ];
46              
47             my $validators = {
48             'fixed_line' => '
49             (?:
50             4[1-35-7]|
51             5[01]
52             )\\d{4}
53             ',
54             'geographic' => '
55             (?:
56             4[1-35-7]|
57             5[01]
58             )\\d{4}
59             ',
60             'mobile' => '
61             (?:
62             4[02-4]|
63             5[056]|
64             708[45][0-5]
65             )\\d{4}
66             ',
67             'pager' => '',
68             'personal_number' => '',
69             'specialrate' => '',
70             'toll_free' => '80[0-5]\\d{6}',
71             'voip' => ''
72             };
73              
74             sub new {
75 10     10 1 24 my $class = shift;
76 10         21 my $number = shift;
77 10         63 $number =~ s/(^\+508|\D)//g;
78 10         51 my $self = bless({ country_code => '508', number => $number, formatters => $formatters, validators => $validators, }, $class);
79 10 100       46 return $self if ($self->is_valid());
80 1         8 $number =~ s/^(?:0)//;
81 1         11 $self = bless({ country_code => '508', number => $number, formatters => $formatters, validators => $validators, }, $class);
82 1 50       3 return $self->is_valid() ? $self : undef;
83             }
84             1;