File Coverage

blib/lib/Number/Phone/StubCountry/NF.pm
Criterion Covered Total %
statement 26 27 96.3
branch 4 6 66.6
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 37 40 92.5


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::NF;
20 2     2   1291 use base qw(Number::Phone::StubCountry);
  2         7  
  2         226  
21              
22 2     2   26 use strict;
  2         13  
  2         53  
23 2     2   13 use warnings;
  2         5  
  2         54  
24 2     2   17 use utf8;
  2         5  
  2         13  
25             our $VERSION = 1.20230614174404;
26              
27             my $formatters = [
28             {
29             'format' => '$1 $2',
30             'leading_digits' => '1[0-3]',
31             'pattern' => '(\\d{2})(\\d{4})'
32             },
33             {
34             'format' => '$1 $2',
35             'leading_digits' => '[13]',
36             'pattern' => '(\\d)(\\d{5})'
37             }
38             ];
39              
40             my $validators = {
41             'fixed_line' => '
42             (?:
43             1(?:
44             06|
45             17|
46             28|
47             39
48             )|
49             3[0-2]\\d
50             )\\d{3}
51             ',
52             'geographic' => '
53             (?:
54             1(?:
55             06|
56             17|
57             28|
58             39
59             )|
60             3[0-2]\\d
61             )\\d{3}
62             ',
63             'mobile' => '
64             (?:
65             14|
66             3[58]
67             )\\d{4}
68             ',
69             'pager' => '',
70             'personal_number' => '',
71             'specialrate' => '',
72             'toll_free' => '',
73             'voip' => ''
74             };
75             my %areanames = ();
76             $areanames{en} = {"67212", "Casey",
77             "67213", "Macquarie\ Island",
78             "67210", "Davis",
79             "67211", "Mawson",};
80              
81             sub new {
82 6     6 1 20 my $class = shift;
83 6         12 my $number = shift;
84 6         34 $number =~ s/(^\+672|\D)//g;
85 6         38 my $self = bless({ country_code => '672', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
86 6 100       48 return $self if ($self->is_valid());
87 3         32 my $prefix = qr/^(?:([0-258]\d{4})$)/;
88 3         18 my @matches = $number =~ /$prefix/;
89 3 50       12 if (defined $matches[-1]) {
90 2     2   650 no warnings 'uninitialized';
  2         20  
  2         389  
91 0         0 $number =~ s/$prefix/3$1/;
92             }
93             else {
94 3         10 $number =~ s/$prefix//;
95             }
96 3         35 $self = bless({ country_code => '672', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
97 3 50       13 return $self->is_valid() ? $self : undef;
98             }
99             1;