File Coverage

blib/lib/Number/Phone/StubCountry/RW.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::RW;
20 2     2   1270 use base qw(Number::Phone::StubCountry);
  2         5  
  2         272  
21              
22 2     2   24 use strict;
  2         6  
  2         60  
23 2     2   10 use warnings;
  2         6  
  2         60  
24 2     2   13 use utf8;
  2         5  
  2         12  
25             our $VERSION = 1.20230614174404;
26              
27             my $formatters = [
28             {
29             'format' => '$1 $2 $3 $4',
30             'pattern' => '(\\d{2})(\\d{2})(\\d{2})(\\d{2})'
31             },
32             {
33             'format' => '$1 $2 $3',
34             'leading_digits' => '[7-9]',
35             'national_rule' => '0$1',
36             'pattern' => '(\\d{3})(\\d{3})(\\d{3})'
37             },
38             {
39             'format' => '$1 $2 $3',
40             'leading_digits' => '2',
41             'pattern' => '(\\d{3})(\\d{3})(\\d{3})'
42             }
43             ];
44              
45             my $validators = {
46             'fixed_line' => '
47             (?:
48             06|
49             2[23568]\\d
50             )\\d{6}
51             ',
52             'geographic' => '
53             (?:
54             06|
55             2[23568]\\d
56             )\\d{6}
57             ',
58             'mobile' => '7[2389]\\d{7}',
59             'pager' => '',
60             'personal_number' => '',
61             'specialrate' => '(900\\d{6})',
62             'toll_free' => '800\\d{6}',
63             'voip' => ''
64             };
65              
66             sub new {
67 13     13 1 28 my $class = shift;
68 13         24 my $number = shift;
69 13         111 $number =~ s/(^\+250|\D)//g;
70 13         77 my $self = bless({ country_code => '250', number => $number, formatters => $formatters, validators => $validators, }, $class);
71 13 100       69 return $self if ($self->is_valid());
72 1         2 $number =~ s/^(?:0)//;
73 1         12 $self = bless({ country_code => '250', number => $number, formatters => $formatters, validators => $validators, }, $class);
74 1 50       4 return $self->is_valid() ? $self : undef;
75             }
76             1;