Catmandu/Fix/assoc.pm

filter: Statementstmt 100% 34 / 34 Branchbran 75.0% 3 / 4 Conditioncond 80.0% 4 / 5 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 94.4% 51 / 54 CC 5 SCAR 9.9
CC
5
Cov
95%
__ANON__
5.1
_build_fixer
1.0
BEGIN
1.0
CRAP 2.7
« Catmandu/Util/Path.pm ↑ Summary Catmandu/Fix/Bind/list.pm »
1 package Catmandu::Fix::assoc;
2  
3 1 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 our $VERSION = '1.2025';
6  
7 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Catmandu::Util::Path qw(as_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Catmandu::Util qw(is_hash_ref);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Catmandu::Fix::Has;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 with 'Catmandu::Fix::Builder';
14  
15 1 has path => (fix_arg => 1);
16 1 has keys_path => (fix_arg => 1);
17 1 has vals_path => (fix_arg => 1);
18  
19 2 ▶sub _build_fixer {
Subroutine _build_fixer: called CC=1 SCAR=0.0
20 2 my ($self) = @_;
21 2 my $keys_getter = as_path($self->keys_path)->getter;
22 2 my $vals_getter = as_path($self->vals_path)->getter;
23 as_path($self->path)->creator(
24 2 ▶ sub {
Subroutine __ANON__: called CC=5 SCAR=16.2
25 2 my ($val, $data) = @_;
26 2 ▶ if (is_hash_ref($val //= {})) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_hash_ref(scalar($val //= {}))) 2 0 2
Condition100%2/2
$val //= {}
l!l
11
MC/DC100%1/1
$val //= {}
$val
Truth table100%2/2
A
A= $val
Aresult
11
00
27 2 my $keys = $keys_getter->($data);
28 2 my $vals = $vals_getter->($data);
29 2 ▶ $val->{shift @$keys} = shift @$vals while @$keys && @$vals;
Branch: 1 branch
BranchTrueFalseTotal
@$keys and @$vals and do { $$val{shift @$keys} = shift @$vals } 4 2 6
Condition66%2/3
@$keys and @$vals
!ll&&!rl&&r
204
MC/DC50%1/2
@$keys and @$vals
@$keys @$vals
Truth table66%2/3
A and B
A= @$keysB= @$vals
ABresult
0X0
100
111
30 }
31 2 $val;
32 }
33 2 );
34 }
35  
36 1 1;
37  
38 __END__
« Catmandu/Util/Path.pm ↑ Summary Catmandu/Fix/Bind/list.pm »