lib/Class/Business/DK/CPR.pm

filter: Statementstmt 90.3% 56 / 62 Branchbran 85.7% 12 / 14 Conditioncond 77.7% 7 / 9 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 73.3% 11 / 15 Podpod 100% 8 / 8 totaltotal 84.2% 96 / 114 CC 11 SCAR 16.0
CC
11
Cov
88%
set_number
10.3
new
2.0
gender
2.0
CRAP 4.9
« lib/Data/FormValidator/Constraints/Business/DK/CPR.pm ↑ Summary script/calculate_cpr.pl »
1 package Class::Business::DK::CPR;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use Class::InsideOut qw( private register id );
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 5 ▶use English qw(-no_match_vars);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use 5.012; #5.12.0
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 5 ▶use Business::DK::CPR qw(validate1968 validate2007);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 5 our $VERSION = '0.17';
13  
14 5 private number => my %number; # read-only accessor: number()
15 5 private gender => my %gender; # read-only accessor: gender()
16 5 private algorithm => my %algorithm; # read-only accessor: algorithm()
17  
18 6 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
19 6 my ( $class, $number ) = @_;
20  
21 6 ▶ if (not $number) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($number) 1 5 6
22 1 croak 'You must provide a CPR number';
23 }
24  
25 ## no critic (Variables::ProhibitUnusedVariables)
26 5 my $self = \( my $scalar );
27  
28 5 bless $self, $class;
29  
30 5 register($self);
31  
32 5 $self->set_number($number);
33  
34 4 return $self;
35 }
36  
37 ## no critic (Subroutines::RequireFinalReturn)
38 1 ▶sub number { $number{ id $_[0] } }
Subroutine number: called CC=1 SCAR=0.0
Pod documented
39  
40 1 ▶sub get_number { $number{ id $_[0] } }
Subroutine get_number: called CC=1 SCAR=0.0
Pod documented
41  
42 8 ▶sub set_number {
Subroutine set_number: called CC=10 SCAR=23.3
Pod documented
43 8 my ( $self, $unvalidated_cpr ) = @_;
44  
45 8 my $rv = 0;
46 8 my @algorithms;
47  
48 8 ▶ if ($unvalidated_cpr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($unvalidated_cpr) { } 7 1 8
49 7 eval { $rv = validate1968($unvalidated_cpr); 1; };
50  
51 7 ▶ if ( $rv && $rv % 2 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($rv and $rv % 2) { } 0 7 7
elsif ($rv) { } 5 2 7
Condition66%2/3
$rv and $rv % 2
!ll&&!rl&&r
250
MC/DC0%0/2
$rv and $rv % 2
$rv $rv % 2
Truth table66%2/3
A and B
A= $rvB= $rv % 2
ABresult
0X0
100
111
52 0 push @algorithms, '1968';
53 }
54 elsif ($rv) {
55 5 push @algorithms, '1968';
56 }
57  
58 7 eval { $rv = validate2007($unvalidated_cpr); 1; };
59  
60 7 ▶ if ( $rv && $rv % 2 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($rv and $rv % 2) { } 0 7 7
elsif ($rv) { } 5 2 7
Condition66%2/3
$rv and $rv % 2
!ll&&!rl&&r
250
MC/DC0%0/2
$rv and $rv % 2
$rv $rv % 2
Truth table66%2/3
A and B
A= $rvB= $rv % 2
ABresult
0X0
100
111
61 0 push @algorithms, '2007';
62 }
63 elsif ($rv) {
64 5 push @algorithms, '2007';
65 }
66  
67 7 ▶ if ( $EVAL_ERROR or not $rv ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Class::Business::DK::CPR::EVAL_ERROR or not $rv) { } 2 5 7
Condition100%3/3
$Class::Business::DK::CPR::EVAL_ERROR or not $rv
l!l&&r!l&&!r
115
MC/DC100%2/2
$Class::Business::DK::CPR::EVAL_ERROR or not $rv
$Class::Business::DK::CPR::EVAL_ERROR not $rv
Truth table100%3/3
A or not(B)
A= $Class::Business::DK::CPR::EVAL_ERRORB= not $rv
ABresult
1X1
011
000
68 2 croak 'Invalid CPR number parameter';
69  
70 }
71 else {
72  
73 5 $number{ id $self } = $unvalidated_cpr;
74 5 $gender{ id $self } = $rv;
75 5 $algorithm{ id $self } = ( join ', ', @algorithms );
76  
77 5 return 1;
78 }
79 }
80 else {
81 1 croak 'You must provide a CPR number';
82 }
83 }
84  
85 0 ▶sub gender { $gender{ id $_[0] } }
Subroutine gender: not called CC=1 SCAR=6.9
Pod documented
86  
87 0 ▶sub get_gender { $gender{ id $_[0] } }
Subroutine get_gender: not called CC=1 SCAR=6.9
Pod documented
88  
89 0 ▶sub algorithm { $algorithm{ id $_[0] } }
Subroutine algorithm: not called CC=1 SCAR=6.9
Pod documented
90  
91 0 ▶sub get_algorithm { $algorithm{ id $_[0] } }
Subroutine get_algorithm: not called CC=1 SCAR=6.9
Pod documented
92  
93 5 1;
94  
95 __END__
« lib/Data/FormValidator/Constraints/Business/DK/CPR.pm ↑ Summary script/calculate_cpr.pl »