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   1804 use base qw(Number::Phone::StubCountry);
  3         10  
  3         354  
21              
22 3     3   59 use strict;
  3         8  
  3         82  
23 3     3   16 use warnings;
  3         8  
  3         75  
24 3     3   15 use utf8;
  3         17  
  3         23  
25             our $VERSION = 1.20230307181423;
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} = {"38328", "Mitrovica",
72             "383280", "Gjilan",
73             "38339", "Peja",
74             "383390", "Gjakova",
75             "38338", "Prishtina",
76             "38329", "Prizren",
77             "383290", "Ferizaj",};
78             $areanames{sr} = {"38338", "Приштина",
79             "383290", "Урошевац",
80             "38329", "Призрен",
81             "383280", "Гњилане",
82             "38328", "Косовска\ Митровица",
83             "383390", "Ђаковица",
84             "38339", "Пећ",};
85             $areanames{sq} = {"38338", "Prishtinë",
86             "38328", "Mitrovicë",
87             "383390", "Gjakovë",
88             "38339", "Pejë",};
89              
90             sub new {
91 19     19 1 51 my $class = shift;
92 19         39 my $number = shift;
93 19         133 $number =~ s/(^\+383|\D)//g;
94 19         125 my $self = bless({ country_code => '383', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
95 19 100       97 return $self if ($self->is_valid());
96 5         30 $number =~ s/^(?:0)//;
97 5         62 $self = bless({ country_code => '383', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
98 5 50       28 return $self->is_valid() ? $self : undef;
99             }
100             1;