File Coverage

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