File Coverage

blib/lib/Number/Phone/StubCountry/XK.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::XK;
20 3     3   1634 use base qw(Number::Phone::StubCountry);
  3         11  
  3         322  
21              
22 3     3   23 use strict;
  3         10  
  3         67  
23 3     3   23 use warnings;
  3         10  
  3         95  
24 3     3   29 use utf8;
  3         7  
  3         20  
25             our $VERSION = 1.20230614174405;
26              
27             my $formatters = [
28             {
29             'format' => '$1 $2',
30             'leading_digits' => '[89]',
31             'national_rule' => '0$1',
32             'pattern' => '(\\d{3})(\\d{5})'
33             },
34             {
35             'format' => '$1 $2 $3',
36             'leading_digits' => '[2-4]',
37             'national_rule' => '0$1',
38             'pattern' => '(\\d{2})(\\d{3})(\\d{3})'
39             },
40             {
41             'format' => '$1 $2 $3',
42             'leading_digits' => '[23]',
43             'national_rule' => '0$1',
44             'pattern' => '(\\d{3})(\\d{3})(\\d{3})'
45             }
46             ];
47              
48             my $validators = {
49             'fixed_line' => '
50             (?:
51             2[89]|
52             39
53             )0\\d{6}|
54             [23][89]\\d{6}
55             ',
56             'geographic' => '
57             (?:
58             2[89]|
59             39
60             )0\\d{6}|
61             [23][89]\\d{6}
62             ',
63             'mobile' => '4[3-9]\\d{6}',
64             'pager' => '',
65             'personal_number' => '',
66             'specialrate' => '(900\\d{5})',
67             'toll_free' => '800\\d{5}',
68             'voip' => ''
69             };
70             my %areanames = ();
71             $areanames{en} = {"383390", "Gjakova",
72             "383280", "Gjilan",
73             "38328", "Mitrovica",
74             "38339", "Peja",
75             "38329", "Prizren",
76             "38338", "Prishtina",
77             "383290", "Ferizaj",};
78             $areanames{sq} = {"38338", "Prishtinë",
79             "383390", "Gjakovë",
80             "38339", "Pejë",
81             "38328", "Mitrovicë",};
82             $areanames{sr} = {"38339", "Пећ",
83             "38328", "Косовска\ Митровица",
84             "383390", "Ђаковица",
85             "383280", "Гњилане",
86             "383290", "Урошевац",
87             "38338", "Приштина",
88             "38329", "Призрен",};
89              
90             sub new {
91 19     19 1 55 my $class = shift;
92 19         45 my $number = shift;
93 19         133 $number =~ s/(^\+383|\D)//g;
94 19         158 my $self = bless({ country_code => '383', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
95 19 100       107 return $self if ($self->is_valid());
96 5         32 $number =~ s/^(?:0)//;
97 5         65 $self = bless({ country_code => '383', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
98 5 50       21 return $self->is_valid() ? $self : undef;
99             }
100             1;