line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Number::Phone::StubCountry; |
2
|
|
|
|
|
|
|
|
3
|
34
|
|
|
34
|
|
12886
|
use strict; |
|
34
|
|
|
|
|
79
|
|
|
34
|
|
|
|
|
1069
|
|
4
|
34
|
|
|
34
|
|
173
|
use warnings; |
|
34
|
|
|
|
|
74
|
|
|
34
|
|
|
|
|
1127
|
|
5
|
34
|
|
|
34
|
|
258
|
use Number::Phone::Country qw(noexport); |
|
34
|
|
|
|
|
65
|
|
|
34
|
|
|
|
|
247
|
|
6
|
|
|
|
|
|
|
|
7
|
34
|
|
|
34
|
|
1926
|
use I18N::LangTags::Detect; |
|
34
|
|
|
|
|
213687
|
|
|
34
|
|
|
|
|
1135
|
|
8
|
34
|
|
|
34
|
|
240
|
use I18N::LangTags; |
|
34
|
|
|
|
|
75
|
|
|
34
|
|
|
|
|
1201
|
|
9
|
|
|
|
|
|
|
|
10
|
34
|
|
|
34
|
|
501
|
use base qw(Number::Phone); |
|
34
|
|
|
|
|
78
|
|
|
34
|
|
|
|
|
29260
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.5001'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Number::Phone::StubCountry - Base class for auto-generated country files |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub country_code { |
20
|
310
|
|
|
310
|
1
|
9087
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
310
|
|
|
|
|
7021
|
return $self->{country_code}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub country { |
26
|
4190
|
|
|
4190
|
1
|
861765
|
my $self = shift; |
27
|
4190
|
100
|
|
|
|
10458
|
if(exists($self->{country})) { return $self->{country}; } |
|
2062
|
|
|
|
|
7139
|
|
28
|
2128
|
|
|
|
|
15828
|
ref($self)=~ /::(\w+?)$/; |
29
|
2128
|
|
|
|
|
10150
|
return $self->{country} = $1; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub raw_number { |
33
|
21387
|
|
|
21387
|
0
|
30956
|
my $self = shift; |
34
|
21387
|
|
|
|
|
1291024
|
$self->{number}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub is_valid { |
38
|
5486
|
|
|
5486
|
1
|
10909
|
my $self = shift; |
39
|
5486
|
100
|
|
|
|
16951
|
if(exists($self->{is_valid})) { |
40
|
26
|
|
|
|
|
131
|
return $self->{is_valid}; |
41
|
|
|
|
|
|
|
} |
42
|
5460
|
|
|
|
|
11453
|
foreach (map { "is_$_" } qw(specialrate geographic mobile pager tollfree personal ipphone)) { |
|
38220
|
|
|
|
|
89451
|
|
43
|
21836
|
100
|
|
|
|
85201
|
return $self->{is_valid} = 1 if($self->$_()); |
44
|
|
|
|
|
|
|
} |
45
|
1258
|
|
|
|
|
12319
|
return $self->{is_valid} = 0; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
4705
|
|
|
4705
|
1
|
16548
|
sub is_geographic { shift()->_validator('geographic'); } |
49
|
766
|
|
|
766
|
1
|
308322
|
sub is_fixed_line { shift()->_validator('fixed_line'); } |
50
|
4241
|
|
|
4241
|
1
|
323218
|
sub is_mobile { shift()->_validator('mobile'); } |
51
|
2643
|
|
|
2643
|
1
|
34953
|
sub is_pager { shift()->_validator('pager'); } |
52
|
2025
|
|
|
2025
|
1
|
80996
|
sub is_personal { shift()->_validator('personal_number'); } |
53
|
6273
|
|
|
6273
|
1
|
331631
|
sub is_specialrate { shift()->_validator('specialrate'); } |
54
|
3052
|
|
|
3052
|
1
|
231467
|
sub is_tollfree { shift()->_validator('toll_free'); } |
55
|
1897
|
|
|
1897
|
1
|
120443
|
sub is_ipphone { shift()->_validator('voip'); } |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _validator { |
58
|
25602
|
|
|
25602
|
|
49256
|
my($self, $validator) = @_; |
59
|
25602
|
|
|
|
|
50185
|
$validator = $self->{validators}->{$validator}; |
60
|
25602
|
100
|
|
|
|
55371
|
return undef unless($validator); |
61
|
21279
|
100
|
|
|
|
44731
|
return $self->raw_number() =~ /^($validator)$/x ? 1 : 0; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub areaname { |
65
|
26
|
|
|
26
|
1
|
944
|
my $self = shift; |
66
|
26
|
|
|
|
|
68
|
my @languages = @_; |
67
|
26
|
100
|
|
|
|
83
|
if(!@languages) { # nothing specifically asked for? use the locale |
68
|
17
|
|
|
|
|
69
|
@languages = I18N::LangTags::implicate_supers(I18N::LangTags::Detect::detect()); |
69
|
17
|
100
|
|
|
|
2995
|
if(!grep { $_ eq 'en' } @languages) { |
|
10
|
|
|
|
|
38
|
|
70
|
|
|
|
|
|
|
# and fall back to English |
71
|
15
|
|
|
|
|
45
|
push @languages, 'en' |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
26
|
|
|
|
|
84
|
my $number = $self->raw_number(); |
75
|
26
|
|
|
|
|
68
|
LANGUAGE: foreach my $language (@languages) { |
76
|
32
|
100
|
|
|
|
100
|
next LANGUAGE unless(exists($self->{areanames}->{$language})); |
77
|
24
|
|
|
|
|
43
|
my %map = %{$self->{areanames}->{$language}}; |
|
24
|
|
|
|
|
27220
|
|
78
|
24
|
|
|
|
|
2727
|
foreach my $prefix (map { substr($number, 0, $_) } reverse(1..length($number))) { |
|
197
|
|
|
|
|
427
|
|
79
|
164
|
100
|
|
|
|
345
|
return $map{$self->country_code().$prefix} if exists($map{$self->country_code().$prefix}); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
3
|
|
|
|
|
26
|
return undef; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub format { |
86
|
80
|
|
|
80
|
1
|
920
|
my $self = shift; |
87
|
80
|
|
|
|
|
229
|
my $number = $self->raw_number(); |
88
|
80
|
|
|
|
|
148
|
foreach my $formatter (@{$self->{formatters}}) { |
|
80
|
|
|
|
|
243
|
|
89
|
438
|
|
|
|
|
905
|
my($leading_digits, $pattern) = map { $formatter->{$_} } qw(leading_digits pattern); |
|
876
|
|
|
|
|
2122
|
|
90
|
438
|
100
|
100
|
|
|
15233
|
if((!$leading_digits || $number =~ /^($leading_digits)/x) && $number =~ /^$pattern$/x) { |
|
|
|
100
|
|
|
|
|
91
|
79
|
|
|
|
|
1030
|
my @bits = $number =~ /^$pattern$/x; |
92
|
79
|
|
|
|
|
436
|
return join(' ', '+'.$self->country_code(), @bits); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
# if there's no formatters defined ... |
96
|
1
|
|
|
|
|
17
|
return '+'.$self->country_code().' '.$number; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |