Catmandu/Fix/flatten.pm

filter: Statementstmt 100% 29 / 29 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 100% 41 / 41 CC 3 SCAR 4.7
CC
3
Cov
100%
__ANON__
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.6
« Catmandu/Exporter/Multi.pm ↑ Summary Catmandu/Fix/validate.pm »
1 package Catmandu::Fix::flatten;
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_array_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 has path => (fix_arg => 1);
14  
15 1 with 'Catmandu::Fix::Builder';
16  
17 1 ▶sub _build_fixer {
Subroutine _build_fixer: called CC=1 SCAR=0.0
18 1 my ($self) = @_;
19 as_path($self->path)->updater(
20 1 ▶ if_array_ref => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
21 1 my $data = $_[0];
22 10 ▶ $data = [map {is_array_ref($_) ? @$_ : $_} @$data]
Branch: 1 branch
BranchTrueFalseTotal
is_array_ref($_) ? : 3 7 10
23 1 ▶ while grep {is_array_ref($_)} @$data;
Branch: 1 branch
BranchTrueFalseTotal
grep {is_array_ref($_);} @$data and do { $data = [map({is_array_ref($_) ? @$_ : $_;} @$data)] } 2 1 3
24 1 $data;
25 }
26 1 );
27 }
28  
29 1 1;
30  
31 __END__
« Catmandu/Exporter/Multi.pm ↑ Summary Catmandu/Fix/validate.pm »