File Coverage

blib/lib/Number/Phone/StubCountry/KP.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::KP;
20 2     2   1245 use base qw(Number::Phone::StubCountry);
  2         6  
  2         270  
21              
22 2     2   20 use strict;
  2         7  
  2         50  
23 2     2   13 use warnings;
  2         6  
  2         54  
24 2     2   11 use utf8;
  2         5  
  2         22  
25             our $VERSION = 1.20230307181421;
26              
27             my $formatters = [
28             {
29             'format' => '$1 $2 $3',
30             'leading_digits' => '8',
31             'national_rule' => '0$1',
32             'pattern' => '(\\d{2})(\\d{3})(\\d{3})'
33             },
34             {
35             'format' => '$1 $2 $3',
36             'leading_digits' => '[2-7]',
37             'national_rule' => '0$1',
38             'pattern' => '(\\d)(\\d{3})(\\d{4})'
39             },
40             {
41             'format' => '$1 $2 $3',
42             'leading_digits' => '1',
43             'national_rule' => '0$1',
44             'pattern' => '(\\d{3})(\\d{3})(\\d{4})'
45             }
46             ];
47              
48             my $validators = {
49             'fixed_line' => '
50             (?:
51             (?:
52             195|
53             2
54             )\\d|
55             3[19]|
56             4[159]|
57             5[37]|
58             6[17]|
59             7[39]|
60             85
61             )\\d{6}
62             ',
63             'geographic' => '
64             (?:
65             (?:
66             195|
67             2
68             )\\d|
69             3[19]|
70             4[159]|
71             5[37]|
72             6[17]|
73             7[39]|
74             85
75             )\\d{6}
76             ',
77             'mobile' => '19[1-3]\\d{7}',
78             'pager' => '',
79             'personal_number' => '',
80             'specialrate' => '',
81             'toll_free' => '',
82             'voip' => ''
83             };
84             my %areanames = ();
85             $areanames{en} = {"85079", "Hyesan",
86             "85049", "Kaesong",
87             "85031", "Pyongyang",
88             "85045", "Haeju",
89             "85067", "Kanggye",
90             "85041", "Sariwon",
91             "85027", "Pyongyang",
92             "85039", "Nampo",
93             "85057", "Wonsan",
94             "8502381", "Pyongyang",
95             "85073", "Chongjin",
96             "850195", "Pyongyang",
97             "85053", "Hamhung",
98             "85028", "Pyongyang",
99             "85021", "Pyongyang",
100             "85061", "Sinuiju",
101             "8508", "Rason",};
102              
103             sub new {
104 7     7 1 19 my $class = shift;
105 7         19 my $number = shift;
106 7         43 $number =~ s/(^\+850|\D)//g;
107 7         36 my $self = bless({ country_code => '850', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
108 7 100       33 return $self if ($self->is_valid());
109 1         16 $number =~ s/^(?:0)//;
110 1         12 $self = bless({ country_code => '850', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
111 1 50       5 return $self->is_valid() ? $self : undef;
112             }
113             1;