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