File Coverage

blib/lib/Number/Phone/StubCountry/SZ.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::SZ;
20 2     2   1079 use base qw(Number::Phone::StubCountry);
  2         8  
  2         207  
21              
22 2     2   17 use strict;
  2         8  
  2         46  
23 2     2   13 use warnings;
  2         19  
  2         54  
24 2     2   12 use utf8;
  2         6  
  2         31  
25             our $VERSION = 1.20230307181422;
26              
27             my $formatters = [
28             {
29             'format' => '$1 $2',
30             'leading_digits' => '[0237]',
31             'pattern' => '(\\d{4})(\\d{4})'
32             },
33             {
34             'format' => '$1 $2',
35             'leading_digits' => '9',
36             'pattern' => '(\\d{5})(\\d{4})'
37             }
38             ];
39              
40             my $validators = {
41             'fixed_line' => '[23][2-5]\\d{6}',
42             'geographic' => '[23][2-5]\\d{6}',
43             'mobile' => '7[6-9]\\d{6}',
44             'pager' => '',
45             'personal_number' => '',
46             'specialrate' => '(900\\d{6})',
47             'toll_free' => '0800\\d{4}',
48             'voip' => '70\\d{6}'
49             };
50             my %areanames = ();
51             $areanames{en} = {"2682344", "Siphofaneni\,\ Lubombo\ district",
52             "2682382", "Simunye\,\ Lubombo\ district",
53             "2682322", "Tshaneni\,\ Lubombo\ district",
54             "2682364", "Big\ Bend\,\ Lubombo\ district",
55             "26833", "Lubombo",
56             "2682538", "Mankayane\,\ Manzini\ district",
57             "2682343", "Siteki\,\ Lubombo\ district",
58             "2682207", "Nhlangano\,\ Shiselweni\ district",
59             "2682303", "Nsoko\,\ Lubombo\ district",
60             "2682528", "Malkerns\,\ Manzini\ district",
61             "2682363", "Big\ Bend\,\ Lubombo\ district",
62             "2682404", "Mbabane\,\ Hhohho\ district",
63             "2682437", "Pigg\'s\ Peak\,\ Hhohho\ district",
64             "2682505", "Manzini",
65             "26834", "Hhohho",
66             "2682472", "Mahwalala\,\ Hhohho\ district",
67             "2682422", "Sidwashini\,\ Hhohho\ district",
68             "2682518", "Matsapha\,\ Manzini\ district",
69             "2682482", "Siphocosini\,\ Hhohho\ district",
70             "2682452", "Bhunya\,\ Hhohho\ district",
71             "2682406", "Mbabane\,\ Hhohho\ district",
72             "2682312", "Mhlume\,\ Lubombo\ district",
73             "2682442", "Ngwenya\,\ Hhohho\ district",
74             "2682453", "Bhunya\,\ Hhohho\ district",
75             "2682467", "Mhlambanyatsi\,\ Hhohho\ district",
76             "2682217", "Hlathikulu\,\ Shiselweni\ district",
77             "2682313", "Mhlume\,\ Lubombo\ district",
78             "2682517", "Matsapha\,\ Manzini\ district",
79             "2682548", "Ludzeludze\,\ Manzini\ district",
80             "2682405", "Mbabane\,\ Hhohho\ district",
81             "2682237", "Mahamba\,\ Shiselweni\ district",
82             "2682333", "Mpaka\,\ Lubombo\ district",
83             "2682383", "Simunye\,\ Lubombo\ district",
84             "26835", "Manzini",
85             "26832", "Shiselweni",
86             "2682323", "Tshaneni\,\ Lubombo\ district",
87             "2682373", "Maphiveni\,\ Lubombo\ district",
88             "2682227", "Hluthi\,\ Shiselweni\ district",
89             "2682506", "Manzini",
90             "2682416", "Lobamba\,\ Hhohho\ district",};
91              
92             sub new {
93 16     16 1 39 my $class = shift;
94 16         27 my $number = shift;
95 16         105 $number =~ s/(^\+268|\D)//g;
96 16         87 my $self = bless({ country_code => '268', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
97 16 100       77 return $self->is_valid() ? $self : undef;
98             }
99             1;