Catmandu/Fix/Bind/iterate.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 8 / 8 Conditioncond 62.5% 5 / 8 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 87.5% 56 / 64 CC 8 SCAR 16.2
CC
8
Cov
94%
bind
8.1
BEGIN
1.0
BEGIN
1.0
CRAP 5.1
« Catmandu/Fix/Bind/each.pm ↑ Summary Catmandu/Exporter/JSON.pm »
1 package Catmandu::Fix::Bind::iterate;
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;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Catmandu::Fix::Has;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 with 'Catmandu::Fix::Bind', 'Catmandu::Fix::Bind::Group';
13  
14 1 has start => (fix_opt => 1);
15 1 has end => (fix_opt => 1);
16 1 has step => (fix_opt => 1);
17 1 has var => (fix_opt => 1);
18  
19 29 ▶sub unit {
Subroutine unit: called CC=1 SCAR=0.0
Pod undocumented
20 29 my ($self, $data) = @_;
21 29 $data;
22 }
23  
24 29 ▶sub bind {
Subroutine bind: called CC=8 SCAR=20.9
Pod undocumented
25 29 my ($self, $mvar, $func, $name, $fixer) = @_;
26  
27 29 my $start = $self->start;
28 29 my $end = $self->end;
29 29 ▶ my $step = $self->step // 1;
Condition50%1/2
$self->step // 1
l!l
029
MC/DC0%0/1
$self->step // 1
$self->step
Truth table50%1/2
A
A= $self->step
Aresult
11
00
30 29 my $var = $self->var;
31  
32 29 ▶ if ( Catmandu::Util::is_number($start)
Branch: 1 branch
BranchTrueFalseTotal
if (Catmandu::Util::is_number($start) and Catmandu::Util::is_number($end) and Catmandu::Util::is_number($step)) 28 1 29
Condition66%4/6
Catmandu::Util::is_number($start) and Catmandu::Util::is_number($end) and Catmandu::Util::is_number($step)
!ll&&!rl&&r
1028
Catmandu::Util::is_number($start) and Catmandu::Util::is_number($end)
!ll&&!rl&&r
1028
MC/DC33%1/3
Catmandu::Util::is_number($start) and Catmandu::Util::is_number($end) and Catmandu::Util::is_number($step)
Catmandu::Util::is_number($start) Catmandu::Util::is_number($end) Catmandu::Util::is_number($step)
Truth table50%2/4
A and B and C
A= Catmandu::Util::is_number($start)B= Catmandu::Util::is_number($end)C= Catmandu::Util::is_number($step)
ABCresult
0XX0
10X0
1100
1111
33 && Catmandu::Util::is_number($end)
34 && Catmandu::Util::is_number($step))
35 {
36 28 ▶ for (my $i = $start; $i <= $end; $i = $i + $step) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $end) 145 27 172
37 145 ▶ $mvar->{$var} = $i if defined($var);
Branch: 1 branch
BranchTrueFalseTotal
if defined $var 10 135 145
38 145 $mvar = $func->($mvar);
39 }
40 }
41  
42 28 ▶ delete $mvar->{$var} if defined($var);
Branch: 1 branch
BranchTrueFalseTotal
if defined $var 1 27 28
43  
44 28 return $mvar;
45 }
46  
47 1 1;
48  
49 __END__
« Catmandu/Fix/Bind/each.pm ↑ Summary Catmandu/Exporter/JSON.pm »