PObject/Iterator.pm

filter: Statementstmt 68.4% 26 / 38 Branchbran 50.0% 2 / 4 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 63.6% 7 / 11 Podpod 85.7% 6 / 7 totaltotal 64.6% 42 / 65 CC 4 SCAR 7.7
CC
4
Cov
64%
push
6.0
new
2.1
next
2.0
CRAP 2.2
« PObject/Type/MD5.pm ↑ Summary PObject/Type/INTEGER.pm »
1 package Class::PObject::Iterator;
2  
3 # Iterator.pm,v 1.8 2005/01/26 19:21:58 sherzodr Exp
4  
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 #use diagnostics;
7 2 ▶use Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use vars ('$VERSION');
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 $VERSION = '1.01';
11  
12 2 ▶sub new {
Subroutine new: called CC=2 SCAR=7.2
Pod documented
13 2 my $class = shift;
14 2 ▶ $class = ref($class) || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
15  
16 my $self = {
17 pobject => $_[0],
18 data_set => $_[1],
19 next_ptr=> 0,
20 2 last_ptr => scalar(@{$_[1]})-1
21 };
22  
23 2 bless $self, $class;
24 }
25  
26 0 ▶sub DESTROY {
Subroutine DESTROY: not called CC=1 SCAR=0.0
27  
28 }
29  
30 10 ▶sub next {
Subroutine next: called CC=2 SCAR=6.9
Pod documented
31 10 my $self = shift;
32  
33 10 my $next_id = $self->{data_set}->[ $self->{next_ptr}++ ];
34 10 ▶ return unless defined $next_id;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $next_id 2 8 10
35 8 return $self->{pobject}->load($next_id)
36 }
37  
38  
39  
40 2 ▶sub size {
Subroutine size: called CC=1 SCAR=0.0
Pod documented
41 2 my $self = shift;
42 2 return $self->{last_ptr} - $self->{next_ptr} + 1
43 }
44  
45  
46  
47 2 ▶sub reset {
Subroutine reset: called CC=1 SCAR=0.0
Pod documented
48 2 my $self = shift;
49  
50 2 $self->{next_ptr} = 0;
51 2 $self->{last_ptr} = scalar( @{ $self->{data_set} } ) - 1
52 }
53  
54  
55 0 ▶sub push {
Subroutine push: not called CC=2 SCAR=17.9
Pod documented
56 0 my $self = shift;
57  
58 0 ▶ unless ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@_) 0 0 0
59 0 croak "push() usage error"
60 }
61 0 push @{$self->{data_set}}, $_[0];
62 0 $self->{last_ptr}++
63 }
64  
65  
66 0 ▶sub finish {
Subroutine finish: not called CC=1 SCAR=6.9
Pod documented
67 0 my $self = shift;
68  
69 0 $self->{data_set} = []
70 }
71  
72  
73  
74 0 ▶sub dump {
Subroutine dump: not called CC=1 SCAR=6.9
Pod undocumented
75 0 my $self = shift;
76  
77 0 require Data::Dumper;
78 0 my $d = new Data::Dumper([$self], [ref $self]);
79 0 return $d->Dump
80 }
81  
82 2 1;
83 __END__
« PObject/Type/MD5.pm ↑ Summary PObject/Type/INTEGER.pm »