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   1254 use base qw(Number::Phone::StubCountry);
  2         11  
  2         251  
21              
22 2     2   15 use strict;
  2         7  
  2         57  
23 2     2   13 use warnings;
  2         11  
  2         54  
24 2     2   13 use utf8;
  2         9  
  2         17  
25             our $VERSION = 1.20230307181421;
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} = {"67210", "Davis",
77             "67212", "Casey",
78             "67211", "Mawson",
79             "67213", "Macquarie\ Island",};
80              
81             sub new {
82 6     6 1 23 my $class = shift;
83 6         18 my $number = shift;
84 6         44 $number =~ s/(^\+672|\D)//g;
85 6         42 my $self = bless({ country_code => '672', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
86 6 100       46 return $self if ($self->is_valid());
87 3         40 my $prefix = qr/^(?:([0-258]\d{4})$)/;
88 3         23 my @matches = $number =~ /$prefix/;
89 3 50       12 if (defined $matches[-1]) {
90 2     2   1461 no warnings 'uninitialized';
  2         13  
  2         355  
91 0         0 $number =~ s/$prefix/3$1/;
92             }
93             else {
94 3         15 $number =~ s/$prefix//;
95             }
96 3         37 $self = bless({ country_code => '672', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
97 3 50       12 return $self->is_valid() ? $self : undef;
98             }
99             1;