Fix/Bind/pica_each.pm

filter: Statementstmt 100% 43 / 43 Branchbran 70.0% 7 / 10 Conditioncond 55.5% 5 / 9 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 2 totaltotal 83.7% 67 / 80 CC 10 SCAR 16.7
CC
10
Cov
89%
bind
9.8
__ANON__
2.0
BEGIN
1.0
CRAP 5.3
« Fix/pica_remove.pm ↑ Summary Fix/pica_map.pm »
1 package Catmandu::Fix::Bind::pica_each;
2  
3 1 our $VERSION = '1.18';
4  
5 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Catmandu::Util;
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 PICA::Path;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Scalar::Util 'reftype';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 with 'Catmandu::Fix::Bind', 'Catmandu::Fix::Bind::Group';
13  
14 1 has done => ( is => 'ro' );
15 has pica_path => (
16 fix_arg => 1,
17 4 ▶ coerce => sub { $_[0] ne '....' ? PICA::Path->new( $_[0] ) : undef },
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] ne '....' ? : 3 1 4
18 1 ▶ default => sub { '....' }
Subroutine __ANON__: called CC=1 SCAR=0.0
19 1 );
20  
21 4 ▶sub unit {
Subroutine unit: called CC=1 SCAR=0.0
Pod undocumented
22 4 my ( $self, $data ) = @_;
23 4 $self->{done} = 0;
24 4 $data;
25 }
26  
27 4 ▶sub bind {
Subroutine bind: called CC=9 SCAR=22.9
Pod undocumented
28 4 my ( $self, $data, $code ) = @_;
29 4 ▶ return $data if $self->done or reftype( $data->{record} ) ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if $self->done or builtin::reftype($data->{"record"}) ne "ARRAY" 0 4 4
Condition33%1/3
$self->done or builtin::reftype($data->{"record"}) ne "ARRAY"
l!l&&r!l&&!r
004
MC/DC0%0/2
$self->done or builtin::reftype($data->{"record"}) ne "ARRAY"
$self->done builtin::reftype($data->{"record"}) ne "ARRAY"
Truth table33%1/3
A or B
A= $self->doneB= builtin::reftype($data->{"record"}) ne "ARRAY"
ABresult
1X1
011
000
30  
31 4 my $fields = $data->{record};
32  
33 4 my @new = ();
34  
35 4 for my $field ( @{$fields} ) {
36 91 ▶ if ( $self->pica_path && !$self->pica_path->match_field($field) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->pica_path and not $self->pica_path->match_field($field)) { } 58 33 91
Condition100%3/3
$self->pica_path and not $self->pica_path->match_field($field)
!ll&&!rl&&r
25858
MC/DC100%2/2
$self->pica_path and not $self->pica_path->match_field($field)
$self->pica_path not $self->pica_path->match_field($field)
Truth table100%3/3
A and not(B)
A= $self->pica_pathB= not $self->pica_path->match_field($field)
ABresult
0X0
100
111
37 58 push @new, $field;
38 }
39 else {
40 33 $data->{record} = [$field];
41  
42 33 my $fixed = $code->($data);
43  
44 33 push @new, @{ $fixed->{record} }
45 33 ▶ if defined($fixed) && exists $fixed->{record};
Branch: 1 branch
BranchTrueFalseTotal
if defined $fixed and exists $fixed->{"record"} 33 0 33
Condition33%1/3
defined $fixed and exists $fixed->{"record"}
!ll&&!rl&&r
0033
MC/DC0%0/2
defined $fixed and exists $fixed->{"record"}
defined $fixed exists $fixed->{"record"}
Truth table33%1/3
A and B
A= defined $fixedB= exists $fixed->{"record"}
ABresult
0X0
100
111
46 }
47 }
48  
49 4 ▶ $data->{record} = \@new if exists $data->{record};
Branch: 1 branch
BranchTrueFalseTotal
if exists $data->{"record"} 4 0 4
50  
51 4 $self->{done} = 1;
52  
53 4 $data;
54 }
55  
56 1 1;
57 __END__
« Fix/pica_remove.pm ↑ Summary Fix/pica_map.pm »