File Coverage

blib/lib/Number/Phone/StubCountry/MH.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::MH;
20 2     2   1198 use base qw(Number::Phone::StubCountry);
  2         6  
  2         237  
21              
22 2     2   16 use strict;
  2         9  
  2         47  
23 2     2   19 use warnings;
  2         9  
  2         74  
24 2     2   14 use utf8;
  2         7  
  2         12  
25             our $VERSION = 1.20230614174404;
26              
27             my $formatters = [
28             {
29             'format' => '$1-$2',
30             'leading_digits' => '[2-6]',
31             'pattern' => '(\\d{3})(\\d{4})'
32             }
33             ];
34              
35             my $validators = {
36             'fixed_line' => '
37             (?:
38             247|
39             45[78]|
40             528|
41             625
42             )\\d{4}
43             ',
44             'geographic' => '
45             (?:
46             247|
47             45[78]|
48             528|
49             625
50             )\\d{4}
51             ',
52             'mobile' => '
53             (?:
54             (?:
55             23|
56             54
57             )5|
58             329|
59             45[356]
60             )\\d{4}
61             ',
62             'pager' => '',
63             'personal_number' => '',
64             'specialrate' => '',
65             'toll_free' => '',
66             'voip' => '635\\d{4}'
67             };
68              
69             sub new {
70 10     10 1 24 my $class = shift;
71 10         23 my $number = shift;
72 10         62 $number =~ s/(^\+692|\D)//g;
73 10         60 my $self = bless({ country_code => '692', number => $number, formatters => $formatters, validators => $validators, }, $class);
74 10 100       62 return $self if ($self->is_valid());
75 1         4 $number =~ s/^(?:1)//;
76 1         10 $self = bless({ country_code => '692', number => $number, formatters => $formatters, validators => $validators, }, $class);
77 1 50       6 return $self->is_valid() ? $self : undef;
78             }
79             1;