SICI/Role/ValidSegment.pm

filter: Statementstmt 72.7% 24 / 33 Branchbran 25.0% 2 / 8 Conditioncond 0.0% 0 / 15 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 75.0% 6 / 8 Podpod 100% 4 / 4 totaltotal 48.0% 36 / 75 CC 11 SCAR 25.8
CC
11
Cov
46%
log_problem_on
30.0
is_valid
13.0
clear_problem_on
2.0
CRAP 13.2
« SICI/ItemSegment.pm ↑ Summary SICI/Util.pm »
1 package Biblio::SICI::Role::ValidSegment;
2 {
3 3 $Biblio::SICI::Role::ValidSegment::VERSION = '0.04';
4 }
5  
6 # ABSTRACT: Role to provide common validation error handling functionality to the segments
7  
8 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 3 has validationErrors => ( is => 'lazy', );
15  
16 6 ▶sub _build_validationErrors {
Subroutine _build_validationErrors: called CC=1 SCAR=0.0
17 6 return {};
18 }
19  
20  
21 0 ▶sub log_problem_on {
Subroutine log_problem_on: not called CC=5 SCAR=34.0
Pod documented
22 0 my ( $self, $attr, $desc ) = @_;
23  
24 0 ▶ if ( defined($attr) and $attr and defined($desc) and $desc ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $attr and $attr and defined $desc and $desc) 0 0 0
Condition0%0/9
defined $attr and $attr and defined $desc and $desc
!ll&&!rl&&r
000
defined $attr and $attr and defined $desc
!ll&&!rl&&r
000
defined $attr and $attr
!ll&&!rl&&r
000
MC/DC0%0/4
defined $attr and $attr and defined $desc and $desc
defined $attr $attr defined $desc $desc
Truth table0%0/5
A and B and C and D
A= defined $attrB= $attrC= defined $descD= $desc
ABCDresult
0XXX0
10XX0
110X0
11100
11111
25 0 $self->validationErrors->{$attr} = $desc;
26 }
27 0 return;
28 }
29  
30  
31 1262 ▶sub clear_problem_on {
Subroutine clear_problem_on: called CC=2 SCAR=7.1
Pod documented
32 1262 my ( $self, $attr ) = @_;
33  
34 1262 ▶ delete $self->validationErrors->{$attr} if exists $self->validationErrors->{$attr};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->validationErrors->{$attr} 0 1262 1262
35 1262 return;
36 }
37  
38  
39 0 ▶sub list_problems {
Subroutine list_problems: not called CC=1 SCAR=6.9
Pod documented
40 0 my $self = shift;
41 0 return %{ $self->validationErrors };
42 }
43  
44  
45 363 ▶sub is_valid {
Subroutine is_valid: called CC=6 SCAR=25.6
Pod documented
46 363 my $self = shift;
47 363 my $invalid = 0;
48  
49 363 my %problems = %{ $self->validationErrors };
50  
51 363 foreach my $attr ( keys %problems ) {
52 0 ▶ if ( exists $problems{$attr} and defined $problems{$attr} and $problems{$attr} ne '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $problems{$attr} and defined $problems{$attr} and $problems{$attr} ne "") 0 0 0
Condition0%0/6
exists $problems{$attr} and defined $problems{$attr} and $problems{$attr} ne ""
!ll&&!rl&&r
000
exists $problems{$attr} and defined $problems{$attr}
!ll&&!rl&&r
000
MC/DC0%0/3
exists $problems{$attr} and defined $problems{$attr} and $problems{$attr} ne ""
exists $problems{$attr} defined $problems{$attr} $problems{$attr} ne ""
Truth table0%0/4
A and B and C
A= exists $problems{$attr}B= defined $problems{$attr}C= $problems{$attr} ne ""
ABCresult
0XX0
10X0
1100
1111
53 0 $invalid++;
54 }
55 }
56 363 ▶ return 0 if $invalid;
Branch: 1 branch
BranchTrueFalseTotal
if $invalid 0 363 363
57 363 return 1;
58 }
59  
60  
61 3 1;
62  
63 __END__
« SICI/ItemSegment.pm ↑ Summary SICI/Util.pm »