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   1192 use base qw(Number::Phone::StubCountry);
  2         7  
  2         232  
21              
22 2     2   20 use strict;
  2         10  
  2         47  
23 2     2   14 use warnings;
  2         13  
  2         52  
24 2     2   16 use utf8;
  2         11  
  2         13  
25             our $VERSION = 1.20230307181422;
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 35 my $class = shift;
68 13         27 my $number = shift;
69 13         89 $number =~ s/(^\+250|\D)//g;
70 13         73 my $self = bless({ country_code => '250', number => $number, formatters => $formatters, validators => $validators, }, $class);
71 13 100       63 return $self if ($self->is_valid());
72 1         3 $number =~ s/^(?:0)//;
73 1         11 $self = bless({ country_code => '250', number => $number, formatters => $formatters, validators => $validators, }, $class);
74 1 50       6 return $self->is_valid() ? $self : undef;
75             }
76             1;