Fix/pica_occurrence.pm

filter: Statementstmt 100% 23 / 23 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 88.8% 32 / 36 CC 5 SCAR 8.4
CC
5
Cov
90%
__ANON__
3.3
fix
3.0
BEGIN
1.0
CRAP 2.3
« Fix/Bind/pica_diff.pm ↑ Summary Validator/PICA.pm »
1 package Catmandu::Fix::pica_occurrence;
2  
3 1 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '1.18';
6  
7 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Catmandu::Fix::Has;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Scalar::Util 'reftype';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 has occurrence => (
12 fix_arg => 1,
13 2 ▶ coerce => sub {
Subroutine __ANON__: called CC=3 SCAR=12.0
14 2 ▶ die "invalid occurrence: $_[0]\n" if $_[0] !~ qr/^[0-9]*$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0] =~ qr/^[0-9]*$/ 0 2 2
15 2 ▶ return $_[0] > 0 ? sprintf( "%02d", $_[0] ) : "";
Branch: 1 branch
BranchTrueFalseTotal
$_[0] > 0 ? : 2 0 2
16 }
17 1 );
18  
19 2 ▶sub fix {
Subroutine fix: called CC=3 SCAR=11.0
Pod undocumented
20 2 my ( $self, $data ) = @_;
21  
22 2 ▶ if ( reftype( $data->{record} ) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::reftype($data->{"record"}) eq "ARRAY") 2 0 2
23 2 for ( @{ $data->{record} } ) {
24 4 $_->[1] = $self->occurrence;
25 }
26 }
27  
28 2 return $data;
29 }
30  
31 =head1 NAME
32  
33 Catmandu::Fix::pica_occurrence - change occurrence of PICA+ field
34  
35 =head1 SYNOPSIS
36  
37 # remove occurrence of 012X fields
38 do pica_each(012X/*)
39 pica_occurrence(0)
40 end
41  
42 =head1 FUNCTIONS
43  
44 =head2 pica_occurrence(OCCURRENCE)
45  
46 Set the PICA+ occurrence of every field. Only occurrences C<00> (no occurrence) to C<99> are supported.
47  
48 =head2 SEE ALSO
49  
50 L<Catmandu::Fix::pica_tag>
51  
52 =cut
53  
54 1 1;
« Fix/Bind/pica_diff.pm ↑ Summary Validator/PICA.pm »