SICI/ContributionSegment.pm

filter: Statementstmt 92.4% 61 / 66 Branchbran 72.2% 13 / 18 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 12 / 12 Podpod 100% 2 / 2 totaltotal 88.3% 91 / 103 CC 11 SCAR 11.8
CC
11
Cov
87%
to_string
6.0
_trigger_titleCode
4.8
_trigger_location
2.1
CRAP 3.3
« SICI/Util.pm ↑ Summary SICI/ControlSegment.pm »
1  
2 package Biblio::SICI::ContributionSegment;
3 {
4 3 $Biblio::SICI::ContributionSegment::VERSION = '0.04';
5 }
6  
7 # ABSTRACT: The contribution 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 3 ▶use Biblio::SICI::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21  
22 3 has 'location' => ( is => 'rw', trigger => 1, predicate => 1, clearer => 1, );
23  
24 26 ▶sub _trigger_location {
Subroutine _trigger_location: called CC=2 SCAR=7.4
25 26 my ( $self, $newVal ) = @_;
26  
27 26 ▶ if ( $newVal !~ /\A${Biblio::SICI::Util::TITLE_CODE}+\Z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $newVal =~ /\A$Biblio::SICI::Util::TITLE_CODE+\Z/) { } 0 26 26
28 0 $self->log_problem_on( 'location' => ['contains invalid characters'] );
29 }
30 else {
31 26 $self->clear_problem_on('location');
32 }
33  
34 26 return;
35 }
36  
37  
38 3 has 'titleCode' => ( is => 'rw', trigger => 1, predicate => 1, clearer => 1, );
39  
40 27 ▶sub _trigger_titleCode {
Subroutine _trigger_titleCode: called CC=4 SCAR=15.8
41 27 my ( $self, $newVal ) = @_;
42 27 my @problems = ();
43  
44 27 ▶ if ( length $newVal > 6 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $newVal > 6) 0 27 27
45 0 push @problems, 'contains more than 6 characters';
46 }
47  
48 27 ▶ if ( $newVal !~ /\A${Biblio::SICI::Util::TITLE_CODE}+\Z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($newVal =~ /\A$Biblio::SICI::Util::TITLE_CODE+\Z/) 0 27 27
49 0 push @problems, 'contains invalid characters';
50 }
51  
52 27 ▶ if (@problems) {
Branch: 1 branch
BranchTrueFalseTotal
if (@problems) { } 0 27 27
53 0 $self->log_problem_on( titleCode => \@problems );
54 }
55 else {
56 27 $self->clear_problem_on('titleCode');
57 }
58  
59 27 return;
60 }
61  
62  
63 3 has 'localNumber' => ( is => 'rw', trigger => 1, predicate => 1, clearer => 1, );
64  
65 4 ▶sub _trigger_localNumber {
Subroutine _trigger_localNumber: called CC=2 SCAR=7.4
66 4 my ( $self, $newVal ) = @_;
67  
68 4 ▶ if ( $newVal !~ /\A${Biblio::SICI::Util::TITLE_CODE}+\Z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $newVal =~ /\A$Biblio::SICI::Util::TITLE_CODE+\Z/) { } 0 4 4
69 0 $self->log_problem_on( 'location' => ['contains invalid characters'] );
70 }
71 else {
72 4 $self->clear_problem_on('location');
73 }
74  
75 4 return;
76 }
77  
78  
79 179 ▶sub to_string {
Subroutine to_string: called CC=6 SCAR=17.9
Pod documented
80 179 my $self = shift;
81 179 my $str = '';
82  
83 179 ▶ if ( $self->has_location() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_location) 76 103 179
84 76 $str .= $self->location();
85 }
86  
87 179 ▶ if ( $self->has_titleCode() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_titleCode) 79 100 179
88 79 $str .= ':' . $self->titleCode();
89 }
90  
91 179 ▶ if ( $self->has_localNumber() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_localNumber) 12 167 179
92 12 ▶ if ( $self->has_location() or $self->has_titleCode() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_location or $self->has_titleCode) { } 6 6 12
Condition66%2/3
$self->has_location or $self->has_titleCode
l!l&&r!l&&!r
606
MC/DC50%1/2
$self->has_location or $self->has_titleCode
$self->has_location $self->has_titleCode
Truth table66%2/3
A or B
A= $self->has_locationB= $self->has_titleCode
ABresult
1X1
011
000
93 6 $str .= ':' . $self->localNumber();
94 }
95 else {
96 6 $str .= '::' . $self->localNumber();
97 }
98 }
99  
100 179 return $str;
101 }
102  
103  
104 59 ▶sub reset {
Subroutine reset: called CC=1 SCAR=0.0
Pod documented
105 59 my $self = shift;
106 59 $self->clear_location();
107 59 $self->clear_problem_on('location');
108 59 $self->clear_titleCode();
109 59 $self->clear_problem_on('titleCode');
110 59 $self->clear_localNumber();
111 59 $self->clear_problem_on('localNumber');
112  
113 59 return;
114 }
115  
116  
117 3 1;
118  
119 __END__
« SICI/Util.pm ↑ Summary SICI/ControlSegment.pm »