Catmandu/Fix/disassoc.pm

filter: Statementstmt 100% 37 / 37 Branchbran 100% 2 / 2 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 100% 50 / 50 CC 5 SCAR 9.8
CC
5
Cov
100%
__ANON__
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.7
« Catmandu/Fix/int.pm ↑ Summary Catmandu/Store/Hash/Bag.pm »
1 package Catmandu::Fix::disassoc;
2  
3 1 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Catmandu::Util::Path qw(as_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Catmandu::Util qw(is_array_ref);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Catmandu::Fix::Has;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 with 'Catmandu::Fix::Builder';
11  
12 1 has old_path => (fix_arg => 1);
13 1 has new_path => (fix_arg => 1);
14 1 has key_name => (fix_arg => 1);
15 1 has value_name => (fix_arg => 1);
16  
17 3 ▶sub _build_fixer {
Subroutine _build_fixer: called CC=1 SCAR=0.0
18 3 my ($self) = @_;
19 3 my $key_name = $self->key_name;
20 3 my $val_name = $self->value_name;
21 3 my $getter = as_path($self->old_path)->getter;
22 3 my $creator = as_path($self->new_path)->creator;
23 as_path($self->new_path)->creator(
24 3 ▶ sub {
Subroutine __ANON__: called CC=5 SCAR=16.1
25 3 my ($arr, $data) = @_;
26 3 ▶ if (is_array_ref($arr //= [])) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_array_ref(scalar($arr //= []))) 2 1 3
Condition100%2/2
$arr //= []
l!l
12
MC/DC100%1/1
$arr //= []
$arr
Truth table100%2/2
A
A= $arr
Aresult
11
00
27 2 for my $hash (@{$getter->($data)}) {
28 2 for my $key (sort keys %$hash) {
29 push @$arr,
30 4 {$key_name => $key, $val_name => $hash->{$key},};
31 }
32 }
33 }
34 3 $arr;
35 }
36 3 );
37 }
38  
39 1 1;
40  
41 __END__
« Catmandu/Fix/int.pm ↑ Summary Catmandu/Store/Hash/Bag.pm »