lib/XML/Compile/SOAP11/Encoding.pm

filter: Statementstmt 40.1% 165 / 411 Branchbran 29.3% 67 / 228 Conditioncond 20.7% 11 / 53 MC/DCmcdc 15.1% 5 / 33 Subroutinesub 46.8% 22 / 47 Podpod 0.0% 0 / 11 totaltotal 34.4% 270 / 783 CC 147 SCAR 46.4
CC
147
Cov
35%
_dec_simple
342.0
rpcDecode
272.0
_dec
240.0
CRAP 103.7
« lib/XML/Compile/SOAP11/Operation.pm ↑ Summary lib/XML/Compile/SOAP/Operation.pm »
1 # Copyrights 2007-2022 by [Mark Overmeer <markov@cpan.org>].
2 # For other contributors see ChangeLog.
3 # See the manual pages for details on the licensing terms.
4 # Pod stripped from pm file by OODoc 2.03.
5 # This code is part of distribution XML-Compile-SOAP. Meta-POD processed
6 # with OODoc into POD and HTML manual-pages. See README.md
7 # Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
8  
9 package XML::Compile::SOAP11;
10 2 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 $VERSION = '3.28';
12 #!!!
13  
14 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 2 ▶use Log::Report 'xml-compile-soap';
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 2 ▶use List::Util qw/first/;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶use Scalar::Util qw/reftype/;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 use XML::Compile::Util
22 2 ▶ qw/odd_elements SCHEMA2001 SCHEMA2001i pack_type unpack_type type_of_node/;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 2 ▶use XML::Compile::SOAP::Util qw/:soap11 WSDL11/;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 2 my $simplify;
26  
27 sub XML::Compile::SOAP11::Encoding::import(@) #!!!
28 2 ▶{ my ($class, %args) = @_;
Subroutine import: called CC=1 SCAR=0.0
29 2 $simplify = $args{simplify};
30 }
31  
32  
33 sub _initRpcEnc11($$)
34 1 ▶{ my ($self, $schemas, $xsddir) = @_;
Subroutine _initRpcEnc11: called CC=1 SCAR=0.1
35  
36 1 $schemas->addPrefixes('SOAP-ENC' => SOAP11ENC);
37 1 $schemas->importDefinitions("$xsddir/soap-encoding.xsd");
38  
39 1 $schemas->addCompileOptions( 'READERS'
40 , anyElement => 'TAKE_ALL'
41 , anyAttribute => 'TAKE_ALL'
42 , permit_href => 1
43 );
44  
45 # this will keep the soap11 compile object alive after compilation
46 $schemas->addHook
47 ( action => 'READER'
48 , extends => 'SOAP-ENC:Array'
49 0 ▶ , replace => sub { $self->_dec_array_hook(@_) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
50 1 );
51  
52 $schemas->addHook
53 ( action => 'WRITER'
54 , extends => 'SOAP-ENC:Array'
55 0 ▶ , replace => sub { $self->_enc_array_hook(@_) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
56 1 );
57  
58 1 $self;
59 }
60  
61 sub _reader_body_rpcenc_wrapper($$)
62 0 ▶{ my ($self, $procedure, $body) = @_;
Subroutine _reader_body_rpcenc_wrapper: not called CC=1 SCAR=6.9
63 0 my %trans = map +($_->[1] => [ $_->[0], $_->[2] ]), @$body;
64  
65 # this should use key_rewrite, but there is no $wsdl here
66 # my $label = $wsdl->prefixed($procedure);
67 0 my $label = (unpack_type $procedure)[1];
68  
69 my $code = sub
70 0 ▶ { my $opnode = shift or return {};
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
BranchTrueFalseTotal
my $opnode = shift() or return {} 0 0 0
71 0 my @nodes = $opnode->childNodes;
72 0 my $parent = $opnode->parentNode; # href'd sometimes a level up
73 0 ▶ push @nodes, grep $_ ne $opnode, $parent->childNodes
Branch: 1 branch
BranchTrueFalseTotal
if $parent 0 0 0
74 if $parent;
75  
76 0 $self->rpcDecode(@nodes);
77 0 };
78  
79 0 [ [ $label => $procedure => $code ] ];
80 }
81  
82 sub _writer_body_rpcenc_hook($$$$$)
83 0 ▶{ my ($self, $type, $procedure, $params, $faults) = @_;
Subroutine _writer_body_rpcenc_hook: not called CC=1 SCAR=6.9
84 0 $self->_writer_body_rpclit_hook($type, $procedure, $params, $faults);
85 }
86  
87 #------------------
88  
89  
90 sub startEncoding(%)
91 1 ▶{ my ($self, %args) = @_;
Subroutine startEncoding: called CC=2 SCAR=7.4
Pod undocumented
92 1 ▶ my $doc = $args{doc} || XML::LibXML::Document->new('1.0', 'UTF-8');
Condition33%1/3
$args{'doc'} || 'XML::LibXML::Document'->new('1.0', 'UTF-8')
l!l&&r!l&&!r
010
MC/DC0%0/2
$args{'doc'} || 'XML::LibXML::Document'->new('1.0', 'UTF-8')
$args{'doc'} 'XML::LibXML::Document'->new('1.0', 'UTF-8')
Truth table33%1/3
A || B
A= $args{'doc'}B= 'XML::LibXML::Document'->new('1.0', 'UTF-8')
ABresult
1X1
011
000
93 1 $self->{enc} = {doc => $doc};
94 1 $self;
95 }
96  
97 # Currently only support 1-dim arrays
98  
99 sub _enc_array_hook(@)
100 0 ▶{ my ($client, $doc, $val, $path, $tag, $r, $fulltype) = @_;
Subroutine _enc_array_hook: not called CC=6 SCAR=37.4
101 0 my $schema = $client->schemas;
102 0 my $nss = $schema->namespaces;
103  
104 0 my $elem = $doc->createElement($tag);
105 0 my $encns = $schema->prefixFor(SOAP11ENC);
106 0 $elem->setAttribute('xsi:type' => "$encns:Array");
107  
108 0 my ($label, $items) = %$val;
109 0 ▶ my @items = ref $items eq 'ARRAY' ? @$items : $items;
Branch: 1 branch
BranchTrueFalseTotal
ref $items eq 'ARRAY' ? : 0 0 0
110  
111 0 ▶ my $def = $nss->find(complexType => $fulltype)
Branch: 1 branch
BranchTrueFalseTotal
my $def = $nss->find("complexType", $fulltype) or &error(&__x("cannot find {type} in rpc array writer hook", "type", $fulltype)) 0 0 0
112 or error __x"cannot find {type} in rpc array writer hook"
113 , type => $fulltype;
114 0 my $defnode= $def->{node};
115 0 my $xpc = XML::LibXML::XPathContext->new;
116 0 $xpc->registerNs(wsdl => WSDL11);
117 0 my ($atattr) = $xpc->findnodes('.//@wsdl:arrayType', $def->{node});
118  
119 0 my $qname = $atattr->value;
120 0 $qname =~ s/\[.*//; # strip array notation
121  
122 0 ▶ my ($pref,$local) = $qname =~ /\:/ ? (split /\:/,$qname,2) : ('',$qname);
Branch: 1 branch
BranchTrueFalseTotal
$qname =~ /\:/ ? : 0 0 0
123 0 my $ns = $atattr->lookupNamespaceURI($pref);
124 0 my $eltype = pack_type $ns, $local;
125  
126 0 my @nodes;
127 0 ▶ if($nss->find(element => $eltype))
Branch: 1 branch
BranchTrueFalseTotal
if ($nss->find('element', $eltype)) { } 0 0 0
128 0 { my $w = $schema->writer($eltype);
129 0 @nodes = map $w->($doc, $_), @items;
130 }
131 else # type
132 0 { my $w = $schema->writer($eltype, is_type => 1, element => $label);
133 0 @nodes = map $w->($doc, $_), @items;
134 }
135  
136 0 $elem->appendChild($_) for @nodes;
137 0 $elem->setAttribute("$encns:arrayType" => $qname.'['.@nodes.']');
138 0 $elem;
139 }
140  
141  
142 sub prefixed($;$)
143 97 ▶{ my $self = shift;
Subroutine prefixed: called CC=1 SCAR=0.0
Pod undocumented
144 97 $self->schemas->prefixed(@_);
145 }
146  
147  
148 sub enc($$$)
149 7 ▶{ my ($self, $local, $value, $id) = @_;
Subroutine enc: called CC=1 SCAR=0.0
Pod undocumented
150 7 my $type = pack_type SOAP11ENC, $local;
151 $self->schemas->writer($type, include_namespaces => 0)
152 7 ->($self->{enc}{doc}, {_ => $value, id => $id} );
153 }
154  
155  
156 sub typed($$$)
157 6 ▶{ my ($self, $type, $name, $value) = @_;
Subroutine typed: called CC=3 SCAR=11.0
Pod undocumented
158  
159 6 my $showtype;
160 6 ▶ if($type =~ s/^\{\}//)
Branch: 1 branch
BranchTrueFalseTotal
if ($type =~ s/^\{\}//) { } 0 6 6
161 0 { $showtype = $type;
162 }
163 else
164 6 { my ($tns, $tlocal) = unpack_type $type;
165 6 ▶ unless(length $tns)
Branch: 1 branch
BranchTrueFalseTotal
unless (length $tns) 1 5 6
166 1 { $tns = SCHEMA2001;
167 1 $type = pack_type $tns, $tlocal;
168 }
169 6 $showtype = $self->prefixed($tns, $tlocal);
170 }
171  
172 6 my $el = $self->element($type, $name, $value);
173 6 my $typedef = $self->prefixed(SCHEMA2001i, 'type');
174 6 $el->setAttribute($typedef, $showtype);
175 6 $el;
176 }
177  
178  
179 sub struct($@)
180 1 ▶{ my ($self, $type, @childs) = @_;
Subroutine struct: called CC=2 SCAR=6.9
Pod undocumented
181 1 my $typedef = $self->prefixed($type);
182 1 my $doc = $self->{enc}{doc};
183 1 my $struct = $doc->createElement($typedef);
184 1 $struct->addChild($_) for @childs;
185 1 $struct;
186 }
187  
188  
189 sub element($$$)
190 26 ▶{ my ($self, $type, $name, $value) = @_;
Subroutine element: called CC=4 SCAR=14.2
Pod undocumented
191  
192 26 ▶ return $value
Branch: 1 branch
BranchTrueFalseTotal
if UNIVERSAL::isa($value, "XML::LibXML::Element") 0 26 26
193 if UNIVERSAL::isa($value, 'XML::LibXML::Element');
194  
195 26 ▶ $type = $self->prefixed(SCHEMA2001, $type)
Branch: 1 branch
BranchTrueFalseTotal
unless $type =~ /^\{|\:/ 0 26 26
196 if $type !~ m/^\{|\:/;
197  
198 26 my $doc = $self->{enc}{doc};
199 26 my $el = $doc->createElement($name);
200 26 my $child = $self->schemas->writer($type, include_namespaces => 0)
201 ->($doc, $value);
202 26 ▶ $el->addChild($child) if $child;
Branch: 1 branch
BranchTrueFalseTotal
if $child 26 0 26
203 26 $el;
204 }
205  
206  
207 2 my $id_count = 0;
208 sub href($$$)
209 6 ▶{ my ($self, $name, $to, $prefid) = @_;
Subroutine href: called CC=3 SCAR=11.0
Pod undocumented
210 6 my $id = $to->getAttribute('id');
211 6 ▶ unless(defined $id)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $id) 2 4 6
212 2 ▶ { $id = defined $prefid ? $prefid : 'id-'.++$id_count;
Branch: 1 branch
BranchTrueFalseTotal
defined $prefid ? : 1 1 2
213 2 $to->setAttribute(id => $id);
214 }
215  
216 6 my $ename = $self->prefixed($name);
217 6 my $el = $self->{enc}{doc}->createElement($ename);
218 6 $el->setAttribute(href => "#$id");
219 6 $el;
220 }
221  
222  
223 sub nil($;$)
224 3 ▶{ my $self = shift;
Subroutine nil: called CC=4 SCAR=13.9
Pod undocumented
225 3 ▶ my ($type, $name) = @_==2 ? @_ : (undef, $_[0]);
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 ? : 1 2 3
226 3 my ($ns, $local) = unpack_type $name;
227  
228 3 my $doc = $self->{enc}{doc};
229 3 ▶ my $el = $ns
Branch: 1 branch
BranchTrueFalseTotal
$ns ? : 2 1 3
230 ? $doc->createElementNS($ns, $local)
231 : $doc->createElement($local);
232  
233 3 $el->setAttribute($self->prefixed(SCHEMA2001i, 'nil'), 'true');
234 3 ▶ $el->setAttribute($self->prefixed(SCHEMA2001i, 'type')
Branch: 1 branch
BranchTrueFalseTotal
if $type 1 2 3
235 , $self->prefixed($type)) if $type;
236  
237 3 $el;
238 }
239  
240  
241 sub array($$$@)
242 18 ▶{ my ($self, $name, $itemtype, $array, %opts) = @_;
Subroutine array: called CC=20 SCAR=30.0
Pod undocumented
243  
244 18 my $enc = $self->{enc};
245 18 my $doc = $enc->{doc};
246  
247 18 ▶ my $offset = $opts{offset} || 0;
Condition100%2/2
$opts{'offset'} || 0
l!l
414
MC/DC100%1/1
$opts{'offset'} || 0
$opts{'offset'}
Truth table100%2/2
A
A= $opts{'offset'}
Aresult
11
00
248 18 my $slice = $opts{slice};
249  
250 18 my ($min, $size) = ($offset, scalar @$array);
251 18 ▶ $min++ while $min <= $size && !defined $array->[$min];
Branch: 1 branch
BranchTrueFalseTotal
$min <= $size and not defined $array->[$min] and do { ++$min } 6 18 24
Condition66%2/3
$min <= $size and not defined $array->[$min]
!ll&&!rl&&r
0186
MC/DC50%1/2
$min <= $size and not defined $array->[$min]
$min <= $size not defined $array->[$min]
Truth table66%2/3
A and not(B)
A= $min <= $sizeB= not defined $array->[$min]
ABresult
0X0
100
111
252  
253 18 ▶ my $max = defined $slice && $min+$slice-1 < $size ? $min+$slice-1 : $size;
Branch: 1 branch
BranchTrueFalseTotal
defined $slice && $min + $slice - 1 < $size ? : 5 13 18
Condition66%2/3
defined $slice and $min + $slice - 1 < $size
!ll&&!rl&&r
1305
MC/DC50%1/2
defined $slice and $min + $slice - 1 < $size
defined $slice $min + $slice - 1 < $size
Truth table66%2/3
A and B
A= defined $sliceB= $min + $slice - 1 < $size
ABresult
0X0
100
111
254 18 ▶ $max-- while $min <= $max && !defined $array->[$max];
Branch: 1 branch
BranchTrueFalseTotal
$min <= $max and not defined $array->[$max] and do { --$max } 17 18 35
Condition66%2/3
$min <= $max and not defined $array->[$max]
!ll&&!rl&&r
01817
MC/DC50%1/2
$min <= $max and not defined $array->[$max]
$min <= $max not defined $array->[$max]
Truth table66%2/3
A and not(B)
A= $min <= $maxB= not defined $array->[$max]
ABresult
0X0
100
111
255  
256 18 my $sparse = 0;
257 18 ▶ for(my $i = $min; $i < $max; $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $max) 26 16 42
258 26 ▶ { next if defined $array->[$i];
Branch: 1 branch
BranchTrueFalseTotal
if defined $array->[$i] 24 2 26
259 2 $sparse = 1;
260 2 last;
261 }
262  
263 18 ▶ my $elname = $self->prefixed(defined $name ? $name : (SOAP11ENC, 'Array'));
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 1 17 18
264 18 my $el = $doc->createElement($elname);
265 18 ▶ my $nested = $opts{nested_array} || '';
Condition100%2/2
$opts{'nested_array'} || ''
l!l
216
MC/DC100%1/1
$opts{'nested_array'} || ''
$opts{'nested_array'}
Truth table100%2/2
A
A= $opts{'nested_array'}
Aresult
11
00
266 18 my $type = $self->prefixed($itemtype)."$nested\[$size]";
267  
268 18 ▶ $el->setAttribute(id => $opts{id}) if defined $opts{id};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"id"} 5 13 18
269 my $at = $opts{array_type} ? $opts{arrayType}
270 18 ▶ : $self->prefixed(SOAP11ENC, 'arrayType');
Branch: 1 branch
BranchTrueFalseTotal
$opts{'array_type'} ? : 0 18 18
271 18 ▶ $el->setAttribute($at, $type) if defined $at;
Branch: 1 branch
BranchTrueFalseTotal
if defined $at 18 0 18
272  
273 18 ▶ if($sparse)
Branch: 1 branch
BranchTrueFalseTotal
if ($sparse) { } 2 16 18
274 2 { my $placeition = $self->prefixed(SOAP11ENC, 'position');
275 2 ▶ for(my $r = $min; $r <= $max; $r++)
Branch: 1 branch
BranchTrueFalseTotal
if ($r <= $max) 6 2 8
276 6 ▶ { my $row = $array->[$r] or next;
Branch: 1 branch
BranchTrueFalseTotal
my $row = $array->[$r] or next 4 2 6
277 4 my $node = $row->cloneNode(1);
278 4 $node->setAttribute($placeition, "[$r]");
279 4 $el->addChild($node);
280 }
281 }
282 else
283 16 ▶ { $el->setAttribute($self->prefixed(SOAP11ENC, 'offset'), "[$min]")
Branch: 1 branch
BranchTrueFalseTotal
if $min > 0 6 10 16
284 if $min > 0;
285 16 $el->addChild($array->[$_]) for $min..$max;
286 }
287  
288 18 $el;
289 }
290  
291  
292 sub multidim($$$@)
293 3 ▶{ my ($self, $name, $itemtype, $array, %opts) = @_;
Subroutine multidim: called CC=7 SCAR=19.5
Pod undocumented
294 3 my $enc = $self->{enc};
295 3 my $doc = $enc->{doc};
296  
297 # determine dimensions
298 3 my @dims;
299 3 ▶ for(my $dim = $array; ref $dim eq 'ARRAY'; $dim = $dim->[0])
Branch: 1 branch
BranchTrueFalseTotal
if (ref $dim eq "ARRAY") 6 3 9
300 6 { push @dims, scalar @$dim;
301 }
302  
303 3 my $sparse = $self->_check_multidim($array, \@dims, '');
304 3 ▶ my $elname = $self->prefixed(defined $name ? $name : (SOAP11ENC, 'Array'));
Branch: 1 branch
BranchTrueFalseTotal
defined $name ? : 0 3 3
305 3 my $el = $doc->createElement($elname);
306 3 my $type = $self->prefixed($itemtype) . '['.join(',', @dims).']';
307  
308 3 ▶ $el->setAttribute(id => $opts{id}) if defined $opts{id};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"id"} 0 3 3
309 3 $el->setAttribute($self->prefixed(SOAP11ENC, 'arrayType'), $type);
310  
311 3 my @data = $self->_flatten_multidim($array, \@dims, '');
312 3 ▶ if($sparse)
Branch: 1 branch
BranchTrueFalseTotal
if ($sparse) { } 2 1 3
313 2 { my $placeition = $self->prefixed(SOAP11ENC, 'position');
314 2 ▶ while(@data)
Branch: 1 branch
BranchTrueFalseTotal
if (@data) 6 2 8
315 6 { my ($place, $field) = (shift @data, shift @data);
316 6 my $node = $field->cloneNode(1);
317 6 $node->setAttribute($placeition, "[$place]");
318 6 $el->addChild($node);
319 }
320 }
321 else
322 1 { $el->addChild($_) for odd_elements @data;
323 }
324  
325 3 $el;
326 }
327  
328 sub _check_multidim($$$)
329 10 ▶{ my ($self, $array, $dims, $loc) = @_;
Subroutine _check_multidim: called CC=8 SCAR=21.0
330 10 my @dims = @$dims;
331  
332 10 my $expected = shift @dims;
333 10 ▶ @$array <= $expected
Branch: 1 branch
BranchTrueFalseTotal
@$array <= $expected or &error(&__x("dimension at ({location}) is {size}, larger than size {expect} of first row", "location", $loc, "size", scalar @$array, "expect", $expected)) 10 0 10
334 or error __x"dimension at ({location}) is {size}, larger than size {expect} of first row"
335 , location => $loc, size => scalar(@$array), expect => $expected;
336  
337 10 my $sparse = 0;
338 10 ▶ foreach (my $x = 0; $x < $expected; $x++)
Branch: 1 branch
BranchTrueFalseTotal
if ($x < $expected) 56 10 66
339 56 { my $el = $array->[$x];
340 56 ▶ my $cell = length $loc ? "$loc,$x" : $x;
Branch: 1 branch
BranchTrueFalseTotal
length $loc ? : 42 14 56
341  
342 56 ▶ if(!defined $el) { $sparse++ }
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $el) { } 37 19 56
elsif (@dims == 0) { } 12 7 19
elsif (ref $el eq 'ARRAY') { } 7 0 7
343 elsif(@dims==0) # bottom level
344 12 ▶ { UNIVERSAL::isa($el, 'XML::LibXML::Element')
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($el, "XML::LibXML::Element") or &error(&__x("array element at ({location}) shall be a XML element or undef, is {value}", "location", $cell, "value", $el)) 12 0 12
345 or error __x"array element at ({location}) shall be a XML element or undef, is {value}"
346 , location => $cell, value => $el;
347 }
348 elsif(ref $el eq 'ARRAY')
349 7 { $sparse += $self->_check_multidim($el, \@dims, $cell);
350 }
351 else
352 0 { error __x"array at ({location}) expects ARRAY reference, is {value}"
353 , location => $cell, value => $el;
354 }
355 }
356  
357 10 $sparse;
358 }
359  
360 sub _flatten_multidim($$$)
361 10 ▶{ my ($self, $array, $dims, $loc) = @_;
Subroutine _flatten_multidim: called CC=5 SCAR=16.1
362 10 my @dims = @$dims;
363  
364 10 my $expected = shift @dims;
365 10 my @data;
366 10 ▶ foreach (my $x = 0; $x < $expected; $x++)
Branch: 1 branch
BranchTrueFalseTotal
if ($x < $expected) 56 10 66
367 56 { my $el = $array->[$x];
368 56 ▶ defined $el or next;
Branch: 1 branch
BranchTrueFalseTotal
defined $el or next 19 37 56
369  
370 19 ▶ my $cell = length $loc ? "$loc,$x" : $x;
Branch: 1 branch
BranchTrueFalseTotal
length $loc ? : 12 7 19
371 19 ▶ push @data, @dims==0 ? ($cell, $el) # deepest dim
Branch: 1 branch
BranchTrueFalseTotal
@dims == 0 ? : 12 7 19
372 : $self->_flatten_multidim($el, \@dims, $cell);
373 }
374  
375 10 @data;
376 }
377  
378 #--------------------------------------------------
379  
380 sub rpcDecode(@)
381 0 ▶{ my $self = shift;
Subroutine rpcDecode: not called CC=16 SCAR=56.1
Pod undocumented
382 0 my @nodes = grep $_->isa('XML::LibXML::Element'), @_;
383 0 my $data = $self->_dec(\@nodes);
384  
385 #XXX MO: no idea why this is needed:
386 0 foreach my $d (@$data)
387 0 ▶{ next unless $d->{_NAME};
Branch: 1 branch
BranchTrueFalseTotal
unless $d->{"_NAME"} 0 0 0
388 0 $d = { $d->{_NAME} => $d };
389 }
390
391 0 my ($index, $hrefs) = ({}, []);
392 0 $self->_dec_find_ids_hrefs($index, $hrefs, \$data);
393 0 $self->_dec_resolve_hrefs($index, $hrefs);
394  
395 0 ▶ $data = $self->_dec_simplify_tree($data)
Branch: 1 branch
BranchTrueFalseTotal
if $simplify 0 0 0
396 if $simplify;
397  
398 0 ▶ ref $data eq 'ARRAY'
Branch: 1 branch
BranchTrueFalseTotal
ref $data eq "ARRAY" or return $data 0 0 0
399 or return $data;
400  
401 0 ▶ @$data > 1
Branch: 1 branch
BranchTrueFalseTotal
@$data > 1 or return $data->[0] 0 0 0
402 or return $data->[0];
403  
404 # find the root element(s)
405 0 my @roots;
406 0 ▶ for(my $i = 0; $i < @_ && $i < @$data; $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @_ and $i < @$data) 0 0 0
Condition0%0/3
$i < @_ and $i < @$data
!ll&&!rl&&r
000
MC/DC0%0/2
$i < @_ and $i < @$data
$i < @_ $i < @$data
Truth table0%0/3
A and B
A= $i < @_B= $i < @$data
ABresult
0X0
100
111
407 0 { my $root = $nodes[$i]->getAttributeNS(SOAP11ENC, 'root');
408 0 ▶ next if defined $root && $root==0;
Branch: 1 branch
BranchTrueFalseTotal
if defined $root and $root == 0 0 0 0
Condition0%0/3
defined $root and $root == 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $root and $root == 0
defined $root $root == 0
Truth table0%0/3
A and B
A= defined $rootB= $root == 0
ABresult
0X0
100
111
409 0 push @roots, $data->[$i];
410 }
411  
412 0 ▶ my $root_type = @roots ? $roots[0]->{_TYPE} : undef;
Branch: 1 branch
BranchTrueFalseTotal
@roots ? : 0 0 0
413  
414 # address parameters by name
415 # On the top-level, we can strip on level. Some elements may appear
416 # more than once.
417 0 my %h;
418 0 ▶ foreach my $param (@roots ? @roots : @$data)
Branch: 1 branch
BranchTrueFalseTotal
@roots ? : 0 0 0
419 0 { delete $param->{_TYPE};
420 0 my ($k, $v) = %$param;
421 0 ▶ if(! exists $h{$k}) { $h{$k} = $v }
Branch: 2 branches
BranchTrueFalseTotal
if (not exists $h{$k}) { } 0 0 0
elsif (builtin::reftype($h{$k}) eq 'ARRAY') { } 0 0 0
422 0 elsif(reftype $h{$k} eq 'ARRAY') { push @{$h{$k}}, $v }
423 0 else { $h{$k} = [ $h{$k}, $v ] }
424 }
425  
426 0 ▶ $h{_TYPE} = $root_type
Branch: 1 branch
BranchTrueFalseTotal
if $root_type 0 0 0
427 if $root_type;
428  
429 0 \%h;
430 }
431  
432 sub _dec_reader($$@)
433 0 ▶{ my ($self, $node, $type) = splice @_, 0, 3;
Subroutine _dec_reader: not called CC=5 SCAR=34.0
434  
435 # We must decode the prefix from the $node context
436 0 ▶ if(substr($type, 0, 1) ne '{')
Branch: 1 branch
BranchTrueFalseTotal
if (substr($type, 0, 1) ne "{") 0 0 0
437 0 ▶ { my ($prefix, $local) = $type =~ m/^(.*?)\:(.*)/ ? ($1, $2) : ('',$type);
Branch: 1 branch
BranchTrueFalseTotal
$type =~ /^(.*?)\:(.*)/ ? : 0 0 0
438 0 ▶ $type = pack_type $node->lookupNamespaceURI($prefix) // '', $local;
Condition0%0/2
$node->lookupNamespaceURI($prefix) // ""
l!l
00
MC/DC0%0/1
$node->lookupNamespaceURI($prefix) // ""
$node->lookupNamespaceURI($prefix)
Truth table0%0/2
A
A= $node->lookupNamespaceURI($prefix)
Aresult
11
00
439 }
440  
441 0 ▶ my $r = try {
Subroutine __ANON__: not called CC=1 SCAR=6.9
442 0 $self->schemas->reader($type
443 , element => type_of_node($node), is_type => 1, @_);
444 0 };
445 0 ▶ $r || sub { shift };
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$r or sub { shift(); } 0 0 0
446 }
447  
448 sub _dec($;$$$)
449 0 ▶{ my ($self, $nodes, $basetype, $offset, $dims) = @_;
Subroutine _dec: not called CC=15 SCAR=54.8
450 0 my $schemas = $self->schemas;
451 0 my $nss = $schemas->namespaces;
452  
453 0 my @res;
454 0 ▶ $#res = $offset-1 if defined $offset;
Branch: 1 branch
BranchTrueFalseTotal
if defined $offset 0 0 0
455  
456 0 foreach my $node (@$nodes)
457 0 ▶ { my $ns = $node->namespaceURI || '';
Condition0%0/2
$node->namespaceURI || ''
l!l
00
MC/DC0%0/1
$node->namespaceURI || ''
$node->namespaceURI
Truth table0%0/2
A
A= $node->namespaceURI
Aresult
11
00
458  
459 0 my $label = type_of_node $node;
460 0 my $place;
461 0 ▶ if($dims)
Branch: 1 branch
BranchTrueFalseTotal
if ($dims) 0 0 0
462 0 { my $pos = $node->getAttributeNS(SOAP11ENC, 'position');
463 0 ▶ if($pos && $pos =~ m/^\[([\d,]+)\]/ )
Branch: 1 branch
BranchTrueFalseTotal
if ($pos and $pos =~ /^\[([\d,]+)\]/) 0 0 0
Condition0%0/3
$pos and $pos =~ /^\[([\d,]+)\]/
!ll&&!rl&&r
000
MC/DC0%0/2
$pos and $pos =~ /^\[([\d,]+)\]/
$pos $pos =~ /^\[([\d,]+)\]/
Truth table0%0/3
A and B
A= $posB= $pos =~ /^\[([\d,]+)\]/
ABresult
0X0
100
111
464 0 { my @pos = split /\,/, $1;
465 0 $place = \$res[shift @pos];
466 0 ▶ $place = \(($$place ||= [])->[shift @pos]) while @pos;
Branch: 1 branch
BranchTrueFalseTotal
@pos and do { $place = \($$place ||= [])->[shift @pos] } 0 0 0
Condition0%0/2
$$place ||= []
l!l
00
MC/DC0%0/1
$$place ||= []
$$place
Truth table0%0/2
A
A= $$place
Aresult
11
00
467 }
468 }
469  
470 0 ▶ unless($place)
Branch: 1 branch
BranchTrueFalseTotal
unless ($place) 0 0 0
471 0 { push @res, undef;
472 0 $place = \$res[-1];
473 }
474  
475 0 ▶ if(my $href = $node->getAttribute('href') || '')
Branch: 1 branch
BranchTrueFalseTotal
if (my $href = $node->getAttribute("href") || "") 0 0 0
Condition0%0/2
$node->getAttribute('href') || ''
l!l
00
MC/DC0%0/1
$node->getAttribute('href') || ''
$node->getAttribute('href')
Truth table0%0/2
A
A= $node->getAttribute('href')
Aresult
11
00
476 0 { $$place = { $label => { href => $href } };
477 0 next;
478 }
479  
480 0 ▶ if($ns ne SOAP11ENC)
Branch: 1 branch
BranchTrueFalseTotal
if ($ns ne "http://schemas.xmlsoap.org/soap/encoding/") 0 0 0
481 0 { my $typedef = $node->getAttributeNS(SCHEMA2001i, 'type');
482 0 ▶ if($typedef)
Branch: 1 branch
BranchTrueFalseTotal
if ($typedef) 0 0 0
483 0 { $$place = $self->_dec_typed($node, $typedef);
484 0 next;
485 }
486  
487 0 $$place = $self->_dec_other($node, $basetype);
488 0 next;
489 }
490  
491 0 my $local = $node->localName;
492 0 ▶ if($local eq 'Array')
Branch: 1 branch
BranchTrueFalseTotal
if ($local eq "Array") 0 0 0
493 0 { $$place = $self->_dec_other($node, $basetype);
494 0 next;
495 }
496  
497 0 $$place = $self->_dec_soapenc($node, pack_type($ns, $local));
498 }
499  
500 0 \@res;
501 }
502  
503 sub _dec_typed($$$)
504 0 ▶{ my ($self, $node, $type, $index) = @_;
Subroutine _dec_typed: not called CC=3 SCAR=24.8
505  
506 0 my $full = type_of_node $node;
507 0 my $read = $self->_dec_reader($node, $type);
508 0 my $child = $read->($node);
509 0 ▶ my $data = ref $child eq 'HASH' ? $child : { _ => $child };
Branch: 1 branch
BranchTrueFalseTotal
ref $child eq 'HASH' ? : 0 0 0
510 0 $data->{_TYPE} = $type;
511 0 $data->{_NAME} = type_of_node $node;
512  
513 0 my $id = $node->getAttribute('id');
514 0 ▶ $data->{id} = $id if defined $id;
Branch: 1 branch
BranchTrueFalseTotal
if defined $id 0 0 0
515  
516 0 $data;
517 }
518  
519 sub _dec_other($$)
520 0 ▶{ my ($self, $node, $basetype) = @_;
Subroutine _dec_other: not called CC=11 SCAR=48.8
521 0 my $local = $node->localName;
522  
523 0 my $data;
524 0 ▶ my $type = $basetype || type_of_node $node;
Condition0%0/3
$basetype || &type_of_node($node)
l!l&&r!l&&!r
000
MC/DC0%0/2
$basetype || &type_of_node($node)
$basetype &type_of_node($node)
Truth table0%0/3
A || B
A= $basetypeB= &type_of_node($node)
ABresult
1X1
011
000
525 0 ▶ my $read = try { $self->_dec_reader($node, $type) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
526 0 ▶ if($@)
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 0 0
527 { # warn $@->wasFatal->message; #--> element not found
528 # Element not known, so we must autodetect the type
529 0 my @childs = grep $_->isa('XML::LibXML::Element'), $node->childNodes;
530 0 ▶ if(@childs)
Branch: 1 branch
BranchTrueFalseTotal
if (@childs) { } 0 0 0
531 0 { my ($childbase, $dims);
532 0 ▶ if($type =~ m/(.+?)\s*\[([\d,]+)\]$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($type =~ /(.+?)\s*\[([\d,]+)\]$/) 0 0 0
533 0 { $childbase = $1;
534 0 $dims = ($2 =~ tr/,//) + 1;
535 }
536 0 my $dec_childs = $self->_dec(\@childs, $childbase, 0, $dims);
537  
538 0 my $key = $local;
539 0 ▶ $key = '_' if $key eq 'Array'; # simplifies better
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "Array" 0 0 0
540 0 ▶ $data = { $key => $dec_childs } if $dec_childs;
Branch: 1 branch
BranchTrueFalseTotal
if $dec_childs 0 0 0
541 }
542 else
543 0 { $data->{_} = $node->textContent;
544 0 ▶ $data->{_TYPE} = $basetype if $basetype;
Branch: 1 branch
BranchTrueFalseTotal
if $basetype 0 0 0
545 }
546 }
547 else
548 0 { my @x = $read->($node);
549 0 $data = $x[0];
550 0 ▶ $data = { _ => $data } if ref $data ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $data ne "HASH" 0 0 0
551 0 ▶ $data->{_TYPE} = $basetype if $basetype;
Branch: 1 branch
BranchTrueFalseTotal
if $basetype 0 0 0
552 }
553  
554 0 $data->{_NAME} = type_of_node $node;
555  
556 0 my $id = $node->getAttribute('id');
557 0 ▶ $data->{id} = $id if defined $id;
Branch: 1 branch
BranchTrueFalseTotal
if defined $id 0 0 0
558  
559 0 ($local => $data);
560 }
561  
562 sub _dec_soapenc($$)
563 0 ▶{ my ($self, $node, $type) = @_;
Subroutine _dec_soapenc: not called CC=3 SCAR=24.8
564 0 ▶ my $reader = $self->_dec_reader($node, $type)
Branch: 1 branch
BranchTrueFalseTotal
my $reader = $self->_dec_reader($node, $type) or return $node 0 0 0
565 or return $node;
566 0 my $data = $reader->($node);
567 0 ▶ $data = { _ => $data } if ref $data ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $data ne "HASH" 0 0 0
568 0 $data->{_TYPE} = $type;
569 0 $data;
570 }
571  
572 sub _dec_find_ids_hrefs($$$)
573 0 ▶{ my ($self, $index, $hrefs, $node) = @_;
Subroutine _dec_find_ids_hrefs: not called CC=13 SCAR=52.0
574 0 ▶ ref $$node or return;
Branch: 1 branch
BranchTrueFalseTotal
ref $$node or return 0 0 0
575  
576 0 ▶ if(ref $$node eq 'ARRAY')
Branch: 3 branches
BranchTrueFalseTotal
if (ref $$node eq 'ARRAY') { } 0 0 0
elsif (ref $$node eq 'HASH') { } 0 0 0
elsif (UNIVERSAL::isa($$node, 'XML::LibXML::Element')) { } 0 0 0
577 0 { foreach my $child (@$$node)
578 0 { $self->_dec_find_ids_hrefs($index, $hrefs, \$child);
579 }
580 }
581 elsif(ref $$node eq 'HASH')
582 { $index->{$$node->{id}} = $$node
583 0 ▶ if defined $$node->{id};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$node->{"id"} 0 0 0
584  
585 0 ▶ if(my $href = $$node->{href})
Branch: 1 branch
BranchTrueFalseTotal
if (my $href = $$node->{"href"}) 0 0 0
586 0 ▶ { push @$hrefs, $href => $node if $href =~ s/^#//;
Branch: 1 branch
BranchTrueFalseTotal
if $href =~ s/^#// 0 0 0
587 }
588  
589 0 foreach my $k (keys %$$node)
590 0 { $self->_dec_find_ids_hrefs($index, $hrefs, \( $$node->{$k} ));
591 }
592 }
593 elsif(UNIVERSAL::isa($$node, 'XML::LibXML::Element'))
594 0 { my $search = XML::LibXML::XPathContext->new($$node);
595 $index->{$_->value} = $_->getOwnerElement
596 0 for $search->findnodes('.//@id');
597  
598 # we cannot restore deep hrefs, so only top level
599 0 ▶ if(my $href = $$node->getAttribute('href'))
Branch: 1 branch
BranchTrueFalseTotal
if (my $href = $$node->getAttribute("href")) 0 0 0
600 0 ▶ { push @$hrefs, $href => $node if $href =~ s/^#//;
Branch: 1 branch
BranchTrueFalseTotal
if $href =~ s/^#// 0 0 0
601 }
602 }
603 }
604  
605 sub _dec_resolve_hrefs($$)
606 0 ▶{ my ($self, $index, $hrefs) = @_;
Subroutine _dec_resolve_hrefs: not called CC=3 SCAR=24.8
607  
608 0 ▶ while(@$hrefs)
Branch: 1 branch
BranchTrueFalseTotal
if (@$hrefs) 0 0 0
609 0 { my ($to, $where) = (shift @$hrefs, shift @$hrefs);
610 0 my $dest = $index->{$to};
611 0 ▶ unless($dest)
Branch: 1 branch
BranchTrueFalseTotal
unless ($dest) 0 0 0
612 0 { warning __x"cannot find id for href {name}", name => $to;
613 0 next;
614 }
615 0 $$where = $dest;
616 }
617 }
618  
619 sub _dec_array_hook($$$$$)
620 0 ▶{ my ($self, $node, $args, $where, $local, $r, $fulltype) = @_;
Subroutine _dec_array_hook: not called CC=9 SCAR=45.0
621  
622 0 ▶ my $at = $node->getAttributeNS(SOAP11ENC, 'arrayType')
Branch: 1 branch
BranchTrueFalseTotal
my $at = $node->getAttributeNS("http://schemas.xmlsoap.org/soap/encoding/", "arrayType") || $node->getAttributeNS("http://schemas.xmlsoap.org/wsdl/", "arrayType") or return $node 0 0 0
Condition0%0/3
$node->getAttributeNS('http://schemas.xmlsoap.org/soap/encoding/', 'arrayType') || $node->getAttributeNS('http://schemas.xmlsoap.org/wsdl/', 'arrayType')
l!l&&r!l&&!r
000
MC/DC0%0/2
$node->getAttributeNS('http://schemas.xmlsoap.org/soap/encoding/', 'arrayType') || $node->getAttributeNS('http://schemas.xmlsoap.org/wsdl/', 'arrayType')
$node->getAttributeNS('http://schemas.xmlsoap.org/soap/encoding/', 'arrayType') $node->getAttributeNS('http://schemas.xmlsoap.org/wsdl/', 'arrayType')
Truth table0%0/3
A || B
A= $node->getAttributeNS('http://schemas.xmlsoap.org/soap/encoding/', 'arrayType')B= $node->getAttributeNS('http://schemas.xmlsoap.org/wsdl/', 'arrayType')
ABresult
1X1
011
000
623 || $node->getAttributeNS(WSDL11, 'arrayType')
624 or return $node;
625  
626 0 ▶ $at =~ m/^(.*) \s* \[ ([\d,]+)? \] $/x
Branch: 1 branch
BranchTrueFalseTotal
$at =~ /^(.*) \s* \[ ([\d,]+)? \] $/x or return $node 0 0 0
627 or return $node;
628  
629 0 my ($preftype, $dims) = ($1, $2);
630 0 ▶ my @dims = defined $dims ? split /\,/, $dims : ();
Branch: 1 branch
BranchTrueFalseTotal
defined $dims ? : 0 0 0
631
632 0 my $basetype;
633 0 ▶ if(index($preftype, ':') >= 0)
Branch: 1 branch
BranchTrueFalseTotal
if (index($preftype, ':') != -1) { } 0 0 0
634 0 { my ($prefix, $local) = split /\:/, $preftype, 2;
635 0 $basetype = pack_type $node->lookupNamespaceURI($prefix), $local;
636 }
637 else
638 0 { $basetype = pack_type '', $preftype;
639 }
640  
641 0 my $table;
642 0 ▶ if(@dims < 2)
Branch: 1 branch
BranchTrueFalseTotal
if (@dims < 2) { } 0 0 0
643 0 { $table = $self->_dec_array_one($node, $basetype, $dims[0]);
644 }
645 else
646 0 ▶ { my $first = first {$_->isa('XML::LibXML::Element')} $node->childNodes;
Subroutine __ANON__: not called CC=1 SCAR=6.9
647 0 ▶ $table = $first && $first->getAttributeNS(SOAP11ENC, 'position')
Branch: 1 branch
BranchTrueFalseTotal
$first && $first->getAttributeNS('http://schemas.xmlsoap.org/soap/encoding/', 'position') ? : 0 0 0
Condition0%0/3
$first and $first->getAttributeNS("http://schemas.xmlsoap.org/soap/encoding/", "position")
!ll&&!rl&&r
000
MC/DC0%0/2
$first and $first->getAttributeNS("http://schemas.xmlsoap.org/soap/encoding/", "position")
$first $first->getAttributeNS("http://schemas.xmlsoap.org/soap/encoding/", "position")
Truth table0%0/3
A and B
A= $firstB= $first->getAttributeNS("http://schemas.xmlsoap.org/soap/encoding/", "position")
ABresult
0X0
100
111
648 ? $self->_dec_array_multisparse($node, $basetype, \@dims)
649 : $self->_dec_array_multi($node, $basetype, \@dims);
650 }
651  
652 0 (type_of_node($node) => $table);
653 }
654  
655 sub _dec_array_one($$;$)
656 0 ▶{ my ($self, $node, $basetype, $size) = @_;
Subroutine _dec_array_one: not called CC=4 SCAR=30.0
657  
658 0 ▶ my $off = $node->getAttributeNS(SOAP11ENC, 'offset') || '[0]';
Condition0%0/2
$node->getAttributeNS('http://schemas.xmlsoap.org/soap/encoding/', 'offset') || '[0]'
l!l
00
MC/DC0%0/1
$node->getAttributeNS('http://schemas.xmlsoap.org/soap/encoding/', 'offset') || '[0]'
$node->getAttributeNS('http://schemas.xmlsoap.org/soap/encoding/', 'offset')
Truth table0%0/2
A
A= $node->getAttributeNS('http://schemas.xmlsoap.org/soap/encoding/', 'offset')
Aresult
11
00
659 0 ▶ $off =~ m/^\[(\d+)\]$/ or return $node;
Branch: 1 branch
BranchTrueFalseTotal
$off =~ /^\[(\d+)\]$/ or return $node 0 0 0
660  
661 0 my $offset = $1;
662 0 my @childs = grep $_->isa('XML::LibXML::Element'), $node->childNodes;
663 0 my $array = $self->_dec(\@childs, $basetype, $offset, 1);
664 0 ▶ $#$array = $size -1 if $size; # resize array to specified size
Branch: 1 branch
BranchTrueFalseTotal
if $size 0 0 0
665 0 $array;
666 }
667  
668 sub _dec_array_multisparse($$$)
669 0 ▶{ my ($self, $node, $basetype, $dims) = @_;
Subroutine _dec_array_multisparse: not called CC=1 SCAR=6.9
670  
671 0 my @childs = grep $_->isa('XML::LibXML::Element'), $node->childNodes;
672 0 my $array = $self->_dec(\@childs, $basetype, 0, scalar(@$dims));
673 0 $array;
674 }
675  
676 sub _dec_array_multi($$$)
677 0 ▶{ my ($self, $node, $basetype, $dims) = @_;
Subroutine _dec_array_multi: not called CC=1 SCAR=6.9
678  
679 0 my @childs = grep $_->isa('XML::LibXML::Element'), $node->childNodes;
680 0 $self->_dec_array_multi_slice(\@childs, $basetype, $dims);
681 }
682  
683 sub _dec_array_multi_slice($$$)
684 0 ▶{ my ($self, $childs, $basetype, $dims) = @_;
Subroutine _dec_array_multi_slice: not called CC=2 SCAR=17.9
685 0 ▶ if(@$dims==1)
Branch: 1 branch
BranchTrueFalseTotal
if (@$dims == 1) 0 0 0
686 0 { my @col = splice @$childs, 0, $dims->[0];
687 0 return $self->_dec(\@col, $basetype);
688 }
689 0 my ($rows, @dims) = @$dims;
690  
691 0 [map $self->_dec_array_multi_slice($childs, $basetype, \@dims), 1..$rows];
692 }
693  
694 sub _dec_simplify_tree($@)
695 0 ▶{ my ($self, $tree, %opts) = @_;
Subroutine _dec_simplify_tree: not called CC=2 SCAR=17.9
696 0 ▶ defined $tree or return ();
Branch: 1 branch
BranchTrueFalseTotal
defined $tree or return () 0 0 0
697 0 $self->{dec}{_simple_recurse} = {};
698 0 $self->_dec_simple($tree, \%opts);
699 }
700  
701 sub _dec_simple($$)
702 0 ▶{ my ($self, $tree, $opts) = @_;
Subroutine _dec_simple: not called CC=18 SCAR=58.3
703  
704 0 ▶ ref $tree
Branch: 1 branch
BranchTrueFalseTotal
ref $tree or return $tree 0 0 0
705 or return $tree;
706  
707 return $tree
708 0 ▶ if $self->{dec}{_simple_recurse}{$tree};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"dec"}{"_simple_recurse"}{$tree} 0 0 0
709  
710 0 $self->{dec}{_simple_recurse}{$tree}++;
711  
712 0 ▶ if(ref $tree eq 'ARRAY')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $tree eq "ARRAY") 0 0 0
713 0 { my @a = map $self->_dec_simple($_, $opts), @$tree;
714 0 ▶ return $a[0] if @a==1;
Branch: 1 branch
BranchTrueFalseTotal
if @a == 1 0 0 0
715  
716 # array of hash with each one element becomes hash
717 0 my %out;
718 0 foreach my $hash (@a)
719 0 ▶ { ref $hash eq 'HASH' && keys %$hash==1
Branch: 1 branch
BranchTrueFalseTotal
ref $hash eq "HASH" and keys %$hash == 1 or return \@a 0 0 0
Condition0%0/3
ref $hash eq "HASH" and keys %$hash == 1
!ll&&!rl&&r
000
MC/DC0%0/2
ref $hash eq "HASH" and keys %$hash == 1
ref $hash eq "HASH" keys %$hash == 1
Truth table0%0/3
A and B
A= ref $hash eq "HASH"B= keys %$hash == 1
ABresult
0X0
100
111
720 or return \@a;
721  
722 0 my ($name, $value) = each %$hash;
723 0 ▶ if(!exists $out{$name}) { $out{$name} = $value }
Branch: 2 branches
BranchTrueFalseTotal
if (not exists $out{$name}) { } 0 0 0
elsif (ref $out{$name} eq 'ARRAY') { } 0 0 0
724 elsif(ref $out{$name} eq 'ARRAY')
725 { $out{$name} = [ $out{$name} ] # array of array: keep []
726 0 ▶ if ref $out{$name}[0] ne 'ARRAY' && ref $value eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $out{$name}[0] ne "ARRAY" and ref $value eq "ARRAY" 0 0 0
Condition0%0/3
ref $out{$name}[0] ne "ARRAY" and ref $value eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $out{$name}[0] ne "ARRAY" and ref $value eq "ARRAY"
ref $out{$name}[0] ne "ARRAY" ref $value eq "ARRAY"
Truth table0%0/3
A and B
A= ref $out{$name}[0] ne "ARRAY"B= ref $value eq "ARRAY"
ABresult
0X0
100
111
727 0 push @{$out{$name}}, $value;
728 }
729 0 else { $out{$name} = [ $out{$name}, $value ] }
730 }
731 0 return \%out;
732 }
733  
734 0 ▶ ref $tree eq 'HASH'
Branch: 1 branch
BranchTrueFalseTotal
ref $tree eq "HASH" or return $tree 0 0 0
735 or return $tree;
736  
737 0 foreach my $k (keys %$tree)
738 0 ▶ { if($k =~ m/^(?:_NAME$|_TYPE$|id$)/) { delete $tree->{$k} }
Branch: 2 branches
BranchTrueFalseTotal
if ($k =~ /^(?:_NAME$|_TYPE$|id$)/) { } 0 0 0
elsif (ref $tree->{$k}) { } 0 0 0
739 elsif(ref $tree->{$k})
740 0 { $tree->{$k} = $self->_dec_simple($tree->{$k}, $opts);
741 }
742 }
743  
744 0 delete $self->{dec}{_simple_recurse}{$tree};
745  
746 0 ▶ keys(%$tree)==1 && exists $tree->{_} ? $tree->{_} : $tree;
Branch: 1 branch
BranchTrueFalseTotal
keys %$tree == 1 && exists $tree->{'_'} ? : 0 0 0
Condition0%0/3
keys %$tree == 1 and exists $tree->{"_"}
!ll&&!rl&&r
000
MC/DC0%0/2
keys %$tree == 1 and exists $tree->{"_"}
keys %$tree == 1 exists $tree->{"_"}
Truth table0%0/3
A and B
A= keys %$tree == 1B= exists $tree->{"_"}
ABresult
0X0
100
111
747 }
748  
749 2 1;
« lib/XML/Compile/SOAP11/Operation.pm ↑ Summary lib/XML/Compile/SOAP/Operation.pm »