File Coverage

blib/lib/Number/Phone/StubCountry/WS.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::WS;
20 2     2   1190 use base qw(Number::Phone::StubCountry);
  2         11  
  2         237  
21              
22 2     2   19 use strict;
  2         7  
  2         47  
23 2     2   10 use warnings;
  2         8  
  2         51  
24 2     2   40 use utf8;
  2         9  
  2         20  
25             our $VERSION = 1.20230903131449;
26              
27             my $formatters = [
28             {
29             'format' => '$1',
30             'leading_digits' => '
31             [2-5]|
32             6[1-9]
33             ',
34             'pattern' => '(\\d{5})'
35             },
36             {
37             'format' => '$1 $2',
38             'leading_digits' => '[68]',
39             'pattern' => '(\\d{3})(\\d{3,7})'
40             },
41             {
42             'format' => '$1 $2',
43             'leading_digits' => '7',
44             'pattern' => '(\\d{2})(\\d{5})'
45             }
46             ];
47              
48             my $validators = {
49             'fixed_line' => '
50             6[1-9]\\d{3}|
51             (?:
52             [2-5]|
53             60
54             )\\d{4}
55             ',
56             'geographic' => '
57             6[1-9]\\d{3}|
58             (?:
59             [2-5]|
60             60
61             )\\d{4}
62             ',
63             'mobile' => '
64             (?:
65             7[1-35-7]|
66             8(?:
67             [3-7]|
68             9\\d{3}
69             )
70             )\\d{5}
71             ',
72             'pager' => '',
73             'personal_number' => '',
74             'specialrate' => '',
75             'toll_free' => '800\\d{3}',
76             'voip' => ''
77             };
78             my %areanames = ();
79             $areanames{en} = {"68564", "Apia",
80             "68562", "Apia",
81             "6855", "Savaii",
82             "68563", "Apia",
83             "68561", "Apia",
84             "68569", "Apia",
85             "68568", "Apia",
86             "68565", "Apia",
87             "68566", "Apia",
88             "6852", "Apia",
89             "6853", "Apia",
90             "6854", "Upolu\ Rural",
91             "68567", "Apia",};
92              
93             sub new {
94 10     10 1 42 my $class = shift;
95 10         62 my $number = shift;
96 10         66 $number =~ s/(^\+685|\D)//g;
97 10         62 my $self = bless({ country_code => '685', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
98 10 100       56 return $self->is_valid() ? $self : undef;
99             }
100             1;