Validator/Plugin/Field035.pm

filter: Statementstmt 97.7% 44 / 45 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 11 / 11 Podpod 100% 4 / 4 totaltotal 97.0% 66 / 68 CC 6 SCAR 10.6
CC
6
Cov
96%
process
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.9
« Validator/Plugin/Field040.pm ↑ Summary Validator/Plugin/Field045.pm »
1 package MARC::Validator::Plugin::Field035;
2  
3 6 ▶use base qw(MARC::Validator::Abstract);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 6 ▶use Data::MARC::Validator::Report::Error 0.02;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use Data::MARC::Validator::Report::Plugin::Errors 0.02;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use English;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 6 our $VERSION = 0.25;
12  
13 4 ▶sub module_name {
Subroutine module_name: called CC=1 SCAR=0.0
Pod documented
14 4 my $self = shift;
15  
16 4 return __PACKAGE__;
17 }
18  
19 5 ▶sub name {
Subroutine name: called CC=1 SCAR=0.0
Pod documented
20 5 my $self = shift;
21  
22 5 return 'field_035';
23 }
24  
25 3 ▶sub process {
Subroutine process: called CC=6 SCAR=18.0
Pod documented
26 3 my ($self, $marc_record) = @_;
27  
28 3 my $record_id = $self->{'cb_record_id'}->($marc_record);
29 3 my @record_errors;
30  
31 3 my @system_control_numbers = $marc_record->field('035');
32 3 foreach my $system_control_number (@system_control_numbers) {
33 4 my $value = $system_control_number->subfield('a');
34 4 ▶ if (! defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $value) 0 4 4
35 0 next;
36 }
37  
38 4 ▶ if (! exists $self->{'ids'}->{$value}) {
Branch: 2 branches
BranchTrueFalseTotal
if (not exists $self->{'ids'}{$value}) { } 2 2 4
elsif ($self->{'ids'}{$value} eq $record_id) { } 1 1 2
39 2 $self->{'ids'}->{$value} = $record_id;
40 } elsif ($self->{'ids'}->{$value} eq $record_id) {
41 1 push @record_errors, Data::MARC::Validator::Report::Error->new(
42 'error' => 'Duplicate system control number in 035a field.',
43 'params' => {
44 'Value' => $value,
45 },
46 );
47 } else {
48 push @record_errors, Data::MARC::Validator::Report::Error->new(
49 'error' => 'Bad system control number in 035a field.',
50 'params' => {
51 'value' => $value,
52 1 'duplicate_to' => $self->{'ids'}->{$value},
53 },
54 );
55 }
56 }
57  
58 3 ▶ if (@record_errors) {
Branch: 1 branch
BranchTrueFalseTotal
if (@record_errors) 2 1 3
59 2 push @{$self->{'errors'}}, Data::MARC::Validator::Report::Plugin::Errors->new(
60 'errors' => \@record_errors,
61 2 'filters' => $self->{'filters'},
62 'record_id' => $record_id,
63 );
64 }
65  
66 3 return;
67 }
68  
69 4 ▶sub version {
Subroutine version: called CC=1 SCAR=0.0
Pod documented
70 4 my $self = shift;
71  
72 4 return $VERSION;
73 }
74  
75 3 ▶sub _init {
Subroutine _init: called CC=1 SCAR=0.0
76 3 my $self = shift;
77  
78 3 $self->{'ids'} = {};
79  
80 3 return;
81 }
82  
83 6 1;
84  
85 __END__
« Validator/Plugin/Field040.pm ↑ Summary Validator/Plugin/Field045.pm »