line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Business::DK::CPR; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
434860
|
use strict; |
|
4
|
|
|
|
|
47
|
|
|
4
|
|
|
|
|
119
|
|
4
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
116
|
|
5
|
4
|
|
|
4
|
|
2323
|
use Class::InsideOut qw( private register id ); |
|
4
|
|
|
|
|
29001
|
|
|
4
|
|
|
|
|
28
|
|
6
|
4
|
|
|
4
|
|
519
|
use Carp qw(croak); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
177
|
|
7
|
4
|
|
|
4
|
|
1003
|
use English qw(-no_match_vars); |
|
4
|
|
|
|
|
7598
|
|
|
4
|
|
|
|
|
23
|
|
8
|
4
|
|
|
4
|
|
1378
|
use 5.010; #5.10.0 |
|
4
|
|
|
|
|
16
|
|
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
2080
|
use Business::DK::CPR qw(validate1968 validate2007); |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
2286
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.15'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
private number => my %number; # read-only accessor: number() |
15
|
|
|
|
|
|
|
private gender => my %gender; # read-only accessor: gender() |
16
|
|
|
|
|
|
|
private algorithm => my %algorithm; # read-only accessor: algorithm() |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
19
|
6
|
|
|
6
|
1
|
568
|
my ( $class, $number ) = @_; |
20
|
|
|
|
|
|
|
|
21
|
6
|
100
|
|
|
|
27
|
if (not $number) { |
22
|
1
|
|
|
|
|
23
|
croak 'You must provide a CPR number'; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
## no critic (Variables::ProhibitUnusedVariables) |
26
|
5
|
|
|
|
|
13
|
my $self = \( my $scalar ); |
27
|
|
|
|
|
|
|
|
28
|
5
|
|
|
|
|
15
|
bless $self, $class; |
29
|
|
|
|
|
|
|
|
30
|
5
|
|
|
|
|
32
|
register($self); |
31
|
|
|
|
|
|
|
|
32
|
5
|
|
|
|
|
115
|
$self->set_number($number); |
33
|
|
|
|
|
|
|
|
34
|
4
|
|
|
|
|
19
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
## no critic (Subroutines::RequireFinalReturn) |
38
|
1
|
|
|
1
|
1
|
29
|
sub number { $number{ id $_[0] } } |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
1
|
1
|
25
|
sub get_number { $number{ id $_[0] } } |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub set_number { |
43
|
8
|
|
|
8
|
1
|
95
|
my ( $self, $unvalidated_cpr ) = @_; |
44
|
|
|
|
|
|
|
|
45
|
8
|
|
|
|
|
16
|
my $rv = 0; |
46
|
8
|
|
|
|
|
13
|
my @algorithms; |
47
|
|
|
|
|
|
|
|
48
|
8
|
100
|
|
|
|
27
|
if ($unvalidated_cpr) { |
49
|
7
|
|
|
|
|
12
|
eval { $rv = validate1968($unvalidated_cpr); 1; }; |
|
7
|
|
|
|
|
25
|
|
|
6
|
|
|
|
|
15
|
|
50
|
|
|
|
|
|
|
|
51
|
7
|
50
|
66
|
|
|
501
|
if ( $rv && $rv % 2 ) { |
|
|
100
|
|
|
|
|
|
52
|
0
|
|
|
|
|
0
|
push @algorithms, '1968'; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
elsif ($rv) { |
55
|
5
|
|
|
|
|
17
|
push @algorithms, '1968'; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
7
|
|
|
|
|
13
|
eval { $rv = validate2007($unvalidated_cpr); 1; }; |
|
7
|
|
|
|
|
22
|
|
|
6
|
|
|
|
|
17
|
|
59
|
|
|
|
|
|
|
|
60
|
7
|
50
|
66
|
|
|
464
|
if ( $rv && $rv % 2 ) { |
|
|
100
|
|
|
|
|
|
61
|
0
|
|
|
|
|
0
|
push @algorithms, '2007'; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
elsif ($rv) { |
64
|
5
|
|
|
|
|
13
|
push @algorithms, '2007'; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
7
|
100
|
100
|
|
|
43
|
if ( $EVAL_ERROR or not $rv ) { |
68
|
2
|
|
|
|
|
19
|
croak 'Invalid CPR number parameter'; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
else { |
72
|
|
|
|
|
|
|
|
73
|
5
|
|
|
|
|
35
|
$number{ id $self } = $unvalidated_cpr; |
74
|
5
|
|
|
|
|
31
|
$gender{ id $self } = $rv; |
75
|
5
|
|
|
|
|
126
|
$algorithm{ id $self } = ( join ', ', @algorithms ); |
76
|
|
|
|
|
|
|
|
77
|
5
|
|
|
|
|
20
|
return 1; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
else { |
81
|
1
|
|
|
|
|
24
|
croak 'You must provide a CPR number'; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
0
|
1
|
|
sub gender { $gender{ id $_[0] } } |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
0
|
1
|
|
sub get_gender { $gender{ id $_[0] } } |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
0
|
1
|
|
sub algorithm { $algorithm{ id $_[0] } } |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
0
|
1
|
|
sub get_algorithm { $algorithm{ id $_[0] } } |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |