line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Number::Phone::StubCountry; |
2
|
|
|
|
|
|
|
|
3
|
34
|
|
|
34
|
|
12448
|
use strict; |
|
34
|
|
|
|
|
76
|
|
|
34
|
|
|
|
|
1009
|
|
4
|
34
|
|
|
34
|
|
186
|
use warnings; |
|
34
|
|
|
|
|
70
|
|
|
34
|
|
|
|
|
1063
|
|
5
|
34
|
|
|
34
|
|
255
|
use Number::Phone::Country qw(noexport); |
|
34
|
|
|
|
|
65
|
|
|
34
|
|
|
|
|
271
|
|
6
|
|
|
|
|
|
|
|
7
|
34
|
|
|
34
|
|
1904
|
use I18N::LangTags::Detect; |
|
34
|
|
|
|
|
195586
|
|
|
34
|
|
|
|
|
1077
|
|
8
|
34
|
|
|
34
|
|
226
|
use I18N::LangTags; |
|
34
|
|
|
|
|
67
|
|
|
34
|
|
|
|
|
1200
|
|
9
|
|
|
|
|
|
|
|
10
|
34
|
|
|
34
|
|
540
|
use base qw(Number::Phone); |
|
34
|
|
|
|
|
85
|
|
|
34
|
|
|
|
|
28997
|
|
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
|
9452
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
310
|
|
|
|
|
7072
|
return $self->{country_code}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub country { |
26
|
4190
|
|
|
4190
|
1
|
896242
|
my $self = shift; |
27
|
4190
|
100
|
|
|
|
11902
|
if(exists($self->{country})) { return $self->{country}; } |
|
2062
|
|
|
|
|
7005
|
|
28
|
2128
|
|
|
|
|
15656
|
ref($self)=~ /::(\w+?)$/; |
29
|
2128
|
|
|
|
|
10190
|
return $self->{country} = $1; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub raw_number { |
33
|
21387
|
|
|
21387
|
0
|
30423
|
my $self = shift; |
34
|
21387
|
|
|
|
|
1266247
|
$self->{number}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub is_valid { |
38
|
5486
|
|
|
5486
|
1
|
11803
|
my $self = shift; |
39
|
5486
|
100
|
|
|
|
16198
|
if(exists($self->{is_valid})) { |
40
|
26
|
|
|
|
|
137
|
return $self->{is_valid}; |
41
|
|
|
|
|
|
|
} |
42
|
5460
|
|
|
|
|
12006
|
foreach (map { "is_$_" } qw(specialrate geographic mobile pager tollfree personal ipphone)) { |
|
38220
|
|
|
|
|
89202
|
|
43
|
21836
|
100
|
|
|
|
81607
|
return $self->{is_valid} = 1 if($self->$_()); |
44
|
|
|
|
|
|
|
} |
45
|
1258
|
|
|
|
|
12220
|
return $self->{is_valid} = 0; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
4705
|
|
|
4705
|
1
|
17397
|
sub is_geographic { shift()->_validator('geographic'); } |
49
|
766
|
|
|
766
|
1
|
313867
|
sub is_fixed_line { shift()->_validator('fixed_line'); } |
50
|
4241
|
|
|
4241
|
1
|
329995
|
sub is_mobile { shift()->_validator('mobile'); } |
51
|
2643
|
|
|
2643
|
1
|
34224
|
sub is_pager { shift()->_validator('pager'); } |
52
|
2025
|
|
|
2025
|
1
|
80604
|
sub is_personal { shift()->_validator('personal_number'); } |
53
|
6273
|
|
|
6273
|
1
|
336890
|
sub is_specialrate { shift()->_validator('specialrate'); } |
54
|
3052
|
|
|
3052
|
1
|
237264
|
sub is_tollfree { shift()->_validator('toll_free'); } |
55
|
1897
|
|
|
1897
|
1
|
124119
|
sub is_ipphone { shift()->_validator('voip'); } |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _validator { |
58
|
25602
|
|
|
25602
|
|
49534
|
my($self, $validator) = @_; |
59
|
25602
|
|
|
|
|
49191
|
$validator = $self->{validators}->{$validator}; |
60
|
25602
|
100
|
|
|
|
55786
|
return undef unless($validator); |
61
|
21279
|
100
|
|
|
|
43947
|
return $self->raw_number() =~ /^($validator)$/x ? 1 : 0; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub areaname { |
65
|
26
|
|
|
26
|
1
|
1088
|
my $self = shift; |
66
|
26
|
|
|
|
|
66
|
my @languages = @_; |
67
|
26
|
100
|
|
|
|
77
|
if(!@languages) { # nothing specifically asked for? use the locale |
68
|
17
|
|
|
|
|
74
|
@languages = I18N::LangTags::implicate_supers(I18N::LangTags::Detect::detect()); |
69
|
17
|
100
|
|
|
|
2884
|
if(!grep { $_ eq 'en' } @languages) { |
|
10
|
|
|
|
|
31
|
|
70
|
|
|
|
|
|
|
# and fall back to English |
71
|
15
|
|
|
|
|
37
|
push @languages, 'en' |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
26
|
|
|
|
|
79
|
my $number = $self->raw_number(); |
75
|
26
|
|
|
|
|
64
|
LANGUAGE: foreach my $language (@languages) { |
76
|
32
|
100
|
|
|
|
95
|
next LANGUAGE unless(exists($self->{areanames}->{$language})); |
77
|
24
|
|
|
|
|
36
|
my %map = %{$self->{areanames}->{$language}}; |
|
24
|
|
|
|
|
27621
|
|
78
|
24
|
|
|
|
|
2685
|
foreach my $prefix (map { substr($number, 0, $_) } reverse(1..length($number))) { |
|
197
|
|
|
|
|
462
|
|
79
|
164
|
100
|
|
|
|
335
|
return $map{$self->country_code().$prefix} if exists($map{$self->country_code().$prefix}); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
3
|
|
|
|
|
35
|
return undef; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub format { |
86
|
80
|
|
|
80
|
1
|
933
|
my $self = shift; |
87
|
80
|
|
|
|
|
228
|
my $number = $self->raw_number(); |
88
|
80
|
|
|
|
|
160
|
foreach my $formatter (@{$self->{formatters}}) { |
|
80
|
|
|
|
|
247
|
|
89
|
438
|
|
|
|
|
892
|
my($leading_digits, $pattern) = map { $formatter->{$_} } qw(leading_digits pattern); |
|
876
|
|
|
|
|
2054
|
|
90
|
438
|
100
|
100
|
|
|
14797
|
if((!$leading_digits || $number =~ /^($leading_digits)/x) && $number =~ /^$pattern$/x) { |
|
|
|
100
|
|
|
|
|
91
|
79
|
|
|
|
|
1009
|
my @bits = $number =~ /^$pattern$/x; |
92
|
79
|
|
|
|
|
419
|
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; |