File Coverage

blib/lib/Number/Phone/StubCountry/LV.pm
Criterion Covered Total %
statement 17 17 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 25 25 100.0


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::LV;
20 2     2   1156 use base qw(Number::Phone::StubCountry);
  2         5  
  2         239  
21              
22 2     2   15 use strict;
  2         4  
  2         50  
23 2     2   11 use warnings;
  2         6  
  2         49  
24 2     2   12 use utf8;
  2         6  
  2         15  
25             our $VERSION = 1.20230307181421;
26              
27             my $formatters = [
28             {
29             'format' => '$1 $2 $3',
30             'leading_digits' => '
31             [269]|
32             8[01]
33             ',
34             'pattern' => '(\\d{2})(\\d{3})(\\d{3})'
35             }
36             ];
37              
38             my $validators = {
39             'fixed_line' => '6\\d{7}',
40             'geographic' => '6\\d{7}',
41             'mobile' => '
42             23(?:
43             23[0-57-9]|
44             33[0238]
45             )\\d{3}|
46             2(?:
47             [0-24-9]\\d\\d|
48             3(?:
49             0[07]|
50             [14-9]\\d|
51             2[024-9]|
52             3[0-24-9]
53             )
54             )\\d{4}
55             ',
56             'pager' => '',
57             'personal_number' => '',
58             'specialrate' => '(81\\d{6})|(90\\d{6})',
59             'toll_free' => '80\\d{6}',
60             'voip' => ''
61             };
62             my %areanames = ();
63             $areanames{en} = {"371644", "Gulbene",
64             "371640", "Limbaži",
65             "371659", "Cēsis",
66             "371651", "Aizkraukle",
67             "371646", "Rēzekne",
68             "37166", "Riga",
69             "371630", "Jelgava",
70             "371683", "Jēkabpils",
71             "371655", "Ogre",
72             "371634", "Liepaja",
73             "371636", "Ventspils",
74             "371682", "Valmiera",
75             "37169", "Riga",
76             "371653", "Preiļi",
77             "371658", "Daugavpils",
78             "371657", "Ludza",
79             "371652", "Jēkabpils",
80             "37167", "Riga",
81             "371650", "Ogre",
82             "371654", "Daugavpils",
83             "371635", "Ventspils",
84             "371649", "Aizkraukle",
85             "371641", "Cēsis",
86             "371656", "Krāslava",
87             "371633", "Kuldiga",
88             "371684", "Liepāja",
89             "371637", "Dobele",
90             "371686", "Jelgava",
91             "371632", "Talsi",
92             "371638", "Saldus",
93             "37162", "Valmiera",
94             "371645", "Balvi",
95             "37161", "Jūrmala",
96             "371631", "Tukums",
97             "371639", "Bauska",
98             "371643", "Alūksne",
99             "371648", "Madona",
100             "371647", "Valka",
101             "371642", "Valmiera",};
102              
103             sub new {
104 16     16 1 35 my $class = shift;
105 16         28 my $number = shift;
106 16         98 $number =~ s/(^\+371|\D)//g;
107 16         87 my $self = bless({ country_code => '371', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
108 16 100       74 return $self->is_valid() ? $self : undef;
109             }
110             1;