File Coverage

blib/lib/XML/Amazon/Collection.pm
Criterion Covered Total %
statement 18 40 45.0
branch 0 2 0.0
condition n/a
subroutine 6 12 50.0
pod 6 6 100.0
total 30 60 50.0


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