SICI/ControlSegment.pm

filter: Statementstmt 94.5% 52 / 55 Branchbran 70.0% 7 / 10 Conditioncond 91.6% 11 / 12 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 100% 12 / 12 Podpod 100% 3 / 3 totaltotal 88.7% 87 / 98 CC 10 SCAR 10.2
CC
10
Cov
91%
_trigger_dpi
5.2
csi
4.0
_trigger_mfi
2.1
CRAP 2.8
« SICI/ContributionSegment.pm ↑ Summary SICI/Role/RecursiveLink.pm »
1  
2 package Biblio::SICI::ControlSegment;
3 {
4 3 $Biblio::SICI::ControlSegment::VERSION = '0.04';
5 }
6  
7 # ABSTRACT: The control segment of a SICI
8  
9 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 3 ▶use Sub::Quote;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 3 ▶use Biblio::SICI;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 3 with 'Biblio::SICI::Role::ValidSegment', 'Biblio::SICI::Role::RecursiveLink';
18  
19  
20 3 has 'dpi' => (
21 is => 'rw', lazy => 1,
22 trigger => 1,
23 default => quote_sub(q{ 0 }),
24 predicate => 1,
25 clearer => 1,
26 );
27  
28 58 ▶sub _trigger_dpi {
Subroutine _trigger_dpi: called CC=5 SCAR=16.4
29 58 my ( $self, $newVal ) = @_;
30  
31 58 ▶ if ( not( "$newVal" eq "0" or "$newVal" eq "1" or "$newVal" eq "2" or "$newVal" eq "3" ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not "$newVal" eq '0' || "$newVal" eq '1' || "$newVal" eq '2' || "$newVal" eq '3') { } 0 58 58
Condition88%8/9
"$newVal" eq '0' || "$newVal" eq '1' || "$newVal" eq '2' || "$newVal" eq '3'
l!l&&r!l&&!r
5710
"$newVal" eq 0 or "$newVal" eq 1 or "$newVal" eq 2
l!l&&r!l&&!r
5521
"$newVal" eq 0 or "$newVal" eq 1
l!l&&r!l&&!r
5413
MC/DC0%0/4
"$newVal" eq '0' || "$newVal" eq '1' || "$newVal" eq '2' || "$newVal" eq '3'
"$newVal" eq 0 "$newVal" eq 1 "$newVal" eq 2 "$newVal" eq '3'
Truth table80%4/5
A or B or C || D
A= "$newVal" eq 0B= "$newVal" eq 1C= "$newVal" eq 2D= "$newVal" eq '3'
ABCDresult
1XXX1
01XX1
001X1
00011
00000
32 0 $self->log_problem_on( 'dpi' => ['value not in allowed range (0|1|2|3)'] );
33 }
34 else {
35 58 $self->clear_problem_on('dpi');
36 }
37  
38 58 return;
39 }
40  
41  
42 3 has 'mfi' => (
43 is => 'rw', lazy => 1,
44 trigger => 1,
45 default => quote_sub(q{ "ZU" }),
46 predicate => 1,
47 clearer => 1,
48 );
49  
50 59 ▶sub _trigger_mfi {
Subroutine _trigger_mfi: called CC=2 SCAR=7.4
51 59 my ( $self, $newVal ) = @_;
52  
53 59 ▶ if ( $newVal !~ /\A(?:C[DFOT]|H[DE]|SC|T[BHLSX]|VX|Z[NUZ])\Z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $newVal =~ /\A(?:C[DFOT]|H[DE]|SC|T[BHLSX]|VX|Z[NUZ])\Z/) { } 0 59 59
54 0 $self->log_problem_on( 'mfi' => ['unknown identifier'] );
55 }
56 else {
57 59 $self->clear_problem_on('mfi');
58 }
59  
60 59 return;
61 }
62  
63  
64 3 has 'version' => (
65 is => 'rw', lazy => 1,
66 trigger => 1,
67 default => quote_sub(q{ 2 }),
68 predicate => 1,
69 clearer => 1,
70 );
71  
72 58 ▶sub _trigger_version {
Subroutine _trigger_version: called CC=2 SCAR=7.4
73 58 my ( $self, $newVal ) = @_;
74  
75 58 ▶ if ( $newVal != 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($newVal != 2) { } 0 58 58
76 0 $self->log_problem( 'version' => ['unsupported version number (i.e. not "2")'] );
77 }
78 else {
79 58 $self->clear_problem_on('version');
80 }
81  
82 58 return;
83 }
84  
85  
86 237 ▶sub csi {
Subroutine csi: called CC=4 SCAR=13.9
Pod documented
87 237 my $self = shift;
88  
89 237 ▶ if ( $self->_sici()->contribution()->has_localNumber() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_sici->contribution->has_localNumber) 16 221 237
90 16 return 3;
91 }
92  
93 221 ▶ if ( $self->_sici()->contribution()->has_location()
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_sici->contribution->has_location or $self->_sici->contribution->has_titleCode) 97 124 221
Condition100%3/3
$self->_sici->contribution->has_location or $self->_sici->contribution->has_titleCode
l!l&&r!l&&!r
934124
MC/DC100%2/2
$self->_sici->contribution->has_location or $self->_sici->contribution->has_titleCode
$self->_sici->contribution->has_location $self->_sici->contribution->has_titleCode
Truth table100%3/3
A or B
A= $self->_sici->contribution->has_locationB= $self->_sici->contribution->has_titleCode
ABresult
1X1
011
000
94 or $self->_sici()->contribution()->has_titleCode() )
95 {
96 97 return 2;
97 }
98  
99 124 return 1;
100 }
101  
102  
103 179 ▶sub to_string {
Subroutine to_string: called CC=1 SCAR=0.0
Pod documented
104 179 my $self = shift;
105  
106 # Every attribute in this class has a default value
107 179 return sprintf( '%s.%s.%s;%s', $self->csi(), $self->dpi(), $self->mfi(), $self->version() );
108 }
109  
110  
111 59 ▶sub reset {
Subroutine reset: called CC=1 SCAR=0.0
Pod documented
112 59 my $self = shift;
113 59 $self->clear_dpi();
114 59 $self->clear_problem_on('dpi');
115 59 $self->clear_mfi();
116 59 $self->clear_problem_on('mfi');
117 59 $self->clear_version();
118 59 $self->clear_problem_on('version');
119 59 return;
120 }
121  
122  
123 3 1;
124  
125 __END__
« SICI/ContributionSegment.pm ↑ Summary SICI/Role/RecursiveLink.pm »