line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Number::Phone::StubCountry; |
2
|
|
|
|
|
|
|
|
3
|
34
|
|
|
34
|
|
12901
|
use strict; |
|
34
|
|
|
|
|
79
|
|
|
34
|
|
|
|
|
1037
|
|
4
|
34
|
|
|
34
|
|
194
|
use warnings; |
|
34
|
|
|
|
|
74
|
|
|
34
|
|
|
|
|
1088
|
|
5
|
34
|
|
|
34
|
|
257
|
use Number::Phone::Country qw(noexport); |
|
34
|
|
|
|
|
70
|
|
|
34
|
|
|
|
|
262
|
|
6
|
|
|
|
|
|
|
|
7
|
34
|
|
|
34
|
|
1857
|
use I18N::LangTags::Detect; |
|
34
|
|
|
|
|
205152
|
|
|
34
|
|
|
|
|
1113
|
|
8
|
34
|
|
|
34
|
|
253
|
use I18N::LangTags; |
|
34
|
|
|
|
|
85
|
|
|
34
|
|
|
|
|
1195
|
|
9
|
|
|
|
|
|
|
|
10
|
34
|
|
|
34
|
|
494
|
use base qw(Number::Phone); |
|
34
|
|
|
|
|
83
|
|
|
34
|
|
|
|
|
29629
|
|
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
|
8346
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
310
|
|
|
|
|
7421
|
return $self->{country_code}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub country { |
26
|
4194
|
|
|
4194
|
1
|
698676
|
my $self = shift; |
27
|
4194
|
100
|
|
|
|
10498
|
if(exists($self->{country})) { return $self->{country}; } |
|
2064
|
|
|
|
|
7107
|
|
28
|
2130
|
|
|
|
|
15194
|
ref($self)=~ /::(\w+?)$/; |
29
|
2130
|
|
|
|
|
9356
|
return $self->{country} = $1; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub raw_number { |
33
|
21468
|
|
|
21468
|
0
|
32557
|
my $self = shift; |
34
|
21468
|
|
|
|
|
1339564
|
$self->{number}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub is_valid { |
38
|
5501
|
|
|
5501
|
1
|
12158
|
my $self = shift; |
39
|
5501
|
100
|
|
|
|
16149
|
if(exists($self->{is_valid})) { |
40
|
26
|
|
|
|
|
143
|
return $self->{is_valid}; |
41
|
|
|
|
|
|
|
} |
42
|
5475
|
|
|
|
|
11908
|
foreach (map { "is_$_" } qw(specialrate geographic mobile pager tollfree personal ipphone)) { |
|
38325
|
|
|
|
|
91651
|
|
43
|
21950
|
100
|
|
|
|
88509
|
return $self->{is_valid} = 1 if($self->$_()); |
44
|
|
|
|
|
|
|
} |
45
|
1264
|
|
|
|
|
13168
|
return $self->{is_valid} = 0; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
4720
|
|
|
4720
|
1
|
15295
|
sub is_geographic { shift()->_validator('geographic'); } |
49
|
766
|
|
|
766
|
1
|
263542
|
sub is_fixed_line { shift()->_validator('fixed_line'); } |
50
|
4256
|
|
|
4256
|
1
|
275339
|
sub is_mobile { shift()->_validator('mobile'); } |
51
|
2655
|
|
|
2655
|
1
|
28799
|
sub is_pager { shift()->_validator('pager'); } |
52
|
2043
|
|
|
2043
|
1
|
68737
|
sub is_personal { shift()->_validator('personal_number'); } |
53
|
6288
|
|
|
6288
|
1
|
285270
|
sub is_specialrate { shift()->_validator('specialrate'); } |
54
|
3070
|
|
|
3070
|
1
|
197696
|
sub is_tollfree { shift()->_validator('toll_free'); } |
55
|
1921
|
|
|
1921
|
1
|
105643
|
sub is_ipphone { shift()->_validator('voip'); } |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _validator { |
58
|
25719
|
|
|
25719
|
|
50292
|
my($self, $validator) = @_; |
59
|
25719
|
|
|
|
|
50935
|
$validator = $self->{validators}->{$validator}; |
60
|
25719
|
100
|
|
|
|
55376
|
return undef unless($validator); |
61
|
21360
|
100
|
|
|
|
44067
|
return $self->raw_number() =~ /^($validator)$/x ? 1 : 0; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub areaname { |
65
|
26
|
|
|
26
|
1
|
985
|
my $self = shift; |
66
|
26
|
|
|
|
|
71
|
my @languages = @_; |
67
|
26
|
100
|
|
|
|
84
|
if(!@languages) { # nothing specifically asked for? use the locale |
68
|
17
|
|
|
|
|
76
|
@languages = I18N::LangTags::implicate_supers(I18N::LangTags::Detect::detect()); |
69
|
17
|
100
|
|
|
|
3018
|
if(!grep { $_ eq 'en' } @languages) { |
|
10
|
|
|
|
|
32
|
|
70
|
|
|
|
|
|
|
# and fall back to English |
71
|
15
|
|
|
|
|
52
|
push @languages, 'en' |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
26
|
|
|
|
|
80
|
my $number = $self->raw_number(); |
75
|
26
|
|
|
|
|
55
|
LANGUAGE: foreach my $language (@languages) { |
76
|
32
|
100
|
|
|
|
103
|
next LANGUAGE unless(exists($self->{areanames}->{$language})); |
77
|
24
|
|
|
|
|
46
|
my %map = %{$self->{areanames}->{$language}}; |
|
24
|
|
|
|
|
29328
|
|
78
|
24
|
|
|
|
|
2761
|
foreach my $prefix (map { substr($number, 0, $_) } reverse(1..length($number))) { |
|
197
|
|
|
|
|
482
|
|
79
|
164
|
100
|
|
|
|
341
|
return $map{$self->country_code().$prefix} if exists($map{$self->country_code().$prefix}); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
3
|
|
|
|
|
20
|
return undef; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub format { |
86
|
80
|
|
|
80
|
1
|
850
|
my $self = shift; |
87
|
80
|
|
|
|
|
226
|
my $number = $self->raw_number(); |
88
|
80
|
|
|
|
|
155
|
foreach my $formatter (@{$self->{formatters}}) { |
|
80
|
|
|
|
|
237
|
|
89
|
438
|
|
|
|
|
966
|
my($leading_digits, $pattern) = map { $formatter->{$_} } qw(leading_digits pattern); |
|
876
|
|
|
|
|
2106
|
|
90
|
438
|
100
|
100
|
|
|
14896
|
if((!$leading_digits || $number =~ /^($leading_digits)/x) && $number =~ /^$pattern$/x) { |
|
|
|
100
|
|
|
|
|
91
|
79
|
|
|
|
|
1005
|
my @bits = $number =~ /^$pattern$/x; |
92
|
79
|
|
|
|
|
406
|
return join(' ', '+'.$self->country_code(), @bits); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
# if there's no formatters defined ... |
96
|
1
|
|
|
|
|
13
|
return '+'.$self->country_code().' '.$number; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |