S3/Error.pm

filter: Statementstmt 42.4% 14 / 33 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 2 totaltotal 39.1% 18 / 46 CC 3 SCAR 12.0
CC
3
Cov
38%
new
6.0
stringify
6.0
_parse_xml
2.0
CRAP 3.3
« S3.pm ↑ Summary
1 package Furl::S3::Error;
2 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 4 ▶use Class::Accessor::Lite;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use overload q{""} => \&stringify;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 Class::Accessor::Lite->mk_accessors(qw(code http_code http_status message request_id host_id));
8  
9 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
10 0 my( $class, $res ) = @_;
11 my $self = bless {
12 http_code => $res->{code},
13 http_status => $res->{msg},
14 0 }, $class;
15 0 ▶ if ( my $xml = $res->{body} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $xml = $res->{"body"}) 0 0 0
16 0 $self->_parse_xml( $xml );
17 }
18 0 $self;
19 }
20  
21 0 ▶sub stringify {
Subroutine stringify: not called CC=2 SCAR=17.9
Pod undocumented
22 0 my $self = shift;
23 0 ▶ if ( $self->message ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->message) { } 0 0 0
24 0 return sprintf('%s: %s', $self->code, $self->message);
25 }
26 else {
27 0 return sprintf('HTTP Error: %s %s', $self->http_code, $self->http_status);
28 }
29 }
30  
31 0 ▶sub _parse_xml {
Subroutine _parse_xml: not called CC=1 SCAR=6.9
32 0 my( $self, $xml ) = @_;
33 0 my $doc = XML::LibXML->new->parse_string( $xml );
34 0 my $code = $doc->findvalue('/Error/Code');
35 0 my $message = $doc->findvalue('/Error/Message');
36 0 my $request_id = $doc->findvalue('/Error/RequestId');
37 0 my $host_id = $doc->findvalue('/Error/HostId');
38 0 $self->code( $code );
39 0 $self->message( $message );
40 0 $self->request_id( $request_id );
41 0 $self->host_id( $host_id );
42 }
43  
44 4 1;
45  
46 __END__
« S3.pm ↑ Summary