Amazon/Attribute/ReviewSet.pm

filter: Statementstmt 70.7% 29 / 41 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 50.0% 2 / 4 totaltotal 70.0% 42 / 60 CC 5 SCAR 11.3
CC
5
Cov
68%
add_review
6.0
init_via_xmlref
5.3
BEGIN
1.0
CRAP 3.1
« Amazon/Validate/Type/VehicleSearch.pm ↑ Summary Amazon/Response/Seller.pm »
1 ######################################################################
2 package Net::Amazon::Attribute::ReviewSet;
3 ######################################################################
4 24 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 24 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 24 ▶use Log::Log4perl qw(:easy);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 24 ▶use Net::Amazon::Attribute::Review;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 24 ▶use base qw(Net::Amazon);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 24 __PACKAGE__->make_accessor($_) for qw(average_customer_rating total_reviews
11 total_review_pages);
12  
13 ##################################################
14 329 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
15 ##################################################
16 329 my($class, %options) = @_;
17  
18 329 my $self = {
19 reviews => [], # list of reviews
20 };
21  
22 329 bless $self, $class;
23 }
24  
25 ###########################################
26 0 ▶sub add_review {
Subroutine add_review: not called CC=2 SCAR=17.9
Pod documented
27 ###########################################
28 0 my($self, $review) = @_;
29  
30 0 ▶ if(ref $review ne "Net::Amazon::Attribute::Review") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $review ne "Net::Amazon::Attribute::Review") 0 0 0
31 0 warn "add_review called with type ", ref $review;
32 0 return undef;
33 }
34  
35 0 push @{$self->{reviews}}, $review;
36 }
37  
38 ###########################################
39 1 ▶sub reviews {
Subroutine reviews: called CC=1 SCAR=0.0
Pod documented
40 ###########################################
41 1 my($self) = @_;
42  
43 1 return @{$self->{reviews}};
44 }
45  
46 ##################################################
47 1 ▶sub init_via_xmlref {
Subroutine init_via_xmlref: called CC=4 SCAR=16.8
Pod undocumented
48 ##################################################
49 1 my($self, $xmlref) = @_;
50  
51 1 my @pairs = qw(AverageRating average_customer_rating
52 TotalReviews total_reviews
53 TotalReviewPages total_review_pages);
54  
55 1 ▶ while(my($field, $method) = splice @pairs, 0, 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@pairs, 0, 2)) 3 1 4
56
57 3 ▶ if(exists $xmlref->{$field}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $xmlref->{$field}) 0 3 3
58 0 DEBUG "Setting $field via $method to $xmlref->{$field}";
59 0 $self->$method($xmlref->{$field});
60 }
61 }
62  
63 1 for my $review_xmlref (@{$xmlref->{Review}}) {
64 0 my $review = Net::Amazon::Attribute::Review->new();
65 0 $review->init_via_xmlref($review_xmlref);
66 0 DEBUG "Adding review ", $review->summary();
67 0 $self->add_review($review);
68 }
69 }
70  
71 24 1;
72  
73 __END__
« Amazon/Validate/Type/VehicleSearch.pm ↑ Summary Amazon/Response/Seller.pm »