File Coverage

blib/lib/Number/Phone/StubCountry/CD.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::CD;
20 2     2   1334 use base qw(Number::Phone::StubCountry);
  2         6  
  2         261  
21              
22 2     2   17 use strict;
  2         7  
  2         54  
23 2     2   11 use warnings;
  2         5  
  2         62  
24 2     2   12 use utf8;
  2         7  
  2         15  
25             our $VERSION = 1.20230614174401;
26              
27             my $formatters = [
28             {
29             'format' => '$1 $2 $3',
30             'leading_digits' => '88',
31             'national_rule' => '0$1',
32             'pattern' => '(\\d{2})(\\d{2})(\\d{3})'
33             },
34             {
35             'format' => '$1 $2',
36             'leading_digits' => '[1-6]',
37             'national_rule' => '0$1',
38             'pattern' => '(\\d{2})(\\d{5})'
39             },
40             {
41             'format' => '$1 $2 $3',
42             'leading_digits' => '1',
43             'national_rule' => '0$1',
44             'pattern' => '(\\d{2})(\\d{3})(\\d{4})'
45             },
46             {
47             'format' => '$1 $2 $3',
48             'leading_digits' => '[89]',
49             'national_rule' => '0$1',
50             'pattern' => '(\\d{3})(\\d{3})(\\d{3})'
51             }
52             ];
53              
54             my $validators = {
55             'fixed_line' => '
56             12\\d{7}|
57             [1-6]\\d{6}
58             ',
59             'geographic' => '
60             12\\d{7}|
61             [1-6]\\d{6}
62             ',
63             'mobile' => '
64             88\\d{5}|
65             (?:
66             8[0-59]|
67             9[017-9]
68             )\\d{7}
69             ',
70             'pager' => '',
71             'personal_number' => '',
72             'specialrate' => '',
73             'toll_free' => '',
74             'voip' => ''
75             };
76             my %areanames = ();
77             $areanames{en} = {"2436", "North\ Kivu\/South\ Kivu\/Maniema",
78             "2434", "Kasai\-Oriental\/Kasai\-Occidental",
79             "2435", "Oriental\ Province\ \(Kisanga\/Mbandaka\)",
80             "2433", "Bas\-Congo\/Bandundu",
81             "2431", "Kinshasa",
82             "2432", "Katanga",};
83             $areanames{fr} = {"2435", "Province\ Orientale\ \(Kisanga\/Mbandaka\)",
84             "2436", "Nord\-Kivu\/Sud\-Kivu\/Maniema",};
85              
86             sub new {
87 7     7 1 18 my $class = shift;
88 7         16 my $number = shift;
89 7         43 $number =~ s/(^\+243|\D)//g;
90 7         43 my $self = bless({ country_code => '243', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
91 7 100       43 return $self if ($self->is_valid());
92 1         3 $number =~ s/^(?:0)//;
93 1         11 $self = bless({ country_code => '243', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
94 1 50       6 return $self->is_valid() ? $self : undef;
95             }
96             1;