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   1207 use base qw(Number::Phone::StubCountry);
  2         9  
  2         229  
21              
22 2     2   19 use strict;
  2         5  
  2         45  
23 2     2   16 use warnings;
  2         6  
  2         50  
24 2     2   17 use utf8;
  2         12  
  2         20  
25             our $VERSION = 1.20230307181423;
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} = {"68568", "Apia",
80             "6855", "Savaii",
81             "68565", "Apia",
82             "68564", "Apia",
83             "6854", "Upolu\ Rural",
84             "68562", "Apia",
85             "68561", "Apia",
86             "68569", "Apia",
87             "6853", "Apia",
88             "68567", "Apia",
89             "6852", "Apia",
90             "68563", "Apia",
91             "68566", "Apia",};
92              
93             sub new {
94 10     10 1 34 my $class = shift;
95 10         18 my $number = shift;
96 10         61 $number =~ s/(^\+685|\D)//g;
97 10         58 my $self = bless({ country_code => '685', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
98 10 100       53 return $self->is_valid() ? $self : undef;
99             }
100             1;