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   1201 use base qw(Number::Phone::StubCountry);
  2         19  
  2         236  
21              
22 2     2   28 use strict;
  2         9  
  2         51  
23 2     2   25 use warnings;
  2         7  
  2         52  
24 2     2   13 use utf8;
  2         7  
  2         16  
25             our $VERSION = 1.20230903131448;
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} = {"2682312", "Mhlume\,\ Lubombo\ district",
52             "2682227", "Hluthi\,\ Shiselweni\ district",
53             "2682373", "Maphiveni\,\ Lubombo\ district",
54             "2682506", "Manzini",
55             "2682482", "Siphocosini\,\ Hhohho\ district",
56             "2682505", "Manzini",
57             "26835", "Manzini",
58             "2682442", "Ngwenya\,\ Hhohho\ district",
59             "2682528", "Malkerns\,\ Manzini\ district",
60             "2682323", "Tshaneni\,\ Lubombo\ district",
61             "2682517", "Matsapha\,\ Manzini\ district",
62             "2682452", "Bhunya\,\ Hhohho\ district",
63             "2682382", "Simunye\,\ Lubombo\ district",
64             "2682472", "Mahwalala\,\ Hhohho\ district",
65             "2682217", "Hlathikulu\,\ Shiselweni\ district",
66             "2682303", "Nsoko\,\ Lubombo\ district",
67             "2682406", "Mbabane\,\ Hhohho\ district",
68             "2682322", "Tshaneni\,\ Lubombo\ district",
69             "2682344", "Siphofaneni\,\ Lubombo\ district",
70             "2682405", "Mbabane\,\ Hhohho\ district",
71             "2682538", "Mankayane\,\ Manzini\ district",
72             "2682437", "Pigg\'s\ Peak\,\ Hhohho\ district",
73             "2682467", "Mhlambanyatsi\,\ Hhohho\ district",
74             "2682453", "Bhunya\,\ Hhohho\ district",
75             "2682383", "Simunye\,\ Lubombo\ district",
76             "2682333", "Mpaka\,\ Lubombo\ district",
77             "26832", "Shiselweni",
78             "2682363", "Big\ Bend\,\ Lubombo\ district",
79             "26833", "Lubombo",
80             "2682404", "Mbabane\,\ Hhohho\ district",
81             "2682422", "Sidwashini\,\ Hhohho\ district",
82             "2682518", "Matsapha\,\ Manzini\ district",
83             "2682237", "Mahamba\,\ Shiselweni\ district",
84             "2682548", "Ludzeludze\,\ Manzini\ district",
85             "2682364", "Big\ Bend\,\ Lubombo\ district",
86             "2682343", "Siteki\,\ Lubombo\ district",
87             "26834", "Hhohho",
88             "2682207", "Nhlangano\,\ Shiselweni\ district",
89             "2682313", "Mhlume\,\ Lubombo\ district",
90             "2682416", "Lobamba\,\ Hhohho\ district",};
91              
92             sub new {
93 16     16 1 42 my $class = shift;
94 16         33 my $number = shift;
95 16         104 $number =~ s/(^\+268|\D)//g;
96 16         99 my $self = bless({ country_code => '268', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
97 16 100       84 return $self->is_valid() ? $self : undef;
98             }
99             1;