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   1200 use base qw(Number::Phone::StubCountry);
  2         6  
  2         231  
21              
22 2     2   17 use strict;
  2         6  
  2         55  
23 2     2   13 use warnings;
  2         5  
  2         60  
24 2     2   14 use utf8;
  2         6  
  2         13  
25             our $VERSION = 1.20230614174404;
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} = {"371654", "Daugavpils",
64             "371659", "Cēsis",
65             "371655", "Ogre",
66             "371647", "Valka",
67             "371642", "Valmiera",
68             "371639", "Bauska",
69             "371635", "Ventspils",
70             "371634", "Liepaja",
71             "371640", "Limbaži",
72             "371641", "Cēsis",
73             "371652", "Jēkabpils",
74             "371637", "Dobele",
75             "371632", "Talsi",
76             "371657", "Ludza",
77             "371649", "Aizkraukle",
78             "371645", "Balvi",
79             "371644", "Gulbene",
80             "371651", "Aizkraukle",
81             "37167", "Riga",
82             "371630", "Jelgava",
83             "371650", "Ogre",
84             "371631", "Tukums",
85             "371682", "Valmiera",
86             "371648", "Madona",
87             "37166", "Riga",
88             "371684", "Liepāja",
89             "371638", "Saldus",
90             "371658", "Daugavpils",
91             "37169", "Riga",
92             "371686", "Jelgava",
93             "371643", "Alūksne",
94             "371633", "Kuldiga",
95             "371653", "Preiļi",
96             "37161", "Jūrmala",
97             "371646", "Rēzekne",
98             "371683", "Jēkabpils",
99             "37162", "Valmiera",
100             "371656", "Krāslava",
101             "371636", "Ventspils",};
102              
103             sub new {
104 16     16 1 36 my $class = shift;
105 16         27 my $number = shift;
106 16         108 $number =~ s/(^\+371|\D)//g;
107 16         91 my $self = bless({ country_code => '371', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
108 16 100       82 return $self->is_valid() ? $self : undef;
109             }
110             1;