lib/Class/Business/DK/CVR.pm

filter: Statementstmt 100% 44 / 44 Branchbran 100% 8 / 8 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 10 / 10 Podpod 100% 4 / 4 totaltotal 100% 71 / 71 CC 6 SCAR 9.0
CC
6
Cov
100%
set_number
5.0
new
2.0
BEGIN
1.0
CRAP 2.5
« lib/Data/FormValidator/Constraints/Business/DK/CVR.pm ↑ Summary script/validate_cvr.pl »
1 package Class::Business::DK::CVR;
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  
9 5 ▶use Business::DK::CVR qw(validate);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 5 our $VERSION = '0.12';
12  
13 5 private number => my %number; # read-only accessor: number()
14  
15 6 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
16 6 my ( $class, $number ) = @_;
17  
18 6 my $self = {};
19  
20 6 bless $self, $class;
21  
22 6 register($self);
23  
24 6 ▶ if ($number) {
Branch: 1 branch
BranchTrueFalseTotal
if ($number) { } 5 1 6
25 5 $self->set_number($number);
26 } else {
27 1 croak 'You must provide a CVR number';
28 }
29  
30 4 return $self;
31 }
32  
33 1 ▶sub number { my $self = shift; return $number{ id $self } }
Subroutine number: called CC=1 SCAR=0.0
Pod documented
34  
35 1 ▶sub get_number { my $self = shift; return $number{ id $self } }
Subroutine get_number: called CC=1 SCAR=0.0
Pod documented
36  
37 8 ▶sub set_number {
Subroutine set_number: called CC=5 SCAR=16.1
Pod documented
38 8 my ( $self, $unvalidated_cvr ) = @_;
39  
40 8 my $rv;
41  
42 8 ▶ if ($unvalidated_cvr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($unvalidated_cvr) { } 7 1 8
43 7 ▶ eval { $rv = validate($unvalidated_cvr); 1; } or 0;
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $rv = validate($unvalidated_cvr); 1 } } or '???' 6 1 7
44  
45 7 ▶ if ( $EVAL_ERROR or not $rv ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Class::Business::DK::CVR::EVAL_ERROR or not $rv) { } 2 5 7
Condition100%3/3
$Class::Business::DK::CVR::EVAL_ERROR or not $rv
l!l&&r!l&&!r
115
MC/DC100%2/2
$Class::Business::DK::CVR::EVAL_ERROR or not $rv
$Class::Business::DK::CVR::EVAL_ERROR not $rv
Truth table100%3/3
A or not(B)
A= $Class::Business::DK::CVR::EVAL_ERRORB= not $rv
ABresult
1X1
011
000
46 2 croak 'Invalid CVR number parameter';
47  
48 } else {
49 5 $number{ id $self } = $unvalidated_cvr;
50 5 return 1;
51  
52 }
53 } else {
54 1 croak 'You must provide a CVR number';
55 }
56 }
57  
58 5 1;
59  
60 __END__
« lib/Data/FormValidator/Constraints/Business/DK/CVR.pm ↑ Summary script/validate_cvr.pl »