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   1245 use base qw(Number::Phone::StubCountry);
  2         6  
  2         238  
21              
22 2     2   18 use strict;
  2         7  
  2         49  
23 2     2   10 use warnings;
  2         5  
  2         54  
24 2     2   16 use utf8;
  2         13  
  2         14  
25             our $VERSION = 1.20230614174404;
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} = {"9437", "Kurunegala",
97             "9465", "Batticaloa",
98             "9491", "Galle",
99             "9431", "Negombo\,\ Gampaha",
100             "9424", "Vavuniya",
101             "9455", "Badulla",
102             "9435", "Kegalle",
103             "9467", "Kalmunai\,\ Ampara",
104             "9423", "Mannar",
105             "9451", "Hatton\,\ Nuwara\ Eliya",
106             "9457", "Bandarawela\,\ Badulla",
107             "9426", "Trincomalee",
108             "9482", "Kandy",
109             "9445", "Ratnapura",
110             "9434", "Kalutara",
111             "9421", "Jaffna",
112             "9411", "Colombo",
113             "9466", "Matale",
114             "9432", "Chilaw\,\ Puttalam",
115             "9427", "Polonnaruwa",
116             "9463", "Ampara",
117             "9436", "Avissawella\,\ Colombo",
118             "9447", "Hambantota",
119             "9452", "Nuwara\ Eliya",
120             "9441", "Matara",
121             "9438", "Panadura\,\ Kalutara",
122             "9433", "Gampaha",
123             "9425", "Anuradhapura",
124             "9454", "Nawalapitiya\,\ Kandy",};
125              
126             sub new {
127 10     10 1 26 my $class = shift;
128 10         22 my $number = shift;
129 10         71 $number =~ s/(^\+94|\D)//g;
130 10         64 my $self = bless({ country_code => '94', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
131 10 100       54 return $self if ($self->is_valid());
132 1         3 $number =~ s/^(?:0)//;
133 1         20 $self = bless({ country_code => '94', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
134 1 50       13 return $self->is_valid() ? $self : undef;
135             }
136             1;