File Coverage

blib/lib/Number/Phone/StubCountry/SA.pm
Criterion Covered Total %
statement 20 20 100.0
branch 3 4 75.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 29 30 96.6


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::SA;
20 2     2   1352 use base qw(Number::Phone::StubCountry);
  2         6  
  2         254  
21              
22 2     2   24 use strict;
  2         4  
  2         58  
23 2     2   20 use warnings;
  2         4  
  2         60  
24 2     2   14 use utf8;
  2         6  
  2         13  
25             our $VERSION = 1.20230614174404;
26              
27             my $formatters = [
28             {
29             'format' => '$1 $2',
30             'leading_digits' => '9',
31             'pattern' => '(\\d{4})(\\d{5})'
32             },
33             {
34             'format' => '$1 $2 $3',
35             'leading_digits' => '1',
36             'national_rule' => '0$1',
37             'pattern' => '(\\d{2})(\\d{3})(\\d{4})'
38             },
39             {
40             'format' => '$1 $2 $3',
41             'leading_digits' => '5',
42             'national_rule' => '0$1',
43             'pattern' => '(\\d{2})(\\d{3})(\\d{4})'
44             },
45             {
46             'format' => '$1 $2 $3',
47             'leading_digits' => '81',
48             'national_rule' => '0$1',
49             'pattern' => '(\\d{3})(\\d{3})(\\d{3,4})'
50             },
51             {
52             'format' => '$1 $2 $3',
53             'leading_digits' => '8',
54             'pattern' => '(\\d{3})(\\d{3})(\\d{4})'
55             }
56             ];
57              
58             my $validators = {
59             'fixed_line' => '
60             1(?:
61             1\\d|
62             2[24-8]|
63             3[35-8]|
64             4[3-68]|
65             6[2-5]|
66             7[235-7]
67             )\\d{6}
68             ',
69             'geographic' => '
70             1(?:
71             1\\d|
72             2[24-8]|
73             3[35-8]|
74             4[3-68]|
75             6[2-5]|
76             7[235-7]
77             )\\d{6}
78             ',
79             'mobile' => '
80             579[01]\\d{5}|
81             5(?:
82             [013-689]\\d|
83             7[0-35-8]
84             )\\d{6}
85             ',
86             'pager' => '',
87             'personal_number' => '',
88             'specialrate' => '(920\\d{6})|(925\\d{6})|(811\\d{7})',
89             'toll_free' => '800\\d{7}',
90             'voip' => ''
91             };
92             my %areanames = ();
93             $areanames{ar} = {"96617", "أبها\/نجران\/جازان",
94             "96613", "الدمام\/الخبر\/الظهران",
95             "96614", "المدينة\ المنورة\/عرعر\/تبوك\/ينبع\ البحر",
96             "96612", "مكة\/جدة",
97             "96611", "الرياض\/الخرج",
98             "96616", "حائل\/القصيم",};
99             $areanames{en} = {"96616", "Hail\/Qasim",
100             "96611", "Riyadh\/Kharj",
101             "96613", "Dammam\/Khobar\/Dahran",
102             "96614", "Madenah\/Arar\/Tabuk\/Yanbu",
103             "96612", "Makkah\/Jeddah",
104             "96617", "Abha\/Najran\/Jezan",};
105              
106             sub new {
107 19     19 1 49 my $class = shift;
108 19         36 my $number = shift;
109 19         155 $number =~ s/(^\+966|\D)//g;
110 19         116 my $self = bless({ country_code => '966', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
111 19 100       99 return $self if ($self->is_valid());
112 1         4 $number =~ s/^(?:0)//;
113 1         11 $self = bless({ country_code => '966', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
114 1 50       8 return $self->is_valid() ? $self : undef;
115             }
116             1;