File Coverage

blib/lib/Number/Phone/StubCountry/LK.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::LK;
20 2     2   1175 use base qw(Number::Phone::StubCountry);
  2         22  
  2         238  
21              
22 2     2   23 use strict;
  2         9  
  2         45  
23 2     2   17 use warnings;
  2         9  
  2         57  
24 2     2   12 use utf8;
  2         6  
  2         14  
25             our $VERSION = 1.20230903131448;
26              
27             my $formatters = [
28             {
29             'format' => '$1 $2 $3',
30             'leading_digits' => '7',
31             'national_rule' => '0$1',
32             'pattern' => '(\\d{2})(\\d{3})(\\d{4})'
33             },
34             {
35             'format' => '$1 $2 $3',
36             'leading_digits' => '[1-689]',
37             'national_rule' => '0$1',
38             'pattern' => '(\\d{3})(\\d{3})(\\d{3})'
39             }
40             ];
41              
42             my $validators = {
43             'fixed_line' => '
44             (?:
45             12[2-9]|
46             602|
47             8[12]\\d|
48             9(?:
49             1\\d|
50             22|
51             9[245]
52             )
53             )\\d{6}|
54             (?:
55             11|
56             2[13-7]|
57             3[1-8]|
58             4[157]|
59             5[12457]|
60             6[35-7]
61             )[2-57]\\d{6}
62             ',
63             'geographic' => '
64             (?:
65             12[2-9]|
66             602|
67             8[12]\\d|
68             9(?:
69             1\\d|
70             22|
71             9[245]
72             )
73             )\\d{6}|
74             (?:
75             11|
76             2[13-7]|
77             3[1-8]|
78             4[157]|
79             5[12457]|
80             6[35-7]
81             )[2-57]\\d{6}
82             ',
83             'mobile' => '
84             7(?:
85             [0-25-8]\\d|
86             4[0-4]
87             )\\d{6}
88             ',
89             'pager' => '',
90             'personal_number' => '',
91             'specialrate' => '(1973\\d{5})',
92             'toll_free' => '',
93             'voip' => ''
94             };
95             my %areanames = ();
96             $areanames{en} = {"9435", "Kegalle",
97             "9447", "Hambantota",
98             "9451", "Hatton\,\ Nuwara\ Eliya",
99             "9463", "Ampara",
100             "9445", "Ratnapura",
101             "9434", "Kalutara",
102             "9421", "Jaffna",
103             "9437", "Kurunegala",
104             "9432", "Chilaw\,\ Puttalam",
105             "9441", "Matara",
106             "9455", "Badulla",
107             "9425", "Anuradhapura",
108             "9411", "Colombo",
109             "9427", "Polonnaruwa",
110             "9431", "Negombo\,\ Gampaha",
111             "9424", "Vavuniya",
112             "9452", "Nuwara\ Eliya",
113             "9438", "Panadura\,\ Kalutara",
114             "9457", "Bandarawela\,\ Badulla",
115             "9454", "Nawalapitiya\,\ Kandy",
116             "9466", "Matale",
117             "9465", "Batticaloa",
118             "9467", "Kalmunai\,\ Ampara",
119             "9426", "Trincomalee",
120             "9433", "Gampaha",
121             "9482", "Kandy",
122             "9423", "Mannar",
123             "9436", "Avissawella\,\ Colombo",
124             "9491", "Galle",};
125              
126             sub new {
127 10     10 1 28 my $class = shift;
128 10         22 my $number = shift;
129 10         65 $number =~ s/(^\+94|\D)//g;
130 10         56 my $self = bless({ country_code => '94', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
131 10 100       57 return $self if ($self->is_valid());
132 1         3 $number =~ s/^(?:0)//;
133 1         14 $self = bless({ country_code => '94', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
134 1 50       185 return $self->is_valid() ? $self : undef;
135             }
136             1;