Client/XMLRPC/Response.pm

filter: Statementstmt 27.8% 17 / 61 Branchbran 0.0% 0 / 32 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 45.4% 5 / 11 Podpod 0.0% 0 / 4 totaltotal 20.3% 22 / 108 CC 17 SCAR 50.9
CC
17
Cov
18%
start
272.0
__ANON__
6.0
__ANON__
2.0
CRAP 162.1
↑ Summary Client/XMLRPC/Value.pm »
1 #!/bin/false
2 # PODNAME: BZ::Client::XMLRPC::Response
3 # ABSTRACT: Event handler for parsing an XML-RPC response.
4 #
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 package BZ::Client::XMLRPC::Response;
9 1 $BZ::Client::XMLRPC::Response::VERSION = '4.91';
10 1 ▶use parent qw( BZ::Client::XMLRPC::Handler );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use BZ::Client::XMLRPC::Value;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use BZ::Client::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 0 ▶sub start {
Subroutine start: not called CC=16 SCAR=56.1
Pod undocumented
15 0 my($self,$name) = @_;
16 0 my $l = $self->inc_level();
17 0 ▶ if ($l == 0) {
Branch: 4 branches
BranchTrueFalseTotal
if ($l == 0) { } 0 0 0
elsif ($l == 1) { } 0 0 0
elsif ($l == 2) { } 0 0 0
elsif ($l == 3) { } 0 0 0
18 0 ▶ if ('methodResponse' ne $name) {
Branch: 1 branch
BranchTrueFalseTotal
if ("methodResponse" ne $name) 0 0 0
19 0 $self->error("Expected methodResponse element, got $name");
20 }
21 }
22 elsif ($l == 1) {
23 0 ▶ if ('fault' eq $name) {
Branch: 2 branches
BranchTrueFalseTotal
if ('fault' eq $name) { } 0 0 0
elsif ('params' eq $name) { } 0 0 0
24 0 $self->{'in_fault'} = 1;
25 }
26 elsif ('params' eq $name) {
27 0 ▶ if (defined($self->{'result'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"result"}) 0 0 0
28 0 $self->error('Multiple elements methodResponse/params found.');
29 }
30 0 $self->{'in_fault'} = 0;
31 }
32 else {
33 0 $self->error("Unexpected element methodResponse/$name, expected fault|params");
34 }
35 }
36 elsif ($l == 2) {
37 0 ▶ if ($self->{'in_fault'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'in_fault'}) { } 0 0 0
38 0 ▶ if ('value' ne $name) {
Branch: 1 branch
BranchTrueFalseTotal
if ("value" ne $name) 0 0 0
39 0 $self->error("Unexpected element methodResponse/fault/$name, expected value");
40 }
41 0 my $handler = BZ::Client::XMLRPC::Value->new();
42 0 ▶ $self->parser()->register($self, $handler, sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
43 0 my $result = $handler->result();
44 0 ▶ if ('HASH' ne ref($result)) {
Branch: 1 branch
BranchTrueFalseTotal
if ("HASH" ne ref $result) 0 0 0
45 0 $self->error('Failed to parse XML-RPC response document: Error reported, but no faultCode and faultString found.');
46 }
47 0 my $faultCode = $result->{'faultCode'};
48 0 my $faultString = $result->{'faultString'};
49 0 $self->{'exception'} = BZ::Client::Exception->new('message' => $faultString,
50 'xmlrpc_code' => $faultCode);
51 0 });
52 0 $handler->start($name);
53 }
54 else {
55 0 ▶ if ('param' ne $name) {
Branch: 1 branch
BranchTrueFalseTotal
if ("param" ne $name) 0 0 0
56 0 $self->error("Unexpected element methodResponse/params/$name, expected param");
57 }
58 0 ▶ if (defined($self->{'result'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"result"}) 0 0 0
59 0 $self->error('Multiple elements methodResponse/params/param found.');
60 }
61 }
62 }
63 elsif ($l == 3) {
64 0 ▶ if ($self->{'in_fault'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'in_fault'}) { } 0 0 0
65 0 $self->error("Unexpected element $name found at level $l");
66 }
67 else {
68 0 ▶ if ('value' ne $name) {
Branch: 1 branch
BranchTrueFalseTotal
if ("value" ne $name) 0 0 0
69 0 $self->error("Unexpected element methodResponse/params/param/$name, expected value");
70 }
71 0 ▶ if (defined($self->{'result'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"result"}) 0 0 0
72 0 $self->error('Multiple elements methodResponse/params/param/value found.');
73 }
74 0 my $handler = BZ::Client::XMLRPC::Value->new();
75 0 ▶ $self->parser()->register($self, $handler, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
76 0 $self->{'result'} = $handler->result();
77 0 });
78 0 $handler->start($name);
79 }
80 }
81 }
82  
83 0 ▶sub end {
Subroutine end: not called CC=1 SCAR=6.9
Pod undocumented
84 0 my($self, $name) = @_;
85 0 my $l = $self->SUPER::end($name);
86 0 return $l
87 }
88  
89 0 ▶sub exception {
Subroutine exception: not called CC=1 SCAR=6.9
Pod undocumented
90 0 my $self = shift;
91 0 return $self->{'exception'}
92 }
93  
94 0 ▶sub result {
Subroutine result: not called CC=1 SCAR=6.9
Pod undocumented
95 0 my $self = shift;
96 0 return $self->{'result'}
97 }
98  
99 1 1;
100  
101 __END__
↑ Summary Client/XMLRPC/Value.pm »