blib/lib/BZ/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 blib/lib/BZ/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.4001';
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 sub start {
15 0 ▶ my($self,$name) = @_;
Subroutine start: not called CC=16 SCAR=56.1
Pod undocumented
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 } elsif ($l == 1) {
22 0 ▶ if ('fault' eq $name) {
Branch: 2 branches
BranchTrueFalseTotal
if ('fault' eq $name) { } 0 0 0
elsif ('params' eq $name) { } 0 0 0
23 0 $self->{'in_fault'} = 1;
24 } elsif ('params' eq $name) {
25 0 ▶ if (defined($self->{'result'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"result"}) 0 0 0
26 0 $self->error('Multiple elements methodResponse/params found.');
27 }
28 0 $self->{'in_fault'} = 0;
29 } else {
30 0 $self->error("Unexpected element methodResponse/$name, expected fault|params");
31 }
32 } elsif ($l == 2) {
33 0 ▶ if ($self->{'in_fault'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'in_fault'}) { } 0 0 0
34 0 ▶ if ('value' ne $name) {
Branch: 1 branch
BranchTrueFalseTotal
if ("value" ne $name) 0 0 0
35 0 $self->error("Unexpected element methodResponse/fault/$name, expected value");
36 }
37 0 my $handler = BZ::Client::XMLRPC::Value->new();
38 $self->parser()->register($self, $handler, sub {
39 0 ▶ my $result = $handler->result();
Subroutine __ANON__: not called CC=2 SCAR=17.9
40 0 ▶ if ('HASH' ne ref($result)) {
Branch: 1 branch
BranchTrueFalseTotal
if ("HASH" ne ref $result) 0 0 0
41 0 $self->error('Failed to parse XML-RPC response document: Error reported, but no faultCode and faultString found.');
42 }
43 0 my $faultCode = $result->{'faultCode'};
44 0 my $faultString = $result->{'faultString'};
45 0 $self->{'exception'} = BZ::Client::Exception->new('message' => $faultString,
46 'xmlrpc_code' => $faultCode);
47 0 });
48 0 $handler->start($name);
49 } else {
50 0 ▶ if ('param' ne $name) {
Branch: 1 branch
BranchTrueFalseTotal
if ("param" ne $name) 0 0 0
51 0 $self->error("Unexpected element methodResponse/params/$name, expected param");
52 }
53 0 ▶ if (defined($self->{'result'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"result"}) 0 0 0
54 0 $self->error('Multiple elements methodResponse/params/param found.');
55 }
56 }
57 } elsif ($l == 3) {
58 0 ▶ if ($self->{'in_fault'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'in_fault'}) { } 0 0 0
59 0 $self->error("Unexpected element $name found at level $l");
60 } else {
61 0 ▶ if ('value' ne $name) {
Branch: 1 branch
BranchTrueFalseTotal
if ("value" ne $name) 0 0 0
62 0 $self->error("Unexpected element methodResponse/params/param/$name, expected value");
63 }
64 0 ▶ if (defined($self->{'result'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"result"}) 0 0 0
65 0 $self->error('Multiple elements methodResponse/params/param/value found.');
66 }
67 0 my $handler = BZ::Client::XMLRPC::Value->new();
68 $self->parser()->register($self, $handler, sub {
69 0 ▶ $self->{'result'} = $handler->result();
Subroutine __ANON__: not called CC=1 SCAR=6.9
70 0 });
71 0 $handler->start($name);
72 }
73 }
74 }
75  
76 sub end {
77 0 ▶ my($self, $name) = @_;
Subroutine end: not called CC=1 SCAR=6.9
Pod undocumented
78 0 my $l = $self->SUPER::end($name);
79 0 return $l
80 }
81  
82 sub exception {
83 0 ▶ my $self = shift;
Subroutine exception: not called CC=1 SCAR=6.9
Pod undocumented
84 0 return $self->{'exception'}
85 }
86  
87 sub result {
88 0 ▶ my $self = shift;
Subroutine result: not called CC=1 SCAR=6.9
Pod undocumented
89 0 return $self->{'result'}
90 }
91  
92 1 1;
93  
94 __END__
95  
96 =pod
97  
98 =encoding UTF-8
99  
100 =head1 NAME
101  
102 BZ::Client::XMLRPC::Response - Event handler for parsing an XML-RPC response.
103  
104 =head1 VERSION
105  
106 version 4.4001
107  
108 =head1 AUTHORS
109  
110 =over 4
111  
112 =item *
113  
114 Dean Hamstead <dean@bytefoundry.com.au>
115  
116 =item *
117  
118 Jochen Wiedmann <jochen.wiedmann@gmail.com>
119  
120 =back
121  
122 =head1 COPYRIGHT AND LICENSE
123  
124 This software is copyright (c) 2017 by Dean Hamstad.
125  
126 This is free software; you can redistribute it and/or modify it under
127 the same terms as the Perl 5 programming language system itself.
128  
129 =cut
↑ Summary blib/lib/BZ/Client/XMLRPC/Value.pm »