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