File Coverage

blib/lib/Number/Phone/StubCountry/EC.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::EC;
20 2     2   1159 use base qw(Number::Phone::StubCountry);
  2         11  
  2         223  
21              
22 2     2   26 use strict;
  2         5  
  2         50  
23 2     2   16 use warnings;
  2         6  
  2         66  
24 2     2   19 use utf8;
  2         9  
  2         13  
25             our $VERSION = 1.20230903131447;
26              
27             my $formatters = [
28             {
29             'format' => '$1-$2',
30             'intl_format' => 'NA',
31             'leading_digits' => '[2-7]',
32             'pattern' => '(\\d{3})(\\d{4})'
33             },
34             {
35             'format' => '$1 $2-$3',
36             'intl_format' => '$1-$2-$3',
37             'leading_digits' => '[2-7]',
38             'national_rule' => '(0$1)',
39             'pattern' => '(\\d)(\\d{3})(\\d{4})'
40             },
41             {
42             'format' => '$1 $2 $3',
43             'leading_digits' => '9',
44             'national_rule' => '0$1',
45             'pattern' => '(\\d{2})(\\d{3})(\\d{4})'
46             },
47             {
48             'format' => '$1 $2 $3',
49             'leading_digits' => '1',
50             'pattern' => '(\\d{4})(\\d{3})(\\d{3,4})'
51             }
52             ];
53              
54             my $validators = {
55             'fixed_line' => '[2-7][2-7]\\d{6}',
56             'geographic' => '[2-7][2-7]\\d{6}',
57             'mobile' => '
58             964[0-2]\\d{5}|
59             9(?:
60             39|
61             [57][89]|
62             6[0-36-9]|
63             [89]\\d
64             )\\d{6}
65             ',
66             'pager' => '',
67             'personal_number' => '',
68             'specialrate' => '',
69             'toll_free' => '
70             1800\\d{7}|
71             1[78]00\\d{6}
72             ',
73             'voip' => '[2-7]890\\d{4}'
74             };
75             my %areanames = ();
76             $areanames{en} = {"59327", "Azuay\/Cañar\/Morona\ Santiago",
77             "59347", "Loja\/El\ Oro\/Zamora\ Chinchipe",
78             "59344", "Guayas",
79             "59323", "Cotopaxi\/Tungurahua\/Chimborazo\/Bolívar\/Pastaza",
80             "59326", "Carchi\/Imbabura\/Esmeraldas\/Sucumbíos\/Napo\/Orellana",
81             "59322", "Pichincha",
82             "59345", "Manabí\/Los\ Ríos\/Galápagos",};
83              
84             sub new {
85 13     13 1 30 my $class = shift;
86 13         23 my $number = shift;
87 13         83 $number =~ s/(^\+593|\D)//g;
88 13         105 my $self = bless({ country_code => '593', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
89 13 100       61 return $self if ($self->is_valid());
90 1         3 $number =~ s/^(?:0)//;
91 1         10 $self = bless({ country_code => '593', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
92 1 50       4 return $self->is_valid() ? $self : undef;
93             }
94             1;