line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Number::Phone::RO; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
22576
|
use 5.014000; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
5
|
1
|
|
|
1
|
|
10
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
6
|
1
|
|
|
1
|
|
757
|
use parent qw/Number::Phone/; |
|
1
|
|
|
|
|
284
|
|
|
1
|
|
|
|
|
5
|
|
7
|
1
|
|
|
1
|
|
11029
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
8
|
1
|
|
|
1
|
|
26
|
use re '/s'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
960
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub AREA_NAMES (); ## no critic (ProhibitSubroutinePrototypes) |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.002'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our %cache; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _normalized { |
17
|
6
|
|
|
6
|
|
13
|
my ($nr) = @_; |
18
|
6
|
|
|
|
|
17
|
$nr =~ y/0-9+//cd; |
19
|
6
|
|
|
|
|
11
|
$nr =~ s/^[+]40//; |
20
|
6
|
|
|
|
|
21
|
$nr =~ s/^0//; |
21
|
6
|
|
|
|
|
14
|
$nr |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _analyze_number { |
25
|
6
|
|
|
6
|
|
11
|
my ($nr) = @_; |
26
|
6
|
|
|
|
|
8
|
my %info; |
27
|
|
|
|
|
|
|
|
28
|
6
|
100
|
|
|
|
23
|
return { valid => 0 } unless length $nr == 9; |
29
|
5
|
|
|
|
|
13
|
$info{valid} = 1; |
30
|
|
|
|
|
|
|
|
31
|
5
|
100
|
|
|
|
21
|
$info{geographic} = $nr =~ /^[23][3-6]/ ? 1 : 0; |
32
|
5
|
100
|
|
|
|
21
|
@info{qw/fixed_line mobile/} = (1, 0) if $nr =~ /^[23]/; |
33
|
5
|
100
|
|
|
|
17
|
@info{qw/fixed_line mobile/} = (0, 1) if $nr =~ /^7/; |
34
|
5
|
100
|
|
|
|
15
|
$info{tollfree} = $nr =~ /^800/ ? 1 : 0; |
35
|
5
|
100
|
|
|
|
19
|
$info{specialrate} = $nr =~ /^90/ ? 1 : 0; |
36
|
5
|
100
|
|
|
|
14
|
$info{adult} = 1 if $nr =~ /^906/; |
37
|
|
|
|
|
|
|
|
38
|
5
|
100
|
|
|
|
12
|
my $arealen = $nr =~ /^[23]1/ ? 2 : 3; |
39
|
5
|
|
|
|
|
13
|
$info{areacode} = substr $nr, 0, $arealen; |
40
|
5
|
|
|
|
|
16
|
$info{subscriber} = substr $nr, $arealen; |
41
|
|
|
|
|
|
|
|
42
|
5
|
|
|
|
|
16
|
\%info |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
28
|
|
|
28
|
|
41
|
sub _info { $cache{${$_[0]}} } |
|
28
|
|
|
|
|
159
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub new { |
48
|
6
|
|
|
6
|
1
|
1201
|
my ($class, $nr) = @_; |
49
|
6
|
|
|
|
|
15
|
$nr = _normalized $nr; |
50
|
6
|
|
|
|
|
14
|
$cache{$nr} = _analyze_number $nr; |
51
|
6
|
|
|
|
|
73
|
my $self = bless \$nr, $class; |
52
|
6
|
100
|
|
|
|
18
|
$self->is_valid ? $self : undef |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
6
|
|
|
6
|
1
|
15
|
sub is_valid { shift->_info->{valid} } |
56
|
3
|
|
|
3
|
1
|
14
|
sub is_geographic { shift->_info->{geographic} } |
57
|
2
|
|
|
2
|
1
|
7
|
sub is_fixed_line { shift->_info->{fixed_line} } |
58
|
2
|
|
|
2
|
1
|
8
|
sub is_mobile { shift->_info->{mobile} } |
59
|
2
|
|
|
2
|
1
|
7
|
sub is_tollfree { shift->_info->{tollfree} } |
60
|
1
|
|
|
1
|
1
|
4
|
sub is_specialrate { shift->_info->{specialrate} } |
61
|
1
|
|
|
1
|
1
|
4
|
sub is_adult { shift->_info->{adult} } |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
1
|
1
|
4
|
sub country_code { 40 } |
64
|
1
|
|
|
1
|
1
|
10
|
sub regulator { 'ANCOM, http://ancom.org.ro'} |
65
|
|
|
|
|
|
|
|
66
|
5
|
|
|
5
|
1
|
15
|
sub areacode { shift->_info->{areacode} } |
67
|
2
|
100
|
|
2
|
1
|
7
|
sub areaname { $_[0]->is_geographic ? AREA_NAMES->{substr $_[0]->areacode, 1} : undef } |
68
|
6
|
|
|
6
|
1
|
16
|
sub subscriber { shift->_info->{subscriber} } |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub format { ## no critic (ProhibitBuiltinHomonyms) |
71
|
2
|
|
|
2
|
1
|
4
|
my ($self) = @_; |
72
|
2
|
|
|
|
|
6
|
join ' ', |
73
|
|
|
|
|
|
|
'+40', |
74
|
|
|
|
|
|
|
$self->areacode, |
75
|
|
|
|
|
|
|
(substr $self->subscriber, 0, 3), |
76
|
|
|
|
|
|
|
(substr $self->subscriber, 3); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
1
|
|
|
1
|
1
|
2
|
sub intra_country_dial_to { "0${$_[0]}" } |
|
1
|
|
|
|
|
5
|
|
80
|
|
|
|
|
|
|
|
81
|
1
|
|
|
1
|
|
38987
|
use HTTP::Tiny; |
|
1
|
|
|
|
|
57556
|
|
|
1
|
|
|
|
|
420
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $ht = HTTP::Tiny->new(agent => "Number-Phone-RO/$VERSION "); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub query_portabilitate { |
86
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
87
|
0
|
|
|
|
|
|
$self->_info->{portabilitate_queried} = 1; |
88
|
0
|
|
|
|
|
|
my $req = $ht->get("http://portabilitate.ro/ro-no-0$$self"); |
89
|
0
|
0
|
|
|
|
|
return unless $req->{success}; |
90
|
0
|
|
|
|
|
|
my ($initial_operator) = $req->{content} =~ /lnkOperatorInitial">([^<]*); |
91
|
0
|
|
|
|
|
|
my ($current_operator) = $req->{content} =~ /lnkOperator">([^<]*); |
92
|
0
|
|
0
|
|
|
|
$initial_operator //= $current_operator; |
93
|
0
|
|
|
|
|
|
$self->_info->{initial_operator} = $initial_operator; |
94
|
0
|
|
|
|
|
|
$self->_info->{current_operator} = $current_operator; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub operator { |
98
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
99
|
0
|
0
|
|
|
|
|
$self->query_portabilitate unless $self->_info->{portabilitate_queried}; |
100
|
|
|
|
|
|
|
$self->_info->{initial_operator} |
101
|
0
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub operator_ported { |
104
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
105
|
0
|
0
|
|
|
|
|
$self->query_portabilitate unless $self->_info->{portabilitate_queried}; |
106
|
|
|
|
|
|
|
$self->_info->{current_operator} |
107
|
0
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
1
|
|
|
|
|
117
|
use constant AREA_NAMES => { |
110
|
|
|
|
|
|
|
1 => 'București', |
111
|
|
|
|
|
|
|
30 => 'Suceava', |
112
|
|
|
|
|
|
|
31 => 'Botoșani', |
113
|
|
|
|
|
|
|
32 => 'Iași', |
114
|
|
|
|
|
|
|
33 => 'Neamț', |
115
|
|
|
|
|
|
|
34 => 'Bacău', |
116
|
|
|
|
|
|
|
35 => 'Vaslui', |
117
|
|
|
|
|
|
|
36 => 'Galați', |
118
|
|
|
|
|
|
|
37 => 'Vrancea', |
119
|
|
|
|
|
|
|
38 => 'Buzău', |
120
|
|
|
|
|
|
|
39 => 'Brăila', |
121
|
|
|
|
|
|
|
40 => 'Tulcea', |
122
|
|
|
|
|
|
|
41 => 'Constanța', |
123
|
|
|
|
|
|
|
42 => 'Călărași', |
124
|
|
|
|
|
|
|
43 => 'Ialomița', |
125
|
|
|
|
|
|
|
44 => 'Prahova', |
126
|
|
|
|
|
|
|
45 => 'Dâmbovița', |
127
|
|
|
|
|
|
|
46 => 'Giurgiu', |
128
|
|
|
|
|
|
|
47 => 'Teleorman', |
129
|
|
|
|
|
|
|
48 => 'Argeș', |
130
|
|
|
|
|
|
|
49 => 'Olt', |
131
|
|
|
|
|
|
|
50 => 'Vâlcea', |
132
|
|
|
|
|
|
|
51 => 'Dolj', |
133
|
|
|
|
|
|
|
52 => 'Mehedinți', |
134
|
|
|
|
|
|
|
53 => 'Gorj', |
135
|
|
|
|
|
|
|
54 => 'Hunedoara', |
136
|
|
|
|
|
|
|
55 => 'Caraș-Severin', |
137
|
|
|
|
|
|
|
56 => 'Timiș', |
138
|
|
|
|
|
|
|
57 => 'Arad', |
139
|
|
|
|
|
|
|
58 => 'Alba', |
140
|
|
|
|
|
|
|
59 => 'Bihor', |
141
|
|
|
|
|
|
|
60 => 'Sălaj', |
142
|
|
|
|
|
|
|
61 => 'Satu Mare', |
143
|
|
|
|
|
|
|
62 => 'Maramureș', |
144
|
|
|
|
|
|
|
63 => 'Bistrița-Năsăud', |
145
|
|
|
|
|
|
|
64 => 'Cluj', |
146
|
|
|
|
|
|
|
65 => 'Mureș', |
147
|
|
|
|
|
|
|
66 => 'Harghita', |
148
|
|
|
|
|
|
|
67 => 'Covasna', |
149
|
|
|
|
|
|
|
68 => 'Brașov', |
150
|
|
|
|
|
|
|
69 => 'Sibiu', |
151
|
1
|
|
|
1
|
|
9
|
}; |
|
1
|
|
|
|
|
1
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
1; |
154
|
|
|
|
|
|
|
__END__ |