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   1164 use base qw(Number::Phone::StubCountry);
  2         8  
  2         250  
21              
22 2     2   23 use strict;
  2         9  
  2         48  
23 2     2   26 use warnings;
  2         6  
  2         54  
24 2     2   13 use utf8;
  2         7  
  2         17  
25             our $VERSION = 1.20230307181421;
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             528|
40             625
41             )\\d{4}
42             ',
43             'geographic' => '
44             (?:
45             247|
46             528|
47             625
48             )\\d{4}
49             ',
50             'mobile' => '
51             (?:
52             (?:
53             23|
54             54
55             )5|
56             329|
57             45[356]
58             )\\d{4}
59             ',
60             'pager' => '',
61             'personal_number' => '',
62             'specialrate' => '',
63             'toll_free' => '',
64             'voip' => '635\\d{4}'
65             };
66              
67             sub new {
68 10     10 1 29 my $class = shift;
69 10         18 my $number = shift;
70 10         60 $number =~ s/(^\+692|\D)//g;
71 10         51 my $self = bless({ country_code => '692', number => $number, formatters => $formatters, validators => $validators, }, $class);
72 10 100       45 return $self if ($self->is_valid());
73 1         4 $number =~ s/^(?:1)//;
74 1         11 $self = bless({ country_code => '692', number => $number, formatters => $formatters, validators => $validators, }, $class);
75 1 50       10 return $self->is_valid() ? $self : undef;
76             }
77             1;