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   1339 use base qw(Number::Phone::StubCountry);
  2         7  
  2         260  
21              
22 2     2   25 use strict;
  2         6  
  2         46  
23 2     2   15 use warnings;
  2         4  
  2         76  
24 2     2   16 use utf8;
  2         4  
  2         12  
25             our $VERSION = 1.20230307181420;
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} = {"59326", "Carchi\/Imbabura\/Esmeraldas\/Sucumbíos\/Napo\/Orellana",
77             "59327", "Azuay\/Cañar\/Morona\ Santiago",
78             "59322", "Pichincha",
79             "59347", "Loja\/El\ Oro\/Zamora\ Chinchipe",
80             "59344", "Guayas",
81             "59345", "Manabí\/Los\ Ríos\/Galápagos",
82             "59323", "Cotopaxi\/Tungurahua\/Chimborazo\/Bolívar\/Pastaza",};
83              
84             sub new {
85 13     13 1 35 my $class = shift;
86 13         28 my $number = shift;
87 13         105 $number =~ s/(^\+593|\D)//g;
88 13         95 my $self = bless({ country_code => '593', number => $number, formatters => $formatters, validators => $validators, areanames => \%areanames}, $class);
89 13 100       77 return $self if ($self->is_valid());
90 1         2 $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;