Catmandu/Fix/retain.pm

filter: Statementstmt 97.5% 40 / 41 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 7 / 8 Podpod n/a totaltotal 96.2% 51 / 53 CC 4 SCAR 7.4
CC
4
Cov
98%
__ANON__
4.0
__ANON__
1.1
BEGIN
1.0
CRAP 2.1
« Catmandu/Fix/lookup_in_store.pm ↑ Summary Catmandu.pm »
1 package Catmandu::Fix::retain;
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 namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Catmandu::Fix::Has;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 with 'Catmandu::Fix::Builder';
13  
14 0 ▶has paths => (fix_arg => 'collect', default => sub {[]},);
Subroutine __ANON__: not called CC=1 SCAR=1.2
15  
16 3 ▶sub _build_fixer {
Subroutine _build_fixer: called CC=1 SCAR=0.0
17 3 my ($self) = @_;
18 3 my $paths = [map {as_path($_)} @{$self->paths}];
19 3 my $getters = [map {$_->getter} @$paths];
20 3 my $creators = [map {$_->creator} @$paths];
21  
22 3 ▶ sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
23 3 my $data = $_[0];
24 3 my $temp = {};
25 3 ▶ for (my $i = 0; $i < @$getters; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$getters) 4 3 7
26 4 my $getter = $getters->[$i];
27 4 my $creator = $creators->[$i];
28 4 my $values = $getter->($data);
29 4 ▶ while (@$values) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$values) 3 4 7
30 3 $creator->($temp, shift @$values);
31 }
32 }
33 3 undef %$data;
34 3 for my $key (keys %$temp) {
35 3 $data->{$key} = $temp->{$key};
36 }
37 3 $data;
38 3 };
39 }
40  
41 1 1;
42  
43 __END__
« Catmandu/Fix/lookup_in_store.pm ↑ Summary Catmandu.pm »