| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Mo::utils::Country; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
207328
|
use base qw(Exporter); |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
572
|
|
|
4
|
4
|
|
|
4
|
|
25
|
use strict; |
|
|
4
|
|
|
|
|
16
|
|
|
|
4
|
|
|
|
|
104
|
|
|
5
|
4
|
|
|
4
|
|
18
|
use warnings; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
223
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
1951
|
use Error::Pure qw(err); |
|
|
4
|
|
|
|
|
27767
|
|
|
|
4
|
|
|
|
|
147
|
|
|
8
|
4
|
|
|
4
|
|
326
|
use List::Util 1.33 qw(none); |
|
|
4
|
|
|
|
|
89
|
|
|
|
4
|
|
|
|
|
432
|
|
|
9
|
4
|
|
|
4
|
|
1906
|
use Locale::Country; |
|
|
4
|
|
|
|
|
256226
|
|
|
|
4
|
|
|
|
|
674
|
|
|
10
|
4
|
|
|
4
|
|
38
|
use Readonly; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
3824
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Readonly::Array our @EXPORT_OK => qw(check_country_3166_1_alpha_2 check_country_3166_1_alpha_3); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = 0.02; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub check_country_3166_1_alpha_2 { |
|
17
|
5
|
|
|
5
|
1
|
366688
|
my ($self, $key) = @_; |
|
18
|
|
|
|
|
|
|
|
|
19
|
5
|
|
|
|
|
13
|
my $error = "Parameter '%s' doesn't contain valid ISO 3166-1 alpha-2 code."; |
|
20
|
|
|
|
|
|
|
|
|
21
|
5
|
|
|
|
|
21
|
_check_country($self, $key, LOCALE_CODE_ALPHA_2, $error); |
|
22
|
|
|
|
|
|
|
|
|
23
|
4
|
|
|
|
|
15
|
return; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub check_country_3166_1_alpha_3 { |
|
27
|
4
|
|
|
4
|
1
|
282721
|
my ($self, $key) = @_; |
|
28
|
|
|
|
|
|
|
|
|
29
|
4
|
|
|
|
|
7
|
my $error = "Parameter '%s' doesn't contain valid ISO 3166-1 alpha-3 code."; |
|
30
|
|
|
|
|
|
|
|
|
31
|
4
|
|
|
|
|
11
|
_check_country($self, $key, LOCALE_CODE_ALPHA_3, $error); |
|
32
|
|
|
|
|
|
|
|
|
33
|
3
|
|
|
|
|
7
|
return; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _check_key { |
|
37
|
9
|
|
|
9
|
|
18
|
my ($self, $key) = @_; |
|
38
|
|
|
|
|
|
|
|
|
39
|
9
|
100
|
100
|
|
|
58
|
if (! exists $self->{$key} || ! defined $self->{$key}) { |
|
40
|
4
|
|
|
|
|
14
|
return 1; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
5
|
|
|
|
|
13
|
return 0; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _check_country { |
|
47
|
9
|
|
|
9
|
|
25
|
my ($self, $key, $codeset, $error) = @_; |
|
48
|
|
|
|
|
|
|
|
|
49
|
9
|
100
|
|
|
|
24
|
_check_key($self, $key) && return; |
|
50
|
|
|
|
|
|
|
|
|
51
|
5
|
100
|
|
669
|
|
50
|
if (none { $_ eq lc($self->{$key}) } all_country_codes($codeset)) { |
|
|
669
|
|
|
|
|
2394
|
|
|
52
|
2
|
|
|
|
|
12
|
my $err = sprintf($error, $key); |
|
53
|
|
|
|
|
|
|
err $err, |
|
54
|
|
|
|
|
|
|
'Codeset', $codeset, |
|
55
|
2
|
|
|
|
|
16
|
'Value', $self->{$key}, |
|
56
|
|
|
|
|
|
|
; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
3
|
|
|
|
|
50
|
return; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__END__ |