File Coverage

blib/lib/Number/Phone/StubCountry/DZ.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::DZ;
20 2     2   1254 use base qw(Number::Phone::StubCountry);
  2         7  
  2         277  
21              
22 2     2   21 use strict;
  2         11  
  2         53  
23 2     2   18 use warnings;
  2         6  
  2         61  
24 2     2   15 use utf8;
  2         11  
  2         17  
25             our $VERSION = 1.20230903131447;
26              
27             my $formatters = [
28             {
29             'format' => '$1 $2 $3 $4',
30             'leading_digits' => '[1-4]',
31             'national_rule' => '0$1',
32             'pattern' => '(\\d{2})(\\d{2})(\\d{2})(\\d{2})'
33             },
34             {
35             'format' => '$1 $2 $3 $4',
36             'leading_digits' => '9',
37             'national_rule' => '0$1',
38             'pattern' => '(\\d{2})(\\d{3})(\\d{2})(\\d{2})'
39             },
40             {
41             'format' => '$1 $2 $3 $4',
42             'leading_digits' => '[5-8]',
43             'national_rule' => '0$1',
44             'pattern' => '(\\d{3})(\\d{2})(\\d{2})(\\d{2})'
45             }
46             ];
47              
48             my $validators = {
49             'fixed_line' => '
50             9619\\d{5}|
51             (?:
52             1\\d|
53             2[013-79]|
54             3[0-8]|
55             4[013-689]
56             )\\d{6}
57             ',
58             'geographic' => '
59             9619\\d{5}|
60             (?:
61             1\\d|
62             2[013-79]|
63             3[0-8]|
64             4[013-689]
65             )\\d{6}
66             ',
67             'mobile' => '
68             (?:
69             5(?:
70             4[0-29]|
71             5\\d|
72             6[0-2]
73             )|
74             6(?:
75             [569]\\d|
76             7[0-6]
77             )|
78             7[7-9]\\d
79             )\\d{6}
80             ',
81             'pager' => '',
82             'personal_number' => '',
83             'specialrate' => '(80[12]1\\d{5})|(80[3-689]1\\d{5})',
84             'toll_free' => '800\\d{6}',
85             'voip' => '98[23]\\d{6}'
86             };
87             my %areanames = ();
88             $areanames{en} = {"21338", "Annaba\/Skikda",
89             "21343", "Tlemcen",
90             "21332", "El\ Oued",
91             "21333", "Batna\/Beskra",
92             "21349", "Adrar\/Béchar\/Tindouf",
93             "21341", "Oran",
94             "21321", "Algiers",
95             "21331", "Constantine",
96             "21329", "Ghardaia\/Illizi\/Tamanrasset",
97             "21335", "Bordj\ Bou\ Arreridj",
98             "21337", "Tebessa",
99             "21327", "Chlef",
100             "21334", "Béjaïa\/Jijel",
101             "21344", "Blida",};
102              
103             sub new {
104 19     19 1 58 my $class = shift;
105 19         34 my $number = shift;
106 19         121 $number =~ s/(^\+213|\D)//g;
107 19         137 my $self = bless({ country_code => '213', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
108 19 100       96 return $self if ($self->is_valid());
109 1         3 $number =~ s/^(?:0)//;
110 1         13 $self = bless({ country_code => '213', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
111 1 50       7 return $self->is_valid() ? $self : undef;
112             }
113             1;