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