Stream/Iterator/Consolidate/FillMissing.pm

filter: Statementstmt 98.0% 49 / 50 Branchbran 88.8% 16 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 33.3% 1 / 3 totaltotal 93.7% 75 / 80 CC 10 SCAR 12.4
CC
10
Cov
96%
get_next
6.0
has_next
4.0
new
2.0
CRAP 3.5
« Stream/Iterator/Consolidate/AdjacentAsc.pm ↑ Summary Stream.pm »
1 package Data::Range::Compare::Stream::Iterator::Consolidate::FillMissing;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use base qw(Data::Range::Compare::Stream::Iterator::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Data::Range::Compare::Stream::Iterator::Consolidate::Result;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use constant NEW_RESULT_FROM=>'Data::Range::Compare::Stream::Iterator::Consolidate::Result';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 5 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
13 5 my ($class,$con,%args)=@_;
14 5 ▶ croak 'Consolidator object must be defined' unless defined($con);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $con 0 5 5
15
16 5 $class->SUPER::new(con=>$con,%args);
17 }
18  
19 51 ▶sub has_next {
Subroutine has_next: called CC=4 SCAR=13.9
Pod undocumented
20 51 my ($self)=@_;
21 51 ▶ return 1 if $self->{con}->has_next;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"con"}->has_next 26 25 51
22 25 ▶ return 1 if defined($self->{missing_result});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"missing_result"} 7 18 25
23 18 ▶ return 1 if defined($self->{last_result_obj});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"last_result_obj"} 7 11 18
24 11 return 0;
25 }
26  
27 24 ▶sub get_next {
Subroutine get_next: called CC=6 SCAR=17.9
Pod documented
28 24 my ($self)=@_;
29 24 my $it=$self->{con};
30
31 24 my $last_result;
32 24 ▶ if(defined($self->{missing_result})) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->{'missing_result'}) { } 8 16 24
elsif (defined $self->{'last_result_obj'}) { } 11 5 16
33 8 my $result=$self->{missing_result};
34 8 $self->{missing_result}=undef;
35 8 return $result;
36 } elsif(defined($self->{last_result_obj})) {
37 11 $last_result=$self->{last_result_obj};
38 11 $self->{last_result_obj}=undef;
39 } else {
40 5 ▶ if($it->has_next) {
Branch: 1 branch
BranchTrueFalseTotal
if ($it->has_next) { } 5 0 5
41 5 $last_result=$it->get_next;
42 } else {
43 0 croak 'iterator called when has_next is false!';
44 }
45 }
46  
47 16 ▶ if($it->has_next) {
Branch: 1 branch
BranchTrueFalseTotal
if ($it->has_next) { } 11 5 16
48 11 my $result=$it->get_next;
49 11 ▶ if($last_result->get_common->contiguous_check($result->get_common)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($last_result->get_common->contiguous_check($result->get_common)) { } 3 8 11
50 3 $self->{last_result_obj}=$result;
51 3 return $last_result;
52 } else {
53 8 $self->{last_result_obj}=$result;
54 8 my $new_result=$self->create_from_factory($last_result->get_common->next_range_start,$result->get_common->previous_range_end);
55 8 $new_result->get_common->on_create_range($last_result->get_common);
56 8 $self->{missing_result}=$self->NEW_RESULT_FROM->new($new_result,$new_result,$new_result,1,1);
57  
58 8 return $last_result;
59 }
60 } else {
61 5 return $last_result;
62 }
63 }
64  
65  
66 2 1;
« Stream/Iterator/Consolidate/AdjacentAsc.pm ↑ Summary Stream.pm »