File Coverage

blib/lib/XML/Amazon/Collection.pm
Criterion Covered Total %
statement 9 34 26.4
branch 0 4 0.0
condition n/a
subroutine 3 9 33.3
pod 6 6 100.0
total 18 53 33.9


line stmt bran cond sub pod time code
1             package XML::Amazon::Collection;
2             $XML::Amazon::Collection::VERSION = '0.14';
3 1     1   7 use strict;
  1         2  
  1         28  
4 1     1   5 use warnings;
  1         3  
  1         23  
5 1     1   5 use utf8;
  1         2  
  1         4  
6              
7             sub new {
8 0     0 1   my $pkg = shift;
9 0           my $data = {
10             total_results => undef,
11             total_pages => undef,
12             current_page => undef,
13             collection => []
14             };
15 0           bless $data, $pkg;
16 0           return $data;
17             }
18              
19             sub add_Amazon {
20 0     0 1   my $self = shift;
21 0           my $add_data = shift;
22              
23 0 0         if(ref $add_data ne "XML::Amazon::Item") {
24 0           warn "add_Amazon called with type ", ref $add_data;
25 0           return undef;
26             }
27 0           push @{$self->{collection}}, $add_data;
  0            
28             }
29              
30             sub total_results {
31 0     0 1   my $self = shift;
32 0           return $self->{total_results};
33             }
34              
35             sub total_pages {
36 0     0 1   my $self = shift;
37 0           return $self->{total_pages};
38             }
39              
40             sub current_page {
41 0     0 1   my $self = shift;
42 0           return $self->{current_page};
43             }
44              
45             sub collection {
46 0     0 1   my $self = shift;
47 0           my @list;
48 0           LIST: for my $el (@{$self->{collection}}) {
  0            
49 0 0         if (! $el) {
50 0           last LIST;
51             }
52 0           push @list, $el;
53             }
54 0           return @list;
55             }
56              
57             1;
58              
59             __END__