blib/lib/BZ/Client/XMLRPC/Struct.pm

filter: Statementstmt 23.4% 11 / 47 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 33.3% 3 / 9 Podpod 0.0% 0 / 5 totaltotal 14.7% 14 / 95 CC 15 SCAR 42.0
CC
15
Cov
14%
start
132.0
end
12.0
characters
12.0
CRAP 66.7
« blib/lib/BZ/Client/XMLRPC/Value.pm ↑ Summary blib/lib/BZ/Client/XMLRPC/Array.pm »
1 #!/bin/false
2 # PODNAME: BZ::Client::XMLRPC::Struct
3 # ABSTRACT: Event handler for parsing a single XML-RPC struct.
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::Struct;
9 1 $BZ::Client::XMLRPC::Struct::VERSION = '4.4001';
10 1 ▶use parent qw(BZ::Client::XMLRPC::Handler );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub init {
13 0 ▶ my ($self, $parser) = @_;
Subroutine init: not called CC=1 SCAR=6.9
Pod undocumented
14 0 $self->SUPER::init($parser);
15 0 $self->{'result'} = {}
16 }
17  
18 sub start {
19 0 ▶ my($self,$name) = @_;
Subroutine start: not called CC=11 SCAR=48.8
Pod undocumented
20 0 my $l = $self->inc_level();
21 0 ▶ if ($l == 0) {
Branch: 3 branches
BranchTrueFalseTotal
if ($l == 0) { } 0 0 0
elsif ($l == 1) { } 0 0 0
elsif ($l == 2) { } 0 0 0
22 0 ▶ if ('struct' ne $name) {
Branch: 1 branch
BranchTrueFalseTotal
if ("struct" ne $name) 0 0 0
23 0 $self->error("Expected struct element, got $name");
24 }
25 } elsif ($l == 1) {
26 0 ▶ if ('member' ne $name) {
Branch: 1 branch
BranchTrueFalseTotal
if ("member" ne $name) 0 0 0
27 0 $self->error("Expected struct/member element, got $name");
28 }
29 0 $self->{'current_name'} = undef;
30 0 $self->{'parsing_name'} = undef;
31 } elsif ($l == 2) {
32 0 ▶ if ('name' eq $name) {
Branch: 2 branches
BranchTrueFalseTotal
if ('name' eq $name) { } 0 0 0
elsif ('value' eq $name) { } 0 0 0
33 0 ▶ $self->error("Multiple name elements in struct/member") if defined $self->{'parsing_name'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"parsing_name"} 0 0 0
34 0 $self->{'parsing_name'} = q();
35 } elsif ('value' eq $name) {
36 0 my $current_name = $self->{'current_name'};
37 0 ▶ $self->error("Expected struct/member/name element, got value") unless defined $current_name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $current_name 0 0 0
38 0 ▶ $self->error('Multiple value elements in struct/member, or multiple members with the same name.') if defined $self->{'result'}->{$current_name};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"result"}{$current_name} 0 0 0
39 0 my $handler = BZ::Client::XMLRPC::Value->new();
40 $self->parser()->register($self, $handler, sub {
41 0 ▶ $self->{'result'}->{$current_name} = $handler->result()
Subroutine __ANON__: not called CC=1 SCAR=6.9
42 0 });
43 0 $handler->start($name);
44 } else {
45 0 $self->error("Expected name|value element in struct/member, got $name");
46 }
47 } else {
48 0 $self->error("Unexpected level $l with element $name");
49 }
50 }
51  
52 sub end {
53 0 ▶ my($self,$name) = @_;
Subroutine end: not called CC=3 SCAR=24.8
Pod undocumented
54 0 my $l = $self->SUPER::end($name);
55 0 ▶ if ($l == 2 && defined($self->{'parsing_name'})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($l == 2 and defined $self->{"parsing_name"}) 0 0 0
Condition0%0/3
$l == 2 and defined $self->{"parsing_name"}
!ll&&!rl&&r
000
MC/DC0%0/2
$l == 2 and defined $self->{"parsing_name"}
$l == 2 defined $self->{"parsing_name"}
Truth table0%0/3
A and B
A= $l == 2B= defined $self->{"parsing_name"}
ABresult
0X0
100
111
56 0 $self->{'current_name'} = $self->{'parsing_name'};
57 }
58 0 return $l
59 }
60  
61 sub characters {
62 0 ▶ my($self, $text) = @_;
Subroutine characters: not called CC=3 SCAR=24.8
Pod undocumented
63 0 my $l = $self->level();
64 0 ▶ if ($l == 3 && defined($self->{'parsing_name'})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($l == 3 and defined $self->{'parsing_name'}) { } 0 0 0
Condition0%0/3
$l == 3 and defined $self->{"parsing_name"}
!ll&&!rl&&r
000
MC/DC0%0/2
$l == 3 and defined $self->{"parsing_name"}
$l == 3 defined $self->{"parsing_name"}
Truth table0%0/3
A and B
A= $l == 3B= defined $self->{"parsing_name"}
ABresult
0X0
100
111
65 0 $self->{'parsing_name'} .= $text;
66 } else {
67 0 $self->SUPER::characters($text);
68 }
69 }
70  
71 sub result {
72 0 ▶ my $self = shift;
Subroutine result: not called CC=1 SCAR=6.9
Pod undocumented
73 0 return $self->{'result'}
74 }
75  
76 1 1;
77  
78 __END__
79  
80 =pod
81  
82 =encoding UTF-8
83  
84 =head1 NAME
85  
86 BZ::Client::XMLRPC::Struct - Event handler for parsing a single XML-RPC struct.
87  
88 =head1 VERSION
89  
90 version 4.4001
91  
92 =head1 AUTHORS
93  
94 =over 4
95  
96 =item *
97  
98 Dean Hamstead <dean@bytefoundry.com.au>
99  
100 =item *
101  
102 Jochen Wiedmann <jochen.wiedmann@gmail.com>
103  
104 =back
105  
106 =head1 COPYRIGHT AND LICENSE
107  
108 This software is copyright (c) 2017 by Dean Hamstad.
109  
110 This is free software; you can redistribute it and/or modify it under
111 the same terms as the Perl 5 programming language system itself.
112  
113 =cut
« blib/lib/BZ/Client/XMLRPC/Value.pm ↑ Summary blib/lib/BZ/Client/XMLRPC/Array.pm »