Moose/Field/Std.pm

filter: Statementstmt 65.6% 21 / 32 Branchbran 50.0% 5 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 100% 1 / 1 totaltotal 62.5% 30 / 48 CC 7 SCAR 15.8
CC
7
Cov
62%
subfield
6.2
__ANON__
6.0
__ANON__
2.0
CRAP 4.9
« Moose/Reader/File/Isis.pm ↑ Summary Moose/Parser/MarcxmlSaxHandler.pm »
1 package MARC::Moose::Field::Std;
2 # ABSTRACT: Standard Marc Field (tag >= 010)
3 4 $MARC::Moose::Field::Std::VERSION = '1.0.49';
4 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 extends 'MARC::Moose::Field';
7  
8 4 has ind1 => (is => 'rw', isa => 'Str', default => ' ');
9 4 has ind2 => (is => 'rw', isa => 'Str', default => ' ');
10  
11  
12 61 ▶has subf => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
13  
14  
15 0 ▶override 'as_formatted' => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
16 0 my $self = shift;
17  
18 join ' ', (
19 $self->tag,
20 $self->ind1 . $self->ind2,
21 0 map { ("\$$_->[0]", $_->[1]) } @{$self->subf} );
22 4 };
23  
24  
25 0 ▶override 'clone' => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
26 0 my ($self, $tag) = @_;
27 0 my $field = MARC::Moose::Field::Std->new( tag => $self->tag );
28 0 ▶ $field->tag($tag) if $tag;
Branch: 1 branch
BranchTrueFalseTotal
if $tag 0 0 0
29 0 $field->subf( [ map { [ $_->[0] => $_->[1] ] } @{$self->subf} ] );
30 0 return $field;
31 4 };
32  
33  
34 8 ▶sub subfield {
Subroutine subfield: called CC=6 SCAR=18.3
Pod documented
35 8 my ($self, $letter) = @_;
36  
37 8 ▶ return unless defined($letter);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $letter 0 8 8
38  
39 8 my @values;
40 8 for ( @{$self->subf} ) {
41 14 ▶ push @values, $_->[1] if $_->[0] =~ $letter;
Branch: 1 branch
BranchTrueFalseTotal
if $_->[0] =~ /$letter/ 8 6 14
42 }
43  
44 8 ▶ return unless @values;
Branch: 1 branch
BranchTrueFalseTotal
unless @values 0 8 8
45 8 ▶ return wantarray ? @values : $values[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 8 8
46 }
47  
48 4 __PACKAGE__->meta->make_immutable;
49  
50 4 1;
51  
52 __END__
« Moose/Reader/File/Isis.pm ↑ Summary Moose/Parser/MarcxmlSaxHandler.pm »