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

filter: Statementstmt 88.6% 39 / 44 Branchbran 50.0% 4 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 91.6% 11 / 12 Podpod 100% 2 / 2 totaltotal 80.2% 57 / 71 CC 6 SCAR 10.7
CC
6
Cov
80%
match_valid_cvr
6.0
__ANON__
5.5
valid_cvr
1.0
CRAP 2.9
« lib/Business/DK/CVR.pm ↑ Summary lib/Class/Business/DK/CVR.pm »
1 package Data::FormValidator::Constraints::Business::DK::CVR;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use vars qw(@ISA $VERSION @EXPORT_OK);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Business::DK::CVR qw(validate);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 3 @EXPORT_OK = qw(valid_cvr match_valid_cvr);
13  
14 3 ▶use constant VALID => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 3 ▶use constant INVALID => undef;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 3 $VERSION = '0.12';
18  
19 4 ▶sub valid_cvr {
Subroutine valid_cvr: called CC=1 SCAR=0.2
Pod documented
20 6 ▶ return sub {
Subroutine __ANON__: called CC=5 SCAR=17.1
21 6 my $dfv = shift;
22  
23 6 ▶ if ( !blessed $dfv || !$dfv->isa('Data::FormValidator::Results') ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($dfv) and $dfv->isa("Data::FormValidator::Results")) 0 6 6
Condition33%1/3
builtin::blessed($dfv) and $dfv->isa("Data::FormValidator::Results")
!ll&&!rl&&r
006
MC/DC0%0/2
builtin::blessed($dfv) and $dfv->isa("Data::FormValidator::Results")
builtin::blessed($dfv) $dfv->isa("Data::FormValidator::Results")
Truth table33%1/3
A and B
A= builtin::blessed($dfv)B= $dfv->isa("Data::FormValidator::Results")
ABresult
0X0
100
111
24 0 croak('Must be called using \'constraint_methods\'!');
25 }
26  
27 6 my $cvr = $dfv->get_current_constraint_value;
28  
29 6 ▶ if ( ref $dfv ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $dfv) 6 0 6
30 6 $dfv->name_this('valid_cvr');
31 }
32  
33 6 ▶ if ( validate($cvr) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (validate($cvr)) { } 4 2 6
34 4 return VALID;
35 } else {
36 2 return INVALID;
37 }
38 }
39 4 }
40  
41 0 ▶sub match_valid_cvr {
Subroutine match_valid_cvr: not called CC=2 SCAR=17.9
Pod documented
42 0 my $dfv = shift;
43  
44 # if $dfv is a ref then we are called as 'constraint_method'
45 # else as 'constraint'
46  
47 0 ▶ my $cvr = ref $dfv ? $dfv->get_current_constraint_value : $dfv;
Branch: 1 branch
BranchTrueFalseTotal
ref $dfv ? : 0 0 0
48  
49 #my $cvr = $dfv->get_current_constraint_value;
50  
51 0 my ($untainted_cvr) = $cvr =~ m/\b(\d{8})\b/smx;
52  
53 0 return $dfv->untainted_constraint_value($untainted_cvr);
54 }
55  
56 3 1;
57  
58 __END__
« lib/Business/DK/CVR.pm ↑ Summary lib/Class/Business/DK/CVR.pm »