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