lib/Data/FormValidator/Constraints/Business/DK/CPR.pm

filter: Statementstmt 69.5% 32 / 46 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 76.9% 10 / 13 Podpod 100% 2 / 2 totaltotal 59.4% 44 / 74 CC 6 SCAR 22.7
CC
6
Cov
56%
__ANON__
30.0
match_valid_cpr
6.0
valid_cpr
2.0
CRAP 9.7
« lib/Business/DK/CPR.pm ↑ Summary lib/Class/Business/DK/CPR.pm »
1 package Data::FormValidator::Constraints::Business::DK::CPR;
2  
3 # $Id$
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use vars qw(@ISA $VERSION @EXPORT_OK);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Business::DK::CPR qw(validate);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use 5.008; #5.8.0
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 @EXPORT_OK = qw(valid_cpr match_valid_cpr);
16  
17 1 ▶use constant VALID => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use constant INVALID => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 $VERSION = '0.17';
21  
22 0 ▶sub valid_cpr {
Subroutine valid_cpr: not called CC=1 SCAR=6.9
Pod documented
23 0 ▶ return sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
24 0 my $dfv = shift;
25  
26 0 ▶ if ( !blessed $dfv || !$dfv->isa('Data::FormValidator::Results') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($dfv) and $dfv->isa("Data::FormValidator::Results")) 0 0 0
Condition0%0/3
builtin::blessed($dfv) and $dfv->isa("Data::FormValidator::Results")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($dfv) and $dfv->isa("Data::FormValidator::Results")
builtin::blessed($dfv) $dfv->isa("Data::FormValidator::Results")
Truth table0%0/3
A and B
A= builtin::blessed($dfv)B= $dfv->isa("Data::FormValidator::Results")
ABresult
0X0
100
111
27 0 croak('Must be called using \'constraint_methods\'!');
28 }
29  
30 0 my $cpr = $dfv->get_current_constraint_value;
31  
32 0 ▶ if ( ref $dfv ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $dfv) 0 0 0
33 0 $dfv->name_this('valid_cpr');
34 }
35  
36 0 ▶ if ( validate($cpr) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (validate($cpr)) { } 0 0 0
37 0 return VALID;
38 }
39 else {
40 0 return INVALID;
41 }
42 0 };
43 }
44  
45 0 ▶sub match_valid_cpr {
Subroutine match_valid_cpr: not called CC=2 SCAR=17.9
Pod documented
46 0 my $dfv = shift;
47  
48 # if $dfv is a ref then we are called as 'constraint_method'
49 # else as 'constraint'
50  
51 0 ▶ my $cpr = ref $dfv ? $dfv->get_current_constraint_value : $dfv;
Branch: 1 branch
BranchTrueFalseTotal
ref $dfv ? : 0 0 0
52  
53 0 my ($untainted_cpr) = $cpr =~ m/\A(\d{10})\Z/msx;
54  
55 0 return $dfv->untainted_constraint_value($untainted_cpr);
56 }
57  
58 1 1;
59  
60 __END__
« lib/Business/DK/CPR.pm ↑ Summary lib/Class/Business/DK/CPR.pm »