File Coverage

blib/lib/Number/Phone/StubCountry/GP.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::GP;
20 3     3   1764 use base qw(Number::Phone::StubCountry);
  3         7  
  3         411  
21              
22 3     3   26 use strict;
  3         9  
  3         75  
23 3     3   17 use warnings;
  3         6  
  3         90  
24 3     3   18 use utf8;
  3         5  
  3         24  
25             our $VERSION = 1.20230307181420;
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             590(?:
45             0[1-68]|
46             [14][0-24-9]|
47             2[0-68]|
48             3[1289]|
49             5[3-579]|
50             6[0-489]|
51             7[08]|
52             8[0-689]|
53             9\\d
54             )\\d{4}
55             ',
56             'geographic' => '
57             590(?:
58             0[1-68]|
59             [14][0-24-9]|
60             2[0-68]|
61             3[1289]|
62             5[3-579]|
63             6[0-489]|
64             7[08]|
65             8[0-689]|
66             9\\d
67             )\\d{4}
68             ',
69             'mobile' => '
70             69(?:
71             0\\d\\d|
72             1(?:
73             2[2-9]|
74             3[0-5]
75             )
76             )\\d{4}
77             ',
78             'pager' => '',
79             'personal_number' => '',
80             'specialrate' => '',
81             'toll_free' => '80[0-5]\\d{6}',
82             'voip' => '976[01]\\d{5}'
83             };
84              
85             sub new {
86 57     57 1 112 my $class = shift;
87 57         102 my $number = shift;
88 57         336 $number =~ s/(^\+590|\D)//g;
89 57         294 my $self = bless({ country_code => '590', number => $number, formatters => $formatters, validators => $validators, }, $class);
90 57 100       254 return $self if ($self->is_valid());
91 9         24 $number =~ s/^(?:0)//;
92 9         87 $self = bless({ country_code => '590', number => $number, formatters => $formatters, validators => $validators, }, $class);
93 9 50       36 return $self->is_valid() ? $self : undef;
94             }
95             1;