Net/Z3950/FOLIO/PostProcess/OPAC.pm

filter: Statementstmt 97.7% 43 / 44 Branchbran 92.8% 13 / 14 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 2 totaltotal 94.5% 70 / 74 CC 10 SCAR 13.3
CC
10
Cov
97%
processListOfFields
7.0
__ANON__
3.1
postProcessHoldings
2.0
CRAP 3.8
« Net/Z3950/FOLIO/TransformXML.pm ↑ Summary Net/Z3950/FOLIO/lodashGet.pm »
1 package Net::Z3950::FOLIO::PostProcess::OPAC;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use Data::Dumper; $Data::Dumper::INDENT = 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Net::Z3950::FOLIO::PostProcess::Transform qw(transform);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 8 ▶sub postProcessHoldings {
Subroutine postProcessHoldings: called CC=2 SCAR=6.9
Pod undocumented
12 8 my($cfg, $holdings) = @_;
13  
14 8 foreach my $holding (@$holdings) {
15 16 processListOfFields($cfg, $holding, 0);
16 }
17  
18 8 return $holdings;
19 }
20  
21  
22 32 ▶sub processListOfFields {
Subroutine processListOfFields: called CC=7 SCAR=19.5
Pod undocumented
23 32 my($cfg, $list, $isItem) = @_;
24 32 ▶ my $thisCfg = $cfg->{$isItem ? 'circulation' : 'holding' };
Branch: 1 branch
BranchTrueFalseTotal
$isItem ? : 16 16 32
25  
26 5 ▶ my $getFieldFromRecord = sub {
Subroutine __ANON__: called CC=3 SCAR=11.2
27 5 my($fieldname) = @_;
28  
29 # XXX maybe we should make a hash the first time we need to do this
30 5 ▶ foreach (my $i = 0; $i < @$list; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$list) 37 0 37
31 37 my $field = $list->[$i];
32 37 my($name, $value) = @$field;
33 37 ▶ if ($name eq $fieldname) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq $fieldname) 5 32 37
34 5 return $value;
35 }
36 }
37  
38 0 return undef;
39 32 };
40  
41 32 ▶ foreach (my $i = 0; $i < @$list; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$list) 144 32 176
42 144 my $field = $list->[$i];
43 144 my($name, $value) = @$field;
44 144 ▶ if (!$isItem && $name eq 'circulations') {
Branch: 1 branch
BranchTrueFalseTotal
if (not $isItem and $name eq 'circulations') { } 8 136 144
Condition100%3/3
not $isItem and $name eq "circulations"
!ll&&!rl&&r
321048
MC/DC100%2/2
not $isItem and $name eq "circulations"
not $isItem $name eq "circulations"
Truth table100%3/3
not(A) and B
A= not $isItemB= $name eq "circulations"
ABresult
0X0
100
111
45 8 ▶ foreach (my $j = 0; $j < @$value; $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j < @$value) 16 8 24
46 16 processListOfFields($cfg, $value->[$j], 1);
47 }
48 } else {
49 136 my $rule = $thisCfg->{$name};
50 136 ▶ if ($rule) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rule) 12 124 136
51 12 $field->[1] = transform($rule, $value, $getFieldFromRecord);
52 }
53 }
54 }
55 }
56  
57  
58 2 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
59 2 our @EXPORT_OK = qw(postProcessHoldings);
60  
61  
62 2 1;
« Net/Z3950/FOLIO/TransformXML.pm ↑ Summary Net/Z3950/FOLIO/lodashGet.pm »