lib/SOAP/Lite.pm

filter: Statementstmt 81.2% 1582 / 1947 Branchbran 62.5% 672 / 1074 Conditioncond 50.6% 339 / 670 MC/DCmcdc 23.6% 90 / 380 Subroutinesub 85.9% 299 / 348 Podpod 70.0% 7 / 10 totaltotal 67.4% 2989 / 4429 CC 856 SCAR 35.3
CC
856
Cov
70%
__ANON__
368.5
call
178.1
decode_value
124.2
CRAP 34.3
« lib/SOAP/Lite/Packager.pm ↑ Summary lib/SOAP/Transport/TCP.pm »
1 # ======================================================================
2 #
3 # Copyright (C) 2000-2005 Paul Kulchenko (paulclinger@yahoo.com)
4 # SOAP::Lite is free software; you can redistribute it
5 # and/or modify it under the same terms as Perl itself.
6 #
7 # ======================================================================
8  
9 # Formatting hint:
10 # Target is the source code format laid out in Perl Best Practices (4 spaces
11 # indent, opening brace on condition line, no cuddled else).
12 #
13 # October 2007, Martin Kutter
14  
15 package SOAP::Lite;
16  
17 44 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 44 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 44 our $VERSION = '1.27'; # VERSION
21  
22 package SOAP::XMLSchemaApacheSOAP::Deserializer;
23  
24 0 ▶sub as_map {
Subroutine as_map: not called CC=2 SCAR=17.9
25 0 my $self = shift;
26 return {
27 map {
28 0 my $hash = ($self->decode_object($_))[1];
29 ($hash->{key} => $hash->{value})
30 0 ▶ } @{$_[3] || []}
Condition0%0/2
$_[3] || []
l!l
00
MC/DC0%0/1
$_[3] || []
$_[3]
Truth table0%0/2
A
A= $_[3]
Aresult
11
00
31 };
32 }
33 44 sub as_Map; *as_Map = \&as_map;
34  
35 # Thank to Kenneth Draper for this contribution
36 3 ▶sub as_vector {
Subroutine as_vector: called CC=2 SCAR=7.0
37 3 my $self = shift;
38 3 ▶ return [ map { scalar(($self->decode_object($_))[1]) } @{$_[3] || []} ];
Condition50%1/2
$_[3] || []
l!l
30
MC/DC0%0/1
$_[3] || []
$_[3]
Truth table50%1/2
A
A= $_[3]
Aresult
11
00
39 }
40 44 sub as_Vector; *as_Vector = \&as_vector;
41  
42 # ----------------------------------------------------------------------
43  
44 package SOAP::XMLSchema::Serializer;
45  
46 44 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
47  
48 392 ▶sub xmlschemaclass {
Subroutine xmlschemaclass: called CC=2 SCAR=6.9
49 392 my $self = shift;
50 392 ▶ return $ISA[0] unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 292 100 392
51 100 @ISA = (shift);
52 100 return $self;
53 }
54  
55 # ----------------------------------------------------------------------
56  
57 package SOAP::XMLSchema1999::Serializer;
58  
59 44 ▶use vars qw(@EXPORT $AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
60  
61 63 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=4 SCAR=13.9
62 63 local($1,$2);
63 63 my($package, $method) = $AUTOLOAD =~ m/(?:(.+)::)([^:]+)$/;
64 63 ▶ return if $method eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $method eq "DESTROY" 1 62 63
65 44 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
66  
67 62 my $export_var = $package . '::EXPORT';
68 62 my @export = @$export_var;
69  
70 # Removed in 0.69 - this is a total hack. For some reason this is failing
71 # despite not being a fatal error condition.
72 # die "Type '$method' can't be found in a schema class '$package'\n"
73 # unless $method =~ s/^as_// && grep {$_ eq $method} @{$export_var};
74  
75 # This was added in its place - it is still a hack, but it performs the
76 # necessary substitution. It just does not die.
77 62 ▶ if ($method =~ s/^as_// && grep {$_ eq $method} @{$export_var}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($method =~ s/^as_// and grep {$_ eq $method;} @{$export_var;}) { } 60 2 62
Condition66%2/3
$method =~ s/^as_// and grep {$_ eq $method;} @{$export_var;}
!ll&&!rl&&r
2060
MC/DC50%1/2
$method =~ s/^as_// and grep {$_ eq $method;} @{$export_var;}
$method =~ s/^as_// grep {$_ eq $method;} @{$export_var;}
Truth table66%2/3
A and B
A= $method =~ s/^as_//B= grep {$_ eq $method;} @{$export_var;}
ABresult
0X0
100
111
78 # print STDERR "method is now '$method'\n";
79 } else {
80 2 return;
81 }
82  
83 60 $method =~ s/_/-/; # fix ur-type
84  
85 94 ▶ *$AUTOLOAD = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
86 94 my $self = shift;
87 94 my($value, $name, $type, $attr) = @_;
88 94 return [$name, {'xsi:type' => "xsd:$method", %$attr}, $value];
89 60 };
90 60 goto &$AUTOLOAD;
91 }
92  
93 44 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=6.9
94 44 @EXPORT = qw(ur_type
95 float double decimal timeDuration recurringDuration uriReference
96 integer nonPositiveInteger negativeInteger long int short byte
97 nonNegativeInteger unsignedLong unsignedInt unsignedShort unsignedByte
98 positiveInteger timeInstant time timePeriod date month year century
99 recurringDate recurringDay language
100 base64 hex string boolean
101 );
102 # TODO: replace by symbol table operations...
103 # predeclare subs, so ->can check will be positive
104 44 foreach (@EXPORT) { eval "sub as_$_" }
105 }
106  
107 44 ▶sub nilValue { 'null' }
Subroutine nilValue: called CC=1 SCAR=0.0
108  
109 1 ▶sub anyTypeValue { 'ur-type' }
Subroutine anyTypeValue: called CC=1 SCAR=0.0
110  
111 2 ▶sub as_base64 {
Subroutine as_base64: called CC=4 SCAR=17.9
112 2 my ($self, $value, $name, $type, $attr) = @_;
113  
114 # Fixes #30271 for 5.8 and above.
115 # Won't fix for 5.6 and below - perl can't handle unicode before
116 # 5.8, and applying pack() to everything is just a slowdown.
117 2 ▶ if ($SOAP::Constants::HAS_ENCODE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($SOAP::Constants::HAS_ENCODE) 2 0 2
118 2 ▶ if (Encode::is_utf8($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&Encode::is_utf8($value)) 0 2 2
119 0 ▶ if (Encode->can('_utf8_off')) { # the quick way, but it may change in future Perl versions.
Branch: 1 branch
BranchTrueFalseTotal
if ('Encode'->can('_utf8_off')) { } 0 0 0
120 0 Encode::_utf8_off($value);
121 }
122 else {
123 0 $value = pack('C*',unpack('C*',$value)); # the slow but safe way,
124 # but this fallback works always.
125 }
126 }
127 }
128  
129 2 require MIME::Base64;
130 return [
131 2 $name,
132 {
133 'xsi:type' => SOAP::Utils::qualify($self->encprefix => 'base64'),
134 %$attr
135 },
136 MIME::Base64::encode_base64($value,'')
137 ];
138 }
139  
140 1 ▶sub as_hex {
Subroutine as_hex: called CC=1 SCAR=0.0
141 1 my ($self, $value, $name, $type, $attr) = @_;
142 return [
143 $name,
144 {
145 'xsi:type' => 'xsd:hex', %$attr
146 },
147 join '', map {
148 1 uc sprintf "%02x", ord
149 } split '', $value
150 ];
151 }
152  
153 4 ▶sub as_long {
Subroutine as_long: called CC=1 SCAR=0.0
154 4 my($self, $value, $name, $type, $attr) = @_;
155 return [
156 4 $name,
157 {'xsi:type' => 'xsd:long', %$attr},
158 $value
159 ];
160 }
161  
162 1 ▶sub as_dateTime {
Subroutine as_dateTime: called CC=1 SCAR=0.0
163 1 my ($self, $value, $name, $type, $attr) = @_;
164 1 return [$name, {'xsi:type' => 'xsd:dateTime', %$attr}, $value];
165 }
166  
167 20 ▶sub as_string {
Subroutine as_string: called CC=2 SCAR=6.9
168 20 my ($self, $value, $name, $type, $attr) = @_;
169 20 ▶ die "String value expected instead of @{[ref $value]} reference\n"
Branch: 1 branch
BranchTrueFalseTotal
if ref $value 1 19 20
170 if ref $value;
171 return [
172 19 $name,
173 {'xsi:type' => 'xsd:string', %$attr},
174 SOAP::Utils::encode_data($value)
175 ];
176 }
177  
178 8 ▶sub as_anyURI {
Subroutine as_anyURI: called CC=2 SCAR=6.9
179 8 my($self, $value, $name, $type, $attr) = @_;
180 8 ▶ die "String value expected instead of @{[ref $value]} reference\n" if ref $value;
Branch: 1 branch
BranchTrueFalseTotal
if ref $value 1 7 8
181 return [
182 7 $name,
183 {'xsi:type' => 'xsd:anyURI', %$attr},
184 SOAP::Utils::encode_data($value)
185 ];
186 }
187  
188 2 ▶sub as_undef { $_[1] ? '1' : '0' }
Subroutine as_undef: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[1] ? : 1 1 2
189  
190 2 ▶sub as_boolean {
Subroutine as_boolean: called CC=3 SCAR=11.0
191 2 my $self = shift;
192 2 my($value, $name, $type, $attr) = @_;
193 # fix [ 1.05279 ] Boolean serialization error
194 return [
195 2 ▶ $name,
Branch: 1 branch
BranchTrueFalseTotal
$value && $value ne 'false' ? : 1 1 2
Condition66%2/3
$value and $value ne "false"
!ll&&!rl&&r
101
MC/DC50%1/2
$value and $value ne "false"
$value $value ne "false"
Truth table66%2/3
A and B
A= $valueB= $value ne "false"
ABresult
0X0
100
111
196 {'xsi:type' => 'xsd:boolean', %$attr},
197 ( $value && $value ne 'false' ) ? 'true' : 'false'
198 ];
199 }
200  
201 2 ▶sub as_float {
Subroutine as_float: called CC=1 SCAR=0.0
202 2 my($self, $value, $name, $type, $attr) = @_;
203 return [
204 2 $name,
205 {'xsi:type' => 'xsd:float', %$attr},
206 $value
207 ];
208 }
209  
210 # ----------------------------------------------------------------------
211  
212 package SOAP::XMLSchema2001::Serializer;
213  
214 44 ▶use vars qw(@EXPORT);
Subroutine BEGIN: called CC=1 SCAR=0.0
215  
216 # no more warnings about "used only once"
217 44 *AUTOLOAD if 0;
218  
219 44 *AUTOLOAD = \&SOAP::XMLSchema1999::Serializer::AUTOLOAD;
220  
221 44 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=6.9
222 44 @EXPORT = qw(anyType anySimpleType float double decimal dateTime
223 timePeriod gMonth gYearMonth gYear century
224 gMonthDay gDay duration recurringDuration anyURI
225 language integer nonPositiveInteger negativeInteger
226 long int short byte nonNegativeInteger unsignedLong
227 unsignedInt unsignedShort unsignedByte positiveInteger
228 date time string hex base64 boolean
229 QName
230 );
231 # Add QName to @EXPORT
232 # predeclare subs, so ->can check will be positive
233 44 foreach (@EXPORT) { eval "sub as_$_" }
234 }
235  
236 74 ▶sub nilValue { 'nil' }
Subroutine nilValue: called CC=1 SCAR=0.0
237  
238 2 ▶sub anyTypeValue { 'anyType' }
Subroutine anyTypeValue: called CC=1 SCAR=0.0
239  
240 44 sub as_long; *as_long = \&SOAP::XMLSchema1999::Serializer::as_long;
241 44 sub as_float; *as_float = \&SOAP::XMLSchema1999::Serializer::as_float;
242 44 sub as_string; *as_string = \&SOAP::XMLSchema1999::Serializer::as_string;
243 44 sub as_anyURI; *as_anyURI = \&SOAP::XMLSchema1999::Serializer::as_anyURI;
244  
245 # TODO - QNames still don't work for 2001 schema!
246 44 sub as_QName; *as_QName = \&SOAP::XMLSchema1999::Serializer::as_string;
247 44 sub as_hex; *as_hex = \&as_hexBinary;
248 44 sub as_base64; *as_base64 = \&as_base64Binary;
249 44 sub as_timeInstant; *as_timeInstant = \&as_dateTime;
250  
251 # only 0 and 1 allowed - that's easy...
252 30 ▶sub as_undef {
Subroutine as_undef: called CC=2 SCAR=7.6
253 30 ▶ $_[1]
Branch: 1 branch
BranchTrueFalseTotal
$_[1] ? : 30 0 30
254 ? 'true'
255 : 'false'
256 }
257  
258 2 ▶sub as_hexBinary {
Subroutine as_hexBinary: called CC=1 SCAR=0.0
259 2 my ($self, $value, $name, $type, $attr) = @_;
260 return [
261 $name,
262 {'xsi:type' => 'xsd:hexBinary', %$attr},
263 join '', map {
264 2 uc sprintf "%02x", ord
265 } split '', $value
266 ];
267 }
268  
269 5 ▶sub as_base64Binary {
Subroutine as_base64Binary: called CC=4 SCAR=14.2
270 5 my ($self, $value, $name, $type, $attr) = @_;
271  
272 # Fixes #30271 for 5.8 and above.
273 # Won't fix for 5.6 and below - perl can't handle unicode before
274 # 5.8, and applying pack() to everything is just a slowdown.
275 5 ▶ if (eval "require Encode; 1") {
Branch: 1 branch
BranchTrueFalseTotal
if (eval "require Encode; 1") 5 0 5
276 5 ▶ if (Encode::is_utf8($value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&Encode::is_utf8($value)) 1 4 5
277 1 ▶ if (Encode->can('_utf8_off')) { # the quick way, but it may change in future Perl versions.
Branch: 1 branch
BranchTrueFalseTotal
if ('Encode'->can('_utf8_off')) { } 1 0 1
278 1 Encode::_utf8_off($value);
279 }
280 else {
281 0 $value = pack('C*',unpack('C*',$value)); # the slow but safe way,
282 # but this fallback works always.
283 }
284 }
285 }
286  
287 5 require MIME::Base64;
288 return [
289 5 $name,
290 {
291 'xsi:type' => 'xsd:base64Binary', %$attr
292 },
293 MIME::Base64::encode_base64($value,'')
294 ];
295 }
296  
297 2 ▶sub as_boolean {
Subroutine as_boolean: called CC=3 SCAR=11.1
298 2 my ($self, $value, $name, $type, $attr) = @_;
299 # fix [ 1.05279 ] Boolean serialization error
300 return [
301 2 ▶ $name,
Branch: 1 branch
BranchTrueFalseTotal
$value && $value ne 'false' ? : 1 1 2
Condition66%2/3
$value and $value ne "false"
!ll&&!rl&&r
011
MC/DC50%1/2
$value and $value ne "false"
$value $value ne "false"
Truth table66%2/3
A and B
A= $valueB= $value ne "false"
ABresult
0X0
100
111
302 {
303 'xsi:type' => 'xsd:boolean', %$attr
304 },
305 ( $value && ($value ne 'false') )
306 ? 'true'
307 : 'false'
308 ];
309 }
310  
311  
312 # ======================================================================
313  
314 package SOAP::Utils;
315  
316 546 ▶sub qualify {
Subroutine qualify: called CC=5 SCAR=18.9
317 546 ▶ $_[1]
Branch: 3 branches
BranchTrueFalseTotal
$_[1] ? : 542 4 546
$_[1] =~ /:/ ? : 0 542 542
defined $_[1] ? : 0 4 4
Condition33%1/3
$_[0] || ()
l!l&&r!l&&!r
54200
MC/DC0%0/2
$_[0] || ()
$_[0] ()
Truth table33%1/3
A || B
A= $_[0]B= ()
ABresult
1X1
011
000
318 ? $_[1] =~ /:/
319 ? $_[1]
320 : join(':', $_[0] || (), $_[1])
321 : defined $_[1]
322 ? $_[0]
323 : ''
324 }
325  
326 0 ▶sub overqualify (&$) {
Subroutine overqualify: not called CC=2 SCAR=17.9
327 0 for ($_[1]) {
328 0 &{$_[0]};
329 0 s/^:|:$//g
330 }
331 }
332  
333 363 ▶sub disqualify {
Subroutine disqualify: called CC=1 SCAR=0.0
334 363 (my $qname = shift) =~ s/^($SOAP::Constants::NSMASK?)://;
335 363 return $qname;
336 }
337  
338 537 ▶sub splitqname {
Subroutine splitqname: called CC=2 SCAR=6.9
339 537 local($1,$2);
340  
341 537 ▶ return unless $_[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0] 1 536 537
342 536 $_[0] =~ /^(?:([^:]+):)?(.+)$/;
343 536 return ($1,$2)
344 }
345  
346 954 ▶sub longname {
Subroutine longname: called CC=2 SCAR=6.9
347 954 ▶ defined $_[0]
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 624 330 954
348 ? sprintf('{%s}%s', $_[0], $_[1])
349 : $_[1]
350 }
351  
352 874 ▶sub splitlongname {
Subroutine splitlongname: called CC=1 SCAR=0.0
353 874 local($1,$2);
354 874 $_[0] =~ /^(?:\{(.*)\})?(.+)$/;
355 874 return ($1,$2)
356 }
357  
358 # Q: why only '&' and '<' are encoded, but not '>'?
359 # A: because it is not required according to XML spec.
360 #
361 # [http://www.w3.org/TR/REC-xml#syntax]
362 # The ampersand character (&) and the left angle bracket (<) may appear in
363 # their literal form only when used as markup delimiters, or within a comment,
364 # a processing instruction, or a CDATA section. If they are needed elsewhere,
365 # they must be escaped using either numeric character references or the
366 # strings "&amp;" and "&lt;" respectively. The right angle bracket (>) may be
367 # represented using the string "&gt;", and must, for compatibility, be
368 # escaped using "&gt;" or a character reference when it appears in the
369 # string "]]>" in content, when that string is not marking the end of a
370 # CDATA section.
371  
372 44 my %encode_attribute = ('&' => '&amp;', '>' => '&gt;', '<' => '&lt;', '"' => '&quot;');
373 468 ▶sub encode_attribute { (my $e = $_[0]) =~ s/([&<>\"])/$encode_attribute{$1}/g; $e }
Subroutine encode_attribute: called CC=1 SCAR=0.0
374  
375 44 my %encode_data = ('&' => '&amp;', '>' => '&gt;', '<' => '&lt;', "\xd" => '&#xd;');
376 55 ▶sub encode_data {
Subroutine encode_data: called CC=2 SCAR=6.9
377 55 my $e = $_[0];
378 55 ▶ if ($e) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e) 35 20 55
379 35 $e =~ s/([&<>\015])/$encode_data{$1}/g;
380 35 $e =~ s/\]\]>/\]\]&gt;/g;
381 }
382 $e
383 55 }
384  
385 # methods for internal tree (SOAP::Deserializer, SOAP::SOM and SOAP::Serializer)
386  
387 69 ▶sub o_qname { $_[0]->[0] }
Subroutine o_qname: called CC=1 SCAR=0.0
388 0 ▶sub o_attr { $_[0]->[1] }
Subroutine o_attr: not called CC=1 SCAR=6.9
389 658 ▶sub o_child { ref $_[0]->[2] ? $_[0]->[2] : undef }
Subroutine o_child: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0][2] ? : 536 122 658
390 0 ▶sub o_chars { ref $_[0]->[2] ? undef : $_[0]->[2] }
Subroutine o_chars: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0][2] ? : 0 0 0
391 # $_[0]->[3] is not used. Serializer stores object ID there
392 166 ▶sub o_value { $_[0]->[4] }
Subroutine o_value: called CC=1 SCAR=0.0
393 1064 ▶sub o_lname { $_[0]->[5] }
Subroutine o_lname: called CC=1 SCAR=0.0
394 1563 ▶sub o_lattr { $_[0]->[6] }
Subroutine o_lattr: called CC=1 SCAR=0.0
395  
396 0 ▶sub format_datetime {
Subroutine format_datetime: not called CC=1 SCAR=6.9
397 0 my ($s,$m,$h,$D,$M,$Y) = (@_)[0,1,2,3,4,5];
398 0 my $time = sprintf("%04d-%02d-%02dT%02d:%02d:%02d",($Y+1900),($M+1),$D,$h,$m,$s);
399 0 return $time;
400 }
401  
402 # make bytelength that calculates length in bytes regardless of utf/byte settings
403 # either we can do 'use bytes' or length will count bytes already
404 44 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.6
405 sub bytelength;
406 *bytelength = eval('use bytes; 1') # 5.6.0 and later?
407 44 ▶ ? sub { use bytes; length(@_ ? $_[0] : $_) }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=2 SCAR=7.0
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 28 0 28
408 0 ▶ : sub { length(@_ ? $_[0] : $_) };
Subroutine BEGIN: called CC=1 SCAR=0.8
Subroutine __ANON__: not called CC=2 SCAR=8.5
Branch: 2 branches
BranchTrueFalseTotal
eval 'use bytes; 1' ? : 44 0 44
@_ ? : 0 0 0
409 }
410  
411 # ======================================================================
412  
413 package SOAP::Cloneable;
414  
415 24 ▶sub clone {
Subroutine clone: called CC=7 SCAR=20.5
416 24 my $self = shift;
417  
418 24 ▶ return unless ref $self && UNIVERSAL::isa($self => __PACKAGE__);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self and UNIVERSAL::isa($self, __PACKAGE__) 0 24 24
Condition33%1/3
ref $self and UNIVERSAL::isa($self, __PACKAGE__)
!ll&&!rl&&r
0024
MC/DC0%0/2
ref $self and UNIVERSAL::isa($self, __PACKAGE__)
ref $self UNIVERSAL::isa($self, __PACKAGE__)
Truth table33%1/3
A and B
A= ref $selfB= UNIVERSAL::isa($self, __PACKAGE__)
ABresult
0X0
100
111
419  
420 24 ▶ my $clone = bless {} => ref($self) || $self;
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
2400
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
421 24 for (keys %$self) {
422 211 my $value = $self->{$_};
423 211 ▶ $clone->{$_} = ref $value && UNIVERSAL::isa($value => __PACKAGE__) ? $value->clone : $value;
Branch: 1 branch
BranchTrueFalseTotal
ref $value && UNIVERSAL::isa($value, __PACKAGE__) ? : 18 193 211
Condition100%3/3
ref $value and UNIVERSAL::isa($value, __PACKAGE__)
!ll&&!rl&&r
7911418
MC/DC100%2/2
ref $value and UNIVERSAL::isa($value, __PACKAGE__)
ref $value UNIVERSAL::isa($value, __PACKAGE__)
Truth table100%3/3
A and B
A= ref $valueB= UNIVERSAL::isa($value, __PACKAGE__)
ABresult
0X0
100
111
424 }
425 24 return $clone;
426 }
427  
428 # ======================================================================
429  
430 package SOAP::Transport;
431  
432 44 ▶use vars qw($AUTOLOAD @ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
433 44 @ISA = qw(SOAP::Cloneable);
434  
435 44 ▶use Class::Inspector;
Subroutine BEGIN: called CC=1 SCAR=0.0
436  
437  
438 51 ▶sub DESTROY { SOAP::Trace::objects('()') }
Subroutine DESTROY: called CC=1 SCAR=0.0
439  
440 51 ▶sub new {
Subroutine new: called CC=3 SCAR=11.8
441 51 my $self = shift;
442 51 ▶ return $self if ref $self;
Branch: 1 branch
BranchTrueFalseTotal
if ref $self 0 51 51
443 51 ▶ my $class = ref($self) || $self;
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
0510
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
444  
445 51 SOAP::Trace::objects('()');
446 51 return bless {} => $class;
447 }
448  
449 109 ▶sub proxy {
Subroutine proxy: called CC=8 SCAR=21.1
450 109 my $self = shift;
451 109 ▶ $self = $self->new() if not ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 109 109
452  
453 109 my $class = ref $self;
454  
455 109 ▶ return $self->{_proxy} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 90 19 109
456  
457 19 ▶ $_[0] =~ /^(\w+):/ or die "proxy: transport protocol not specified\n";
Branch: 1 branch
BranchTrueFalseTotal
$_[0] =~ /^(\w+):/ or die "proxy: transport protocol not specified\n" 19 0 19
458 19 my $protocol = uc "$1"; # untainted now
459  
460 # HTTPS is handled by HTTP class
461 19 $protocol =~s/^HTTPS$/HTTP/;
462  
463 19 (my $protocol_class = "${class}::$protocol") =~ s/-/_/g;
464  
465 44 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
466 19 ▶ unless (Class::Inspector->loaded("$protocol_class\::Client")
Branch: 1 branch
BranchTrueFalseTotal
unless ("Class::Inspector"->loaded("${protocol_class}::Client") and UNIVERSAL::can("${protocol_class}::Client", "new")) 16 3 19
Condition66%2/3
"Class::Inspector"->loaded("${protocol_class}::Client") and UNIVERSAL::can("${protocol_class}::Client", "new")
!ll&&!rl&&r
1603
MC/DC50%1/2
"Class::Inspector"->loaded("${protocol_class}::Client") and UNIVERSAL::can("${protocol_class}::Client", "new")
"Class::Inspector"->loaded("${protocol_class}::Client") UNIVERSAL::can("${protocol_class}::Client", "new")
Truth table66%2/3
A and B
A= "Class::Inspector"->loaded("${protocol_class}::Client")B= UNIVERSAL::can("${protocol_class}::Client", "new")
ABresult
0X0
100
111
467 && UNIVERSAL::can("$protocol_class\::Client" => 'new')
468 ) {
469 16 eval "require $protocol_class";
470 16 ▶ die "Unsupported protocol '$protocol'\n"
Branch: 1 branch
BranchTrueFalseTotal
if $@ =~ m[^Can\'t locate SOAP/Transport/] 0 16 16
471 if $@ =~ m!^Can\'t locate SOAP/Transport/!;
472 16 ▶ die if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 16 16
473 }
474  
475 19 $protocol_class .= "::Client";
476 19 return $self->{_proxy} = $protocol_class->new(endpoint => shift, @_);
477 }
478  
479 56 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=2 SCAR=7.0
480 56 my $method = substr($AUTOLOAD, rindex($AUTOLOAD, '::') + 2);
481 56 ▶ return if $method eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $method eq "DESTROY" 0 56 56
482  
483 44 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
484 56 ▶ *$AUTOLOAD = sub { shift->proxy->$method(@_) };
Subroutine __ANON__: called CC=1 SCAR=0.0
485 56 goto &$AUTOLOAD;
486 }
487  
488 # ======================================================================
489  
490 package SOAP::Fault;
491  
492 44 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
493  
494 44 ▶use overload fallback => 1, '""' => "stringify";
Subroutine BEGIN: called CC=1 SCAR=0.0
495  
496 0 ▶sub DESTROY { SOAP::Trace::objects('()') }
Subroutine DESTROY: not called CC=1 SCAR=6.9
497  
498 0 ▶sub new {
Subroutine new: not called CC=6 SCAR=34.1
499 0 my $self = shift;
500  
501 0 ▶ unless (ref $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self) 0 0 0
502 0 my $class = $self;
503 0 $self = bless {} => $class;
504 0 SOAP::Trace::objects('()');
505 }
506  
507 0 ▶ Carp::carp "Odd (wrong?) number of parameters in new()"
Branch: 1 branch
BranchTrueFalseTotal
if $^W and @_ & 1 0 0 0
Condition0%0/3
$^W and @_ & 1
!ll&&!rl&&r
000
MC/DC0%0/2
$^W and @_ & 1
$^W @_ & 1
Truth table0%0/3
A and B
A= $^WB= @_ & 1
ABresult
0X0
100
111
508 if $^W && (@_ & 1);
509  
510 44 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
511 0 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
512 0 my $method = shift;
513 0 ▶ $self->$method(shift)
Branch: 1 branch
BranchTrueFalseTotal
if $self->can($method) 0 0 0
514 if $self->can($method)
515 }
516  
517 0 return $self;
518 }
519  
520 0 ▶sub stringify {
Subroutine stringify: not called CC=1 SCAR=6.9
521 0 my $self = shift;
522 0 return join ': ', $self->faultcode, $self->faultstring;
523 }
524  
525 44 ▶sub BEGIN {
Subroutine BEGIN: called CC=2 SCAR=10.0
526 44 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
527 44 for my $method (qw(faultcode faultstring faultactor faultdetail)) {
528 176 my $field = '_' . $method;
529 0 ▶ *$method = sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
530 0 ▶ my $self = UNIVERSAL::isa($_[0] => __PACKAGE__)
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($_[0], __PACKAGE__) ? : 0 0 0
531 ? shift->new
532 : __PACKAGE__->new;
533 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
534 0 $self->{$field} = shift;
535 0 return $self
536 }
537 0 return $self->{$field};
538 }
539 176 }
540 44 *detail = \&faultdetail;
541 }
542  
543 # ======================================================================
544  
545 package SOAP::Data;
546  
547 44 ▶use vars qw(@ISA @EXPORT_OK);
Subroutine BEGIN: called CC=1 SCAR=0.0
548 44 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
549 44 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
550 44 ▶use SOAP::Lite::Deserializer::XMLSchemaSOAP1_2;
Subroutine BEGIN: called CC=1 SCAR=0.0
551  
552 44 @ISA = qw(Exporter);
553 44 @EXPORT_OK = qw(name type attr value uri);
554  
555 681 ▶sub DESTROY { SOAP::Trace::objects('()') }
Subroutine DESTROY: called CC=1 SCAR=0.0
556  
557 1056 ▶sub new {
Subroutine new: called CC=6 SCAR=18.2
558 1056 my $self = shift;
559  
560 1056 ▶ unless (ref $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self) 681 375 1056
561 681 my $class = $self;
562 681 $self = bless {_attr => {}, _value => [], _signature => []} => $class;
563 681 SOAP::Trace::objects('()');
564 }
565 44 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
566 1056 ▶ Carp::carp "Odd (wrong?) number of parameters in new()" if $^W && (@_ & 1);
Branch: 1 branch
BranchTrueFalseTotal
if $^W and @_ & 1 0 1056 1056
Condition33%1/3
$^W and @_ & 1
!ll&&!rl&&r
105600
MC/DC0%0/2
$^W and @_ & 1
$^W @_ & 1
Truth table33%1/3
A and B
A= $^WB= @_ & 1
ABresult
0X0
100
111
567 1056 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 281 1056 1337
568 281 my $method = shift;
569 281 ▶ $self->$method(shift) if $self->can($method)
Branch: 1 branch
BranchTrueFalseTotal
if $self->can($method) 281 0 281
570 }
571  
572 1056 return $self;
573 }
574  
575 1785 ▶sub name {
Subroutine name: called CC=8 SCAR=20.8
576 1785 ▶ my $self = ref $_[0] ? shift : UNIVERSAL::isa($_[0] => __PACKAGE__) ? shift->new : __PACKAGE__->new;
Branch: 2 branches
BranchTrueFalseTotal
ref $_[0] ? : 1328 457 1785
UNIVERSAL::isa($_[0], __PACKAGE__) ? : 457 0 457
577 1785 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 713 1072 1785
578 713 my $name = shift;
579 713 my ($uri, $prefix); # predeclare, because can't declare in assign
580 713 ▶ if ($name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name) 598 115 713
581 598 ($uri, $name) = SOAP::Utils::splitlongname($name);
582 598 ▶ unless (defined $uri) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $uri) { } 92 506 598
583 506 ($prefix, $name) = SOAP::Utils::splitqname($name);
584 506 ▶ $self->prefix($prefix) if defined $prefix;
Branch: 1 branch
BranchTrueFalseTotal
if defined $prefix 154 352 506
585 } else {
586 92 $self->uri($uri);
587 }
588 }
589 713 $self->{_name} = $name;
590  
591 713 ▶ $self->value(@_) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 201 512 713
592 713 return $self;
593 }
594 1072 return $self->{_name};
595 }
596  
597 1000 ▶sub attr {
Subroutine attr: called CC=5 SCAR=16.2
598 1000 ▶ my $self = ref $_[0]
Branch: 2 branches
BranchTrueFalseTotal
ref $_[0] ? : 999 1 1000
UNIVERSAL::isa($_[0], __PACKAGE__) ? : 1 0 1
599 ? shift
600 : UNIVERSAL::isa($_[0] => __PACKAGE__)
601 ? shift->new()
602 : __PACKAGE__->new();
603 1000 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 411 589 1000
604 411 $self->{_attr} = shift;
605 411 ▶ return $self->value(@_) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 411 411
606 411 return $self
607 }
608 589 return $self->{_attr};
609 }
610  
611 1063 ▶sub type {
Subroutine type: called CC=7 SCAR=19.8
612 1063 ▶ my $self = ref $_[0]
Branch: 2 branches
BranchTrueFalseTotal
ref $_[0] ? : 1057 6 1063
UNIVERSAL::isa($_[0], __PACKAGE__) ? : 6 0 6
613 ? shift
614 : UNIVERSAL::isa($_[0] => __PACKAGE__)
615 ? shift->new()
616 : __PACKAGE__->new();
617 1063 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 39 1024 1063
618 39 $self->{_type} = shift;
619 39 ▶ $self->value(@_) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 5 34 39
620 39 return $self;
621 }
622 1024 ▶ if (!defined $self->{_type} && (my @types = grep {/^\{$SOAP::Constants::NS_XSI_ALL}type$/o} keys %{$self->{_attr}})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{"_type"} and my(@types) = grep({/^\{$SOAP::Constants::NS_XSI_ALL}type$/o;} keys %{$$self{"_attr"};})) 0 1024 1024
Condition66%2/3
not defined $self->{"_type"} and my(@types) = grep({/^\{$SOAP::Constants::NS_XSI_ALL}type$/o;} keys %{$$self{"_attr"};})
!ll&&!rl&&r
779470
MC/DC0%0/2
not defined $self->{"_type"} and my(@types) = grep({/^\{$SOAP::Constants::NS_XSI_ALL}type$/o;} keys %{$$self{"_attr"};})
not defined $self->{"_type"} my(@types) = grep({/^\{$SOAP::Constants::NS_XSI_ALL}type$/o;} keys %{$$self{"_attr"};})
Truth table66%2/3
not(A) and B
A= not defined $self->{"_type"}B= my(@types) = grep({/^\{$SOAP::Constants::NS_XSI_ALL}type$/o;} keys %{$$self{"_attr"};})
ABresult
0X0
100
111
623 0 $self->{_type} = (SOAP::Utils::splitlongname(delete $self->{_attr}->{shift(@types)}))[1];
624 }
625 1024 return $self->{_type};
626 }
627  
628 44 ▶BEGIN {
Subroutine BEGIN: called CC=3 SCAR=11.9
629 44 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
630 44 for my $method (qw(root mustUnderstand)) {
631 88 my $field = '_' . $method;
632 2 ▶ *$method = sub {
Subroutine __ANON__: called CC=8 SCAR=27.1
633 2 ▶ my $attr = $method eq 'root'
Branch: 1 branch
BranchTrueFalseTotal
$method eq 'root' ? : 1 1 2
634 ? "{$SOAP::Constants::NS_ENC}$method"
635 : "{$SOAP::Constants::NS_ENV}$method";
636 2 ▶ my $self = UNIVERSAL::isa($_[0] => __PACKAGE__)
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($_[0], __PACKAGE__) ? : 2 0 2
637 ? shift->new
638 : __PACKAGE__->new;
639 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 2 0 2
640 2 ▶ $self->{_attr}->{$attr} = $self->{$field} = shift() ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
shift() ? : 2 0 2
641 2 ▶ $self->value(@_) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 2 2
642 2 return $self;
643 }
644 $self->{$field} = SOAP::Lite::Deserializer::XMLSchemaSOAP1_2->as_boolean($self->{_attr}->{$attr})
645 0 ▶ if !defined $self->{$field} && defined $self->{_attr}->{$attr};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $self->{$field} and defined $self->{"_attr"}{$attr} 0 0 0
Condition0%0/3
not defined $self->{$field} and defined $self->{"_attr"}{$attr}
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $self->{$field} and defined $self->{"_attr"}{$attr}
not defined $self->{$field} defined $self->{"_attr"}{$attr}
Truth table0%0/3
not(A) and B
A= not defined $self->{$field}B= defined $self->{"_attr"}{$attr}
ABresult
0X0
100
111
646 0 return $self->{$field};
647 }
648 88 }
649  
650 44 for my $method (qw(actor encodingStyle)) {
651 88 my $field = '_' . $method;
652 8 ▶ *$method = sub {
Subroutine __ANON__: called CC=6 SCAR=19.0
653 8 my $attr = "{$SOAP::Constants::NS_ENV}$method";
654 8 ▶ my $self = UNIVERSAL::isa($_[0] => __PACKAGE__)
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($_[0], __PACKAGE__) ? : 8 0 8
655 ? shift->new()
656 : __PACKAGE__->new();
657 8 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 4 4 8
658 4 $self->{_attr}->{$attr} = $self->{$field} = shift;
659 4 ▶ $self->value(@_) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 4 4
660 4 return $self;
661 }
662 $self->{$field} = $self->{_attr}->{$attr}
663 4 ▶ if !defined $self->{$field} && defined $self->{_attr}->{$attr};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $self->{$field} and defined $self->{"_attr"}{$attr} 0 4 4
Condition33%1/3
not defined $self->{$field} and defined $self->{"_attr"}{$attr}
!ll&&!rl&&r
400
MC/DC0%0/2
not defined $self->{$field} and defined $self->{"_attr"}{$attr}
not defined $self->{$field} defined $self->{"_attr"}{$attr}
Truth table33%1/3
not(A) and B
A= not defined $self->{$field}B= defined $self->{"_attr"}{$attr}
ABresult
0X0
100
111
664 4 return $self->{$field};
665 }
666 88 }
667 }
668  
669 572 ▶sub prefix {
Subroutine prefix: called CC=5 SCAR=16.6
670 572 ▶ my $self = ref $_[0]
Branch: 2 branches
BranchTrueFalseTotal
ref $_[0] ? : 571 1 572
UNIVERSAL::isa($_[0], __PACKAGE__) ? : 1 0 1
671 ? shift
672 : UNIVERSAL::isa($_[0] => __PACKAGE__)
673 ? shift->new()
674 : __PACKAGE__->new();
675 572 ▶ return $self->{_prefix} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 344 228 572
676 228 $self->{_prefix} = shift;
677 228 ▶ if (scalar @_) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_) 0 228 228
678 0 return $self->value(@_);
679 }
680 228 return $self;
681 }
682  
683 440 ▶sub uri {
Subroutine uri: called CC=8 SCAR=22.1
684 440 ▶ my $self = ref $_[0]
Branch: 2 branches
BranchTrueFalseTotal
ref $_[0] ? : 438 2 440
UNIVERSAL::isa($_[0], __PACKAGE__) ? : 2 0 2
685 ? shift
686 : UNIVERSAL::isa($_[0] => __PACKAGE__)
687 ? shift->new()
688 : __PACKAGE__->new();
689 440 ▶ return $self->{_uri} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 345 95 440
690 95 my $uri = $self->{_uri} = shift;
691 95 ▶ warn "Usage of '::' in URI ($uri) deprecated. Use '/' instead\n"
Branch: 1 branch
BranchTrueFalseTotal
if defined $uri and $^W and $uri =~ /::/ 0 95 95
Condition33%2/6
defined $uri and $^W and $uri =~ /::/
!ll&&!rl&&r
9500
defined $uri and $^W
!ll&&!rl&&r
0950
MC/DC0%0/3
defined $uri and $^W and $uri =~ /::/
defined $uri $^W $uri =~ /::/
Truth table25%1/4
A and B and C
A= defined $uriB= $^WC= $uri =~ /::/
ABCresult
0XX0
10X0
1100
1111
692 if defined $uri && $^W && $uri =~ /::/;
693 95 ▶ if (scalar @_) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_) 1 94 95
694 1 return $self->value(@_);
695 }
696 94 return $self;
697 }
698  
699 666 ▶sub set_value {
Subroutine set_value: called CC=3 SCAR=11.1
700 666 ▶ my $self = ref $_[0]
Branch: 2 branches
BranchTrueFalseTotal
ref $_[0] ? : 619 47 666
UNIVERSAL::isa($_[0], __PACKAGE__) ? : 47 0 47
701 ? shift
702 : UNIVERSAL::isa($_[0] => __PACKAGE__)
703 ? shift->new()
704 : __PACKAGE__->new();
705 666 $self->{_value} = [@_];
706 666 return $self;
707 }
708  
709 1038 ▶sub value {
Subroutine value: called CC=5 SCAR=16.1
710 1038 ▶ my $self = ref $_[0] ? shift
Branch: 2 branches
BranchTrueFalseTotal
ref $_[0] ? : 949 89 1038
UNIVERSAL::isa($_[0], __PACKAGE__) ? : 89 0 89
711 : UNIVERSAL::isa($_[0] => __PACKAGE__)
712 ? shift->new()
713 : __PACKAGE__->new;
714 1038 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 318 720 1038
715 318 return $self->set_value(@_);
716 }
717 else {
718 return wantarray
719 503 ? @{$self->{_value}}
720 720 ▶ : $self->{_value}->[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 503 217 720
721 }
722 }
723  
724 370 ▶sub signature {
Subroutine signature: called CC=3 SCAR=11.1
725 370 ▶ my $self = UNIVERSAL::isa($_[0] => __PACKAGE__)
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($_[0], __PACKAGE__) ? : 370 0 370
726 ? shift->new()
727 : __PACKAGE__->new();
728 (@_)
729 ? ($self->{_signature} = shift, return $self)
730 370 ▶ : (return $self->{_signature});
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 339 31 370
731 }
732  
733 # ======================================================================
734  
735 package SOAP::Header;
736  
737 44 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
738 44 @ISA = qw(SOAP::Data);
739  
740 # ======================================================================
741  
742 package SOAP::Serializer;
743 44 ▶use SOAP::Lite::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
744 44 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
745 44 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
746  
747 44 @ISA = qw(SOAP::Cloneable SOAP::XMLSchema::Serializer);
748  
749 44 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
750 # namespaces and anonymous data structures
751 44 my $ns = 0;
752 44 my $name = 0;
753 44 my $prefix = 'c-';
754 16 ▶ sub gen_ns { 'namesp' . ++$ns }
Subroutine gen_ns: called CC=1 SCAR=0.0
755 184 ▶ sub gen_name { join '', $prefix, 'gensym', ++$name }
Subroutine gen_name: called CC=1 SCAR=0.0
756 19 ▶ sub prefix { $prefix =~ s/^[^\-]+-/$_[1]-/; $_[0]; }
Subroutine prefix: called CC=1 SCAR=0.0
757 }
758  
759 44 ▶sub BEGIN {
Subroutine BEGIN: called CC=2 SCAR=6.9
760 44 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
761  
762 44 __PACKAGE__->__mk_accessors(qw(readable level seen autotype attr maptype
763 namespaces multirefinplace encoding signature on_nonserialized context
764 ns_uri ns_prefix use_default_ns));
765  
766 44 for my $method (qw(method fault freeform)) { # aliases for envelope
767 18 ▶ *$method = sub { shift->envelope($method => @_) }
Subroutine __ANON__: called CC=1 SCAR=0.0
768 132 }
769  
770 # Is this necessary? Seems like work for nothing when a user could just use
771 # SOAP::Utils directly.
772 # for my $method (qw(qualify overqualify disqualify)) { # import from SOAP::Utils
773 # *$method = \&{'SOAP::Utils::'.$method};
774 # }
775 }
776  
777 80 ▶sub DESTROY { SOAP::Trace::objects('()') }
Subroutine DESTROY: called CC=1 SCAR=0.0
778  
779 636 ▶sub new {
Subroutine new: called CC=7 SCAR=19.7
780 636 my $self = shift;
781 636 ▶ return $self if ref $self;
Branch: 1 branch
BranchTrueFalseTotal
if ref $self 556 80 636
782  
783 80 my $class = $self;
784 $self = bless {
785 _level => 0,
786 _autotype => 1,
787 _readable => 0,
788 _ns_uri => '',
789 _ns_prefix => '',
790 _use_default_ns => 1,
791 _multirefinplace => 0,
792 _seen => {},
793 _encoding => 'UTF-8',
794 _objectstack => {},
795 _signature => [],
796 _maptype => {},
797 _bodyattr => {},
798 _headerattr => {},
799 0 ▶ _on_nonserialized => sub {Carp::carp "Cannot marshall @{[ref shift]} reference" if $^W; return},
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if $^W 0 0 0
800 80 _encodingStyle => $SOAP::Constants::NS_ENC,
801 _attr => {
802 "{$SOAP::Constants::NS_ENV}encodingStyle" => $SOAP::Constants::NS_ENC,
803 },
804 _namespaces => {},
805 _soapversion => SOAP::Lite->soapversion,
806 } => $class;
807 $self->typelookup({
808 'base64Binary' =>
809 64 ▶ [10, sub { $_[0] =~ /[^\x09\x0a\x0d\x20-\x7f]/ }, 'as_base64Binary'],
Subroutine __ANON__: called CC=1 SCAR=0.0
810 'zerostring' =>
811 61 ▶ [12, sub { $_[0] =~ /^0\d+$/ }, 'as_string'],
Subroutine __ANON__: called CC=1 SCAR=0.0
812 # int (and actually long too) are subtle: the negative range is one greater...
813 'int' =>
814 60 ▶ [20, sub {$_[0] =~ /^([+-]?\d+)$/ && ($1 <= 2147483647) && ($1 >= -2147483648); }, 'as_int'],
Subroutine __ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
$_[0] =~ /^([+-]?\d+)$/ and $1 <= 2147483647 and $1 >= '-2147483648' 36 24 60
Condition100%3/3
$_[0] =~ /^([+-]?\d+)$/ and $1 <= 2147483647
!ll&&!rl&&r
22236
MC/DC100%2/2
$_[0] =~ /^([+-]?\d+)$/ and $1 <= 2147483647
$_[0] =~ /^([+-]?\d+)$/ $1 <= 2147483647
Truth table100%3/3
A and B
A= $_[0] =~ /^([+-]?\d+)$/B= $1 <= 2147483647
ABresult
0X0
100
111
815 'long' =>
816 24 ▶ [25, sub {$_[0] =~ /^([+-]?\d+)$/ && $1 <= 9223372036854775807;}, 'as_long'],
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] =~ /^([+-]?\d+)$/ and $1 <= '9223372036854775807' 2 22 24
817 'float' =>
818 22 ▶ [30, sub {$_[0] =~ /^(-?(?:\d+(?:\.\d*)?|\.\d+|NaN|INF)|([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?)$/}, 'as_float'],
Subroutine __ANON__: called CC=1 SCAR=0.0
819 'gMonth' =>
820 22 ▶ [35, sub { $_[0] =~ /^--\d\d--(-\d\d:\d\d)?$/; }, 'as_gMonth'],
Subroutine __ANON__: called CC=1 SCAR=0.0
821 'gDay' =>
822 22 ▶ [40, sub { $_[0] =~ /^---\d\d(-\d\d:\d\d)?$/; }, 'as_gDay'],
Subroutine __ANON__: called CC=1 SCAR=0.0
823 'gYear' =>
824 22 ▶ [45, sub { $_[0] =~ /^-?\d\d\d\d(-\d\d:\d\d)?$/; }, 'as_gYear'],
Subroutine __ANON__: called CC=1 SCAR=0.0
825 'gMonthDay' =>
826 22 ▶ [50, sub { $_[0] =~ /^-\d\d-\d\d(-\d\d:\d\d)?$/; }, 'as_gMonthDay'],
Subroutine __ANON__: called CC=1 SCAR=0.0
827 'gYearMonth' =>
828 22 ▶ [55, sub { $_[0] =~ /^-?\d\d\d\d-\d\d(Z|([+-]\d\d:\d\d))?$/; }, 'as_gYearMonth'],
Subroutine __ANON__: called CC=1 SCAR=0.0
829 'date' =>
830 22 ▶ [60, sub { $_[0] =~ /^-?\d\d\d\d-\d\d-\d\d(Z|([+-]\d\d:\d\d))?$/; }, 'as_date'],
Subroutine __ANON__: called CC=1 SCAR=0.0
831 'time' =>
832 22 ▶ [70, sub { $_[0] =~ /^\d\d:\d\d:\d\d(\.\d\d\d)?(Z|([+-]\d\d:\d\d))?$/; }, 'as_time'],
Subroutine __ANON__: called CC=1 SCAR=0.0
833 'dateTime' =>
834 22 ▶ [75, sub { $_[0] =~ /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d\d\d)?(Z|([+-]\d\d:\d\d))?$/; }, 'as_dateTime'],
Subroutine __ANON__: called CC=1 SCAR=0.0
835 'duration' =>
836 22 ▶ [80, sub { $_[0] !~m{^-?PT?$} && $_[0] =~ m{^
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
not $_[0] =~ /^-?PT?$/ and $_[0] =~ /^ -? # a optional - sign P (:? \d+Y )? (:? \d+M )? (:? \d+D )? (:? T(:?\d+H)? (:?\d+M)? (:?\d+S)? )? $ /x 20 2 22
837 -? # a optional - sign
838 P
839 (:? \d+Y )?
840 (:? \d+M )?
841 (:? \d+D )?
842 (:?
843 T(:?\d+H)?
844 (:?\d+M)?
845 (:?\d+S)?
846 )?
847 $
848 }x;
849 }, 'as_duration'],
850 'boolean' =>
851 21 ▶ [90, sub { $_[0] =~ /^(true|false)$/i; }, 'as_boolean'],
Subroutine __ANON__: called CC=1 SCAR=0.0
852 'anyURI' =>
853 19 ▶ [95, sub { $_[0] =~ /^(urn:|http:\/\/)/i; }, 'as_anyURI'],
Subroutine __ANON__: called CC=1 SCAR=0.0
854 'string' =>
855 80 ▶ [100, sub {1}, 'as_string'],
Subroutine __ANON__: called CC=1 SCAR=0.0
856 });
857 80 $self->register_ns($SOAP::Constants::NS_ENC,$SOAP::Constants::PREFIX_ENC);
858 80 ▶ $self->register_ns($SOAP::Constants::NS_ENV,$SOAP::Constants::PREFIX_ENV)
Branch: 1 branch
BranchTrueFalseTotal
if $SOAP::Constants::PREFIX_ENV 80 0 80
859 if $SOAP::Constants::PREFIX_ENV;
860 80 $self->xmlschema($SOAP::Constants::DEFAULT_XML_SCHEMA);
861 80 SOAP::Trace::objects('()');
862  
863 44 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
864 80 ▶ Carp::carp "Odd (wrong?) number of parameters in new()" if $^W && (@_ & 1);
Branch: 1 branch
BranchTrueFalseTotal
if $^W and @_ & 1 0 80 80
Condition66%2/3
$^W and @_ & 1
!ll&&!rl&&r
7910
MC/DC0%0/2
$^W and @_ & 1
$^W @_ & 1
Truth table66%2/3
A and B
A= $^WB= @_ & 1
ABresult
0X0
100
111
865 80 ▶ while (@_) { my $method = shift; $self->$method(shift) if $self->can($method) }
Branch: 2 branches
BranchTrueFalseTotal
if (@_) 1 80 81
if $self->can($method) 1 0 1
866  
867 80 return $self;
868 }
869  
870 81 ▶sub typelookup {
Subroutine typelookup: called CC=2 SCAR=6.9
871 81 my ($self, $lookup) = @_;
872 81 ▶ if (defined $lookup) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $lookup) 80 1 81
873 80 $self->{ _typelookup } = $lookup;
874 80 $self->{ _typelookup_order } = [ sort { $lookup->{$a}->[0] <=> $lookup->{$b}->[0] } keys %{ $lookup } ];
875 80 return $self;
876 }
877 1 return $self->{ _typelookup };
878 }
879  
880 3 ▶sub ns {
Subroutine ns: called CC=6 SCAR=18.4
881 3 my $self = shift;
882 3 ▶ $self = $self->new() if not ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 2 1 3
883 3 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 3 0 3
884 3 my ($u,$p) = @_;
885 3 my $prefix;
886  
887 3 ▶ if ($p) {
Branch: 2 branches
BranchTrueFalseTotal
if ($p) { } 1 2 3
elsif (not $p || ($prefix = $self->find_prefix($u))) { } 2 0 2
888 1 $prefix = $p;
889 }
890 ▶ elsif (!$p && !($prefix = $self->find_prefix($u))) {
Condition33%1/3
$p || ($prefix = $self->find_prefix($u))
l!l&&r!l&&!r
002
MC/DC0%0/2
$p || ($prefix = $self->find_prefix($u))
$p ($prefix = $self->find_prefix($u))
Truth table33%1/3
A || B
A= $pB= ($prefix = $self->find_prefix($u))
ABresult
1X1
011
000
891 2 $prefix = gen_ns;
892 }
893  
894 3 $self->{'_ns_uri'} = $u;
895 3 $self->{'_ns_prefix'} = $prefix;
896 3 $self->{'_use_default_ns'} = 0;
897 # $self->register_ns($u,$prefix);
898 3 $self->{'_namespaces'}->{$u} = $prefix;
899 3 return $self;
900 }
901 0 return $self->{'_ns_uri'};
902 }
903  
904 33 ▶sub default_ns {
Subroutine default_ns: called CC=3 SCAR=11.1
905 33 my $self = shift;
906 33 ▶ $self = $self->new() if not ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 1 32 33
907 33 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 33 0 33
908 33 my ($u) = @_;
909 33 $self->{'_ns_uri'} = $u;
910 33 $self->{'_ns_prefix'} = '';
911 33 $self->{'_use_default_ns'} = 1;
912 33 return $self;
913 }
914 0 return $self->{'_ns_uri'};
915 }
916  
917 2 ▶sub use_prefix {
Subroutine use_prefix: called CC=4 SCAR=14.2
918 2 my $self = shift;
919 2 ▶ $self = $self->new() if not ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 2 0 2
920 2 warn 'use_prefix has been deprecated. if you wish to turn off or on the '
921 . 'use of a default namespace, then please use either ns(uri) or default_ns(uri)';
922 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 2 0 2
923 2 my $use = shift;
924 2 ▶ $self->{'_use_default_ns'} = !$use || 0;
Condition100%2/2
!$use || 0
l!l
11
MC/DC100%1/1
!$use || 0
!$use
Truth table100%2/2
not(A)
A= !$use
Aresult
11
00
925 2 return $self;
926 } else {
927 0 return $self->{'_use_default_ns'};
928 }
929 }
930 49 ▶sub uri {
Subroutine uri: called CC=4 SCAR=13.9
931 49 my $self = shift;
932 49 ▶ $self = $self->new() if not ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 49 49
933 # warn 'uri has been deprecated. if you wish to set the namespace for the request, then please use either ns(uri) or default_ns(uri)';
934 49 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 33 16 49
935 33 my $ns = shift;
936 33 ▶ if ($self->{_use_default_ns}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_use_default_ns'}) { } 32 1 33
937 32 $self->default_ns($ns);
938 }
939 else {
940 1 $self->ns($ns);
941 }
942 # $self->{'_ns_uri'} = $ns;
943 # $self->register_ns($self->{'_ns_uri'}) if (!$self->{_use_default_ns});
944 33 return $self;
945 }
946 16 return $self->{'_ns_uri'};
947 }
948  
949 6 ▶sub encodingStyle {
Subroutine encodingStyle: called CC=4 SCAR=22.2
950 6 my $self = shift;
951 6 ▶ $self = $self->new() if not ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 6 6
952 6 ▶ return $self->{'_encodingStyle'} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 6 0 6
953  
954 0 my $cur_style = $self->{'_encodingStyle'};
955 0 delete($self->{'_namespaces'}->{$cur_style});
956  
957 0 my $new_style = shift;
958 0 ▶ if ($new_style eq "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($new_style eq '') { } 0 0 0
959 0 delete($self->{'_attr'}->{"{$SOAP::Constants::NS_ENV}encodingStyle"});
960 }
961 else {
962 0 $self->{'_attr'}->{"{$SOAP::Constants::NS_ENV}encodingStyle"} = $new_style;
963 0 $self->{'_namespaces'}->{$new_style} = $SOAP::Constants::PREFIX_ENC;
964 }
965 }
966  
967 # TODO - changing SOAP version can affect previously set encodingStyle
968 57 ▶sub soapversion {
Subroutine soapversion: called CC=4 SCAR=21.1
969 57 my $self = shift;
970 57 ▶ return $self->{_soapversion} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 57 57
971 57 ▶ return $self if $self->{_soapversion} eq SOAP::Lite->soapversion;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_soapversion"} eq "SOAP::Lite"->soapversion 57 0 57
972 0 $self->{_soapversion} = shift;
973  
974 0 $self->attr({
975 "{$SOAP::Constants::NS_ENV}encodingStyle" => $SOAP::Constants::NS_ENC,
976 });
977 0 ▶ $self->namespaces({
Branch: 1 branch
BranchTrueFalseTotal
$SOAP::Constants::PREFIX_ENV ? : 0 0 0
978 $SOAP::Constants::NS_ENC => $SOAP::Constants::PREFIX_ENC,
979 $SOAP::Constants::PREFIX_ENV ? ($SOAP::Constants::NS_ENV => $SOAP::Constants::PREFIX_ENV) : (),
980 });
981 0 $self->xmlschema($SOAP::Constants::DEFAULT_XML_SCHEMA);
982  
983 0 return $self;
984 }
985  
986 100 ▶sub xmlschema {
Subroutine xmlschema: called CC=9 SCAR=22.6
987 100 my $self = shift->new;
988 100 ▶ return $self->{_xmlschema} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 100 100
989  
990 100 my @schema;
991 100 ▶ if ($_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]) 100 0 100
992 100 ▶ @schema = grep {/XMLSchema/ && /$_[0]/} keys %SOAP::Constants::XML_SCHEMAS;
Condition100%3/3
/XMLSchema/ && /$_[0]/
!ll&&!rl&&r
200100100
MC/DC100%2/2
/XMLSchema/ && /$_[0]/
/XMLSchema/ /$_[0]/
Truth table100%3/3
A && B
A= /XMLSchema/B= /$_[0]/
ABresult
0X0
100
111
993 0 ▶ Carp::croak "More than one schema match parameter '$_[0]': @{[join ', ', @schema]}" if @schema > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @schema > 1 0 100 100
994 100 ▶ Carp::croak "No schema match parameter '$_[0]'" if @schema != 1;
Branch: 1 branch
BranchTrueFalseTotal
if @schema != 1 0 100 100
995 }
996  
997 # do nothing if current schema is the same as new
998 # return $self if $self->{_xmlschema} && $self->{_xmlschema} eq $schema[0];
999  
1000 100 my $ns = $self->namespaces;
1001 # delete current schema from namespaces
1002 100 ▶ if (my $schema = $self->{_xmlschema}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $schema = $self->{"_xmlschema"}) 20 80 100
1003 20 delete $ns->{$schema};
1004 20 delete $ns->{"$schema-instance"};
1005 }
1006  
1007 # add new schema into namespaces
1008 100 ▶ if (my $schema = $self->{_xmlschema} = shift @schema) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $schema = $self->{"_xmlschema"} = shift @schema) 100 0 100
1009 100 $ns->{$schema} = 'xsd';
1010 100 $ns->{"$schema-instance"} = 'xsi';
1011 }
1012  
1013 # and here is the class serializer should work with
1014 my $class = exists $SOAP::Constants::XML_SCHEMAS{$self->{_xmlschema}}
1015 100 ▶ ? $SOAP::Constants::XML_SCHEMAS{$self->{_xmlschema}} . '::Serializer'
Branch: 1 branch
BranchTrueFalseTotal
exists $SOAP::Constants::XML_SCHEMAS{$self->{'_xmlschema'}} ? : 100 0 100
1016 : $self;
1017  
1018 100 $self->xmlschemaclass($class);
1019  
1020 100 return $self;
1021 }
1022  
1023 0 ▶sub headerattr {
Subroutine headerattr: not called CC=2 SCAR=17.9
1024 0 my $self = shift->new();
1025 0 ▶ return $self->{_headerattr} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
1026 0 $self->{_headerattr} = shift;
1027 0 return $self;
1028 }
1029 59 ▶sub bodyattr {
Subroutine bodyattr: called CC=2 SCAR=9.2
1030 59 my $self = shift->new();
1031 59 ▶ return $self->{_bodyattr} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 59 0 59
1032 0 $self->{_bodyattr} = shift;
1033 0 return $self;
1034 }
1035  
1036 148 ▶sub envprefix {
Subroutine envprefix: called CC=2 SCAR=9.2
1037 148 my $self = shift->new();
1038 148 ▶ return $self->namespaces->{$SOAP::Constants::NS_ENV} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 148 0 148
1039 0 $self->namespaces->{$SOAP::Constants::NS_ENV} = shift;
1040 0 return $self;
1041 }
1042  
1043 6 ▶sub encprefix {
Subroutine encprefix: called CC=2 SCAR=9.2
1044 6 my $self = shift->new();
1045 6 ▶ return $self->namespaces->{$SOAP::Constants::NS_ENC} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 6 0 6
1046 0 $self->namespaces->{$SOAP::Constants::NS_ENC} = shift;
1047 0 return $self;
1048 }
1049  
1050 730 ▶sub gen_id { sprintf "%U", $_[1] }
Subroutine gen_id: called CC=1 SCAR=0.0
1051  
1052 536 ▶sub multiref_object {
Subroutine multiref_object: called CC=3 SCAR=11.0
1053 536 my ($self, $object) = @_;
1054 536 my $id = $self->gen_id($object);
1055 536 ▶ if (! exists $self->{ _seen }->{ $id }) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $self->{'_seen'}{$id}) { } 524 12 536
1056 524 $self->{ _seen }->{ $id } = {
1057 count => 1,
1058 multiref => 0,
1059 value => $object,
1060 recursive => 0
1061 };
1062 }
1063 else {
1064 12 my $id_seen = $self->{ _seen }->{ $id };
1065 12 $id_seen->{count}++;
1066 12 $id_seen->{multiref} = 1;
1067 12 $id_seen->{value} = $object;
1068 12 ▶ $id_seen->{recursive} ||= 0;
Condition100%2/2
$id_seen->{"recursive"} ||= 0
l!l
210
MC/DC100%1/1
$id_seen->{"recursive"} ||= 0
$id_seen->{"recursive"}
Truth table100%2/2
A
A= $id_seen->{"recursive"}
Aresult
11
00
1069 }
1070 536 return $id;
1071 }
1072  
1073 0 ▶sub recursive_object {
Subroutine recursive_object: not called CC=1 SCAR=6.9
1074 0 my $self = shift;
1075 0 $self->seen->{$self->gen_id(shift)}->{recursive} = 1;
1076 }
1077  
1078 187 ▶sub is_href {
Subroutine is_href: called CC=8 SCAR=21.0
1079 187 my $self = shift;
1080 187 ▶ my $seen = $self->seen->{shift || return} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $seen = $self->seen->{shift() or return} or return 187 0 187
Condition50%1/2
shift() || (return)
l!l
1870
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
1081 187 ▶ return 1 if $seen->{id};
Branch: 1 branch
BranchTrueFalseTotal
if $seen->{"id"} 3 184 187
1082 return $seen->{multiref}
1083 && !($seen->{id} = (shift
1084 || $seen->{recursive}
1085 184 ▶ || $seen->{multiref} && $self->multirefinplace));
Condition91%11/12
$seen->{'multiref'} && !($seen->{'id'} = shift() || $seen->{'recursive'} || $seen->{'multiref'} && $self->multirefinplace)
!ll&&!rl&&r
17752
shift() || $seen->{'recursive'} || $seen->{'multiref'} && $self->multirefinplace
l!l&&r!l&&!r
412
shift() or $seen->{"recursive"}
l!l&&r!l&&!r
133
$seen->{"multiref"} and $self->multirefinplace
!ll&&!rl&&r
021
MC/DC80%4/5
$seen->{'multiref'} && !($seen->{'id'} = shift() || $seen->{'recursive'} || $seen->{'multiref'} && $self->multirefinplace)
$seen->{'multiref'} shift() $seen->{"recursive"} $seen->{"multiref"} $self->multirefinplace
Truth table83%5/6
A && not(B or C || D and E)
A= $seen->{'multiref'}B= shift()C= $seen->{"recursive"}D= $seen->{"multiref"}E= $self->multirefinplace
ABCDEresult
0XXXX0
11XXX0
101XX0
100110
1000X1
100101
1086 }
1087  
1088 10 ▶sub multiref_anchor {
Subroutine multiref_anchor: called CC=2 SCAR=7.1
1089 10 my ($self, $id) = @_;
1090 44 ▶ no warnings qw(uninitialized);
Subroutine BEGIN: called CC=1 SCAR=0.0
1091 10 ▶ if ($self->{ _seen }->{ $id }->{multiref}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_seen'}{$id}{'multiref'}) { } 10 0 10
1092 10 return "ref-$id"
1093 }
1094 else {
1095 0 return undef;
1096 }
1097 }
1098  
1099 70 ▶sub encode_multirefs {
Subroutine encode_multirefs: called CC=3 SCAR=11.0
1100 70 my $self = shift;
1101 70 ▶ return if $self->multirefinplace();
Branch: 1 branch
BranchTrueFalseTotal
if $self->multirefinplace 1 69 70
1102  
1103 69 my $seen = $self->{ _seen };
1104 1 map { $_->[1]->{_id} = 1; $_ }
1105 1 map { $self->encode_object($seen->{$_}->{value}) }
1106 69 ▶ grep { $seen->{$_}->{multiref} && !$seen->{$_}->{recursive} }
Condition100%3/3
$seen->{$_}{'multiref'} && !$seen->{$_}{'recursive'}
!ll&&!rl&&r
50731
MC/DC100%2/2
$seen->{$_}{'multiref'} && !$seen->{$_}{'recursive'}
$seen->{$_}{'multiref'} !$seen->{$_}{'recursive'}
Truth table100%3/3
A && not(B)
A= $seen->{$_}{'multiref'}B= !$seen->{$_}{'recursive'}
ABresult
0X0
100
111
1107 keys %$seen;
1108 }
1109  
1110 184 ▶sub maptypetouri {
Subroutine maptypetouri: called CC=7 SCAR=19.9
1111 184 my($self, $type, $simple) = @_;
1112  
1113 184 ▶ return $type unless defined $type;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 177 7 184
1114 7 my($prefix, $name) = SOAP::Utils::splitqname($type);
1115  
1116 7 ▶ unless (defined $prefix) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $prefix) 5 2 7
1117 5 $name =~ s/__|\./::/g;
1118 $self->maptype->{$name} = $simple
1119 ? die "Schema/namespace for type '$type' is not specified\n"
1120 : $SOAP::Constants::NS_SL_PERLTYPE
1121 5 ▶ unless exists $self->maptype->{$name};
Branch: 2 branches
BranchTrueFalseTotal
unless exists $self->maptype->{$name} 5 0 5
$simple ? : 1 4 5
1122 $type = $self->maptype->{$name}
1123 4 ▶ ? SOAP::Utils::qualify($self->namespaces->{$self->maptype->{$name}} ||= gen_ns, $type)
Branch: 1 branch
BranchTrueFalseTotal
$self->maptype->{$name} ? : 4 0 4
Condition33%1/3
$self->namespaces->{$self->maptype->{$name}} ||= gen_ns()
l!l&&r!l&&!r
040
MC/DC0%0/2
$self->namespaces->{$self->maptype->{$name}} ||= gen_ns()
$self->namespaces->{$self->maptype->{$name}} gen_ns()
Truth table33%1/3
A ||= B
A= $self->namespaces->{$self->maptype->{$name}}B= gen_ns()
ABresult
1X1
011
000
1124 : undef;
1125 }
1126 6 return $type;
1127 }
1128  
1129 599 ▶sub encode_object {
Subroutine encode_object: called CC=31 SCAR=35.9
1130 599 my($self, $object, $name, $type, $attr) = @_;
1131  
1132 599 ▶ $attr ||= {};
Condition100%2/2
$attr ||= {}
l!l
325274
MC/DC100%1/1
$attr ||= {}
$attr
Truth table100%2/2
A
A= $attr
Aresult
11
00
1133 599 ▶ return $self->encode_scalar($object, $name, $type, $attr)
Branch: 1 branch
BranchTrueFalseTotal
unless ref $object 63 536 599
1134 unless ref $object;
1135  
1136 536 my $id = $self->multiref_object($object);
1137  
1138 44 ▶ use vars '%objectstack'; # we'll play with symbol table
Subroutine BEGIN: called CC=1 SCAR=0.0
1139 536 local %objectstack = %objectstack; # want to see objects ONLY in the current tree
1140  
1141 # did we see this object in current tree? Seems to be recursive refs
1142 # same as call to $self->recursive_object($object) - but
1143 # recursive_object($object) has to re-compute the object's id
1144 536 ▶ if (++$objectstack{ $id } > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$SOAP::Serializer::objectstack{$id} > 1) 5 531 536
1145 5 $self->{ _seen }->{ $id }->{recursive} = 1
1146 }
1147  
1148 # return if we already saw it twice. It should be already properly serialized
1149 536 ▶ return if $objectstack{$id} > 2;
Branch: 1 branch
BranchTrueFalseTotal
if $SOAP::Serializer::objectstack{$id} > 2 2 534 536
1150  
1151 534 ▶ if (UNIVERSAL::isa($object => 'SOAP::Data')) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($object, "SOAP::Data")) 342 192 534
1152 # use $object->SOAP::Data:: to enable overriding name() and others in inherited classes
1153 342 ▶ $object->SOAP::Data::name($name)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $object->SOAP::Data::name 115 227 342
1154 unless defined $object->SOAP::Data::name;
1155  
1156 # apply ->uri() and ->prefix() which can modify name and attributes of
1157 # element, but do not modify SOAP::Data itself
1158 342 my($name, $attr) = $self->fixattrs($object);
1159 342 $attr = $self->attrstoqname($attr);
1160  
1161 342 my @realvalues = $object->SOAP::Data::value;
1162 342 ▶ return [$name || gen_name, $attr] unless @realvalues;
Branch: 1 branch
BranchTrueFalseTotal
unless @realvalues 4 338 342
Condition33%1/3
$name || gen_name()
l!l&&r!l&&!r
400
MC/DC0%0/2
$name || gen_name()
$name gen_name()
Truth table33%1/3
A || B
A= $nameB= gen_name()
ABresult
1X1
011
000
1163  
1164 338 ▶ my $method = "as_" . ($object->SOAP::Data::type || '-'); # dummy type if not defined
Condition100%2/2
$object->SOAP::Data::type || '-'
l!l
6332
MC/DC100%1/1
$object->SOAP::Data::type || '-'
$object->SOAP::Data::type
Truth table100%2/2
A
A= $object->SOAP::Data::type
Aresult
11
00
1165 # try to call method specified for this type
1166 44 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
1167 my @values = map {
1168 # store null/nil attribute if value is undef
1169 338 ▶ local $attr->{SOAP::Utils::qualify(xsi => $self->xmlschemaclass->nilValue)} = $self->xmlschemaclass->as_undef(1)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 17 344 361
1170 unless defined;
1171 361 ▶ $self->can($method) && $self->$method($_, $name || gen_name, $object->SOAP::Data::type, $attr)
Condition73%11/15
$self->can($method) && $self->$method($_, $name || gen_name(), $object->SOAP::Data::type, $attr) || $self->typecast($_, $name || gen_name(), $object->SOAP::Data::type, $attr) || $self->encode_object($_, $name, $object->SOAP::Data::type, $attr)
l!l&&r!l&&!r
373230
$self->can($method) and $self->$method($_, $name || gen_name(), $object->SOAP::Data::type, $attr) or $self->typecast($_, $name || gen_name(), $object->SOAP::Data::type, $attr)
l!l&&r!l&&!r
433324
$self->can($method) and $self->$method($_, $name || gen_name(), $object->SOAP::Data::type, $attr)
!ll&&!rl&&r
35704
$name || gen_name()
l!l&&r!l&&!r
130
$name || gen_name()
l!l&&r!l&&!r
2231340
MC/DC0%0/4
$self->can($method) && $self->$method($_, $name || gen_name(), $object->SOAP::Data::type, $attr) || $self->typecast($_, $name || gen_name(), $object->SOAP::Data::type, $attr) || $self->encode_object($_, $name, $object->SOAP::Data::type, $attr)
$self->can($method) $self->$method($_, $name || gen_name(), $object->SOAP::Data::type, $attr) $self->typecast($_, $name || gen_name(), $object->SOAP::Data::type, $attr) $self->encode_object($_, $name, $object->SOAP::Data::type, $attr)
MC/DC0%0/2
$name || gen_name()
$name gen_name()
MC/DC0%0/2
$name || gen_name()
$name gen_name()
Truth table42%3/7
A and B or C || D
A= $self->can($method)B= $self->$method($_, $name || gen_name(), $object->SOAP::Data::type, $attr)C= $self->typecast($_, $name || gen_name(), $object->SOAP::Data::type, $attr)D= $self->encode_object($_, $name, $object->SOAP::Data::type, $attr)
ABCDresult
11XX1
0X1X1
101X1
0X011
10011
0X000
10000
Truth table66%2/3
A || B
A= $nameB= gen_name()
ABresult
1X1
011
000
Truth table66%2/3
A || B
A= $nameB= gen_name()
ABresult
1X1
011
000
1172 || $self->typecast($_, $name || gen_name, $object->SOAP::Data::type, $attr)
1173 || $self->encode_object($_, $name, $object->SOAP::Data::type, $attr)
1174 } @realvalues;
1175 337 ▶ $object->SOAP::Data::signature([map {join $;, $_->[0], SOAP::Utils::disqualify($_->[1]->{'xsi:type'} || '')} @values]) if @values;
Branch: 1 branch
BranchTrueFalseTotal
if @values 337 0 337
Condition100%2/2
$_->[1]{'xsi:type'} || ''
l!l
49311
MC/DC100%1/1
$_->[1]{'xsi:type'} || ''
$_->[1]{'xsi:type'}
Truth table100%2/2
A
A= $_->[1]{'xsi:type'}
Aresult
11
00
1176 337 ▶ return wantarray ? @values : $values[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 336 1 337
1177 }
1178  
1179 192 my $class = ref $object;
1180  
1181 192 ▶ if ($class !~ /^(?:SCALAR|ARRAY|HASH|REF)$/o) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($class =~ /^(?:SCALAR|ARRAY|HASH|REF)$/o) 3 189 192
1182 # we could also check for CODE|GLOB|LVALUE, but we cannot serialize
1183 # them anyway, so they'll be caught by check below
1184 3 $class =~ s/::/__/g;
1185  
1186 3 ▶ $name = $class if !defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 2 1 3
1187 3 ▶ $type = $class if !defined $type && $self->autotype;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $type and $self->autotype 3 0 3
Condition33%1/3
not defined $type and $self->autotype
!ll&&!rl&&r
003
MC/DC0%0/2
not defined $type and $self->autotype
not defined $type $self->autotype
Truth table33%1/3
not(A) and B
A= not defined $typeB= $self->autotype
ABresult
0X0
100
111
1188  
1189 3 my $method = 'as_' . $class;
1190 3 ▶ if ($self->can($method)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->can($method)) 0 3 3
1191 44 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
1192 0 my $encoded = $self->$method($object, $name, $type, $attr);
1193 0 ▶ return $encoded if ref $encoded;
Branch: 1 branch
BranchTrueFalseTotal
if ref $encoded 0 0 0
1194 # return only if handled, otherwise handle with default handlers
1195 }
1196 }
1197  
1198 192 ▶ if (UNIVERSAL::isa($object => 'REF') || UNIVERSAL::isa($object => 'SCALAR')) {
Branch: 3 branches
BranchTrueFalseTotal
if (UNIVERSAL::isa($object, 'REF') or UNIVERSAL::isa($object, 'SCALAR')) { } 176 16 192
elsif (UNIVERSAL::isa($object, 'ARRAY')) { } 6 10 16
elsif (UNIVERSAL::isa($object, 'HASH')) { } 10 0 10
Condition100%3/3
UNIVERSAL::isa($object, "REF") or UNIVERSAL::isa($object, "SCALAR")
l!l&&r!l&&!r
170616
MC/DC100%2/2
UNIVERSAL::isa($object, "REF") or UNIVERSAL::isa($object, "SCALAR")
UNIVERSAL::isa($object, "REF") UNIVERSAL::isa($object, "SCALAR")
Truth table100%3/3
A or B
A= UNIVERSAL::isa($object, "REF")B= UNIVERSAL::isa($object, "SCALAR")
ABresult
1X1
011
000
1199 176 return $self->encode_scalar($object, $name, $type, $attr);
1200 }
1201 elsif (UNIVERSAL::isa($object => 'ARRAY')) {
1202 # Added in SOAP::Lite 0.65_6 to fix an XMLRPC bug
1203 6 ▶ return $self->encodingStyle eq ""
Branch: 1 branch
BranchTrueFalseTotal
$self->encodingStyle eq '' || $self->isa('XMLRPC::Serializer') ? : 0 6 6
Condition33%1/3
$self->encodingStyle eq "" or $self->isa("XMLRPC::Serializer")
l!l&&r!l&&!r
006
MC/DC0%0/2
$self->encodingStyle eq "" or $self->isa("XMLRPC::Serializer")
$self->encodingStyle eq "" $self->isa("XMLRPC::Serializer")
Truth table33%1/3
A or B
A= $self->encodingStyle eq ""B= $self->isa("XMLRPC::Serializer")
ABresult
1X1
011
000
1204 || $self->isa('XMLRPC::Serializer')
1205 ? $self->encode_array($object, $name, $type, $attr)
1206 : $self->encode_literal_array($object, $name, $type, $attr);
1207 }
1208 elsif (UNIVERSAL::isa($object => 'HASH')) {
1209 10 return $self->encode_hash($object, $name, $type, $attr);
1210 }
1211 else {
1212 0 return $self->on_nonserialized->($object);
1213 }
1214 }
1215  
1216 256 ▶sub encode_scalar {
Subroutine encode_scalar: called CC=9 SCAR=22.3
1217 256 my($self, $value, $name, $type, $attr) = @_;
1218 256 ▶ $name ||= gen_name;
Condition66%2/3
$name ||= gen_name()
l!l&&r!l&&!r
214420
MC/DC0%0/2
$name ||= gen_name()
$name gen_name()
Truth table66%2/3
A ||= B
A= $nameB= gen_name()
ABresult
1X1
011
000
1219  
1220 256 my $schemaclass = $self->xmlschemaclass;
1221  
1222 # null reference
1223 256 ▶ return [$name, {%$attr, SOAP::Utils::qualify(xsi => $schemaclass->nilValue) => $schemaclass->as_undef(1)}] unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 13 243 256
1224  
1225 # object reference
1226 243 ▶ return [$name, {'xsi:type' => $self->maptypetouri($type), %$attr}, [$self->encode_object($$value)], $self->gen_id($value)] if ref $value;
Branch: 1 branch
BranchTrueFalseTotal
if ref $value 176 67 243
1227  
1228 # autodefined type
1229 67 ▶ if ($self->{ _autotype}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_autotype"}) 65 2 67
1230 65 my $lookup = $self->{_typelookup};
1231 44 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
1232 #for (sort {$lookup->{$a}->[0] <=> $lookup->{$b}->[0]} keys %$lookup) {
1233 65 for (@{ $self->{ _typelookup_order } }) {
1234 485 my $method = $lookup->{$_}->[2];
1235 return $self->can($method) && $self->$method($value, $name, $type, $attr)
1236 || $method->($value, $name, $type, $attr)
1237 485 ▶ if $lookup->{$_}->[1]->($value);
Branch: 1 branch
BranchTrueFalseTotal
if $lookup->{$_}[1]->($value) 65 420 485
Condition33%2/6
$self->can($method) && $self->$method($value, $name, $type, $attr) || &$method($value, $name, $type, $attr)
l!l&&r!l&&!r
6500
$self->can($method) and $self->$method($value, $name, $type, $attr)
!ll&&!rl&&r
0065
MC/DC0%0/3
$self->can($method) && $self->$method($value, $name, $type, $attr) || &$method($value, $name, $type, $attr)
$self->can($method) $self->$method($value, $name, $type, $attr) &$method($value, $name, $type, $attr)
Truth table20%1/5
A and B || C
A= $self->can($method)B= $self->$method($value, $name, $type, $attr)C= &$method($value, $name, $type, $attr)
ABCresult
11X1
0X11
1011
0X00
1000
1238 }
1239 }
1240  
1241 # invariant
1242 2 return [$name, $attr, $value];
1243 }
1244  
1245 0 ▶sub encode_array {
Subroutine encode_array: not called CC=9 SCAR=45.0
1246 0 my ($self, $array, $name, $type, $attr) = @_;
1247 0 my $items = 'item';
1248  
1249 # If typing is disabled, just serialize each of the array items
1250 # with no type information, each using the specified name,
1251 # and do not create a wrapper array tag.
1252 0 ▶ if (!$self->autotype) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->autotype) 0 0 0
1253 0 ▶ $name ||= gen_name;
Condition0%0/3
$name ||= gen_name()
l!l&&r!l&&!r
000
MC/DC0%0/2
$name ||= gen_name()
$name gen_name()
Truth table0%0/3
A ||= B
A= $nameB= gen_name()
ABresult
1X1
011
000
1254 0 return map {$self->encode_object($_, $name)} @$array;
1255 }
1256  
1257 # TODO: add support for multidimensional, partially transmitted and sparse arrays
1258 0 my @items = map {$self->encode_object($_, $items)} @$array;
1259 0 my $num = @items;
1260 0 my($arraytype, %types) = '-';
1261 0 ▶ for (@items) { $arraytype = $_->[1]->{'xsi:type'} || '-'; $types{$arraytype}++ }
Condition0%0/2
$_->[1]{'xsi:type'} || '-'
l!l
00
MC/DC0%0/1
$_->[1]{'xsi:type'} || '-'
$_->[1]{'xsi:type'}
Truth table0%0/2
A
A= $_->[1]{'xsi:type'}
Aresult
11
00
1262 0 ▶ $arraytype = sprintf "%s\[$num]", keys %types > 1 || $arraytype eq '-' ? SOAP::Utils::qualify(xsd => $self->xmlschemaclass->anyTypeValue) : $arraytype;
Branch: 1 branch
BranchTrueFalseTotal
keys %types > 1 || $arraytype eq '-' ? : 0 0 0
Condition0%0/3
keys %types > 1 or $arraytype eq "-"
l!l&&r!l&&!r
000
MC/DC0%0/2
keys %types > 1 or $arraytype eq "-"
keys %types > 1 $arraytype eq "-"
Truth table0%0/3
A or B
A= keys %types > 1B= $arraytype eq "-"
ABresult
1X1
011
000
1263  
1264 # $type = SOAP::Utils::qualify($self->encprefix => 'Array') if $self->autotype && !defined $type;
1265 0 ▶ $type = qualify($self->encprefix => 'Array') if !defined $type;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 0 0 0
1266 0 ▶ return [$name || SOAP::Utils::qualify($self->encprefix => 'Array'),
Condition0%0/3
$name || SOAP::Utils::qualify($self->encprefix, 'Array')
l!l&&r!l&&!r
000
MC/DC0%0/2
$name || SOAP::Utils::qualify($self->encprefix, 'Array')
$name SOAP::Utils::qualify($self->encprefix, 'Array')
Truth table0%0/3
A || B
A= $nameB= SOAP::Utils::qualify($self->encprefix, 'Array')
ABresult
1X1
011
000
1267 {
1268 SOAP::Utils::qualify($self->encprefix => 'arrayType') => $arraytype,
1269 'xsi:type' => $self->maptypetouri($type), %$attr
1270 },
1271 [@items],
1272 $self->gen_id($array)
1273 ];
1274 }
1275  
1276 # Will encode arrays using doc-literal style
1277 6 ▶sub encode_literal_array {
Subroutine encode_literal_array: called CC=11 SCAR=24.0
1278 6 my($self, $array, $name, $type, $attr) = @_;
1279  
1280 6 ▶ if ($self->autotype) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->autotype) { } 3 3 6
1281 3 my $items = 'item';
1282  
1283 # TODO: add support for multidimensional, partially transmitted and sparse arrays
1284 3 my @items = map {$self->encode_object($_, $items)} @$array;
1285  
1286  
1287 3 my $num = @items;
1288 3 my($arraytype, %types) = '-';
1289 3 for (@items) {
1290 6 ▶ $arraytype = $_->[1]->{'xsi:type'} || '-';
Condition100%2/2
$_->[1]{'xsi:type'} || '-'
l!l
42
MC/DC100%1/1
$_->[1]{'xsi:type'} || '-'
$_->[1]{'xsi:type'}
Truth table100%2/2
A
A= $_->[1]{'xsi:type'}
Aresult
11
00
1291 6 $types{$arraytype}++
1292 }
1293 3 ▶ $arraytype = sprintf "%s\[$num]", keys %types > 1 || $arraytype eq '-'
Branch: 1 branch
BranchTrueFalseTotal
keys %types > 1 || $arraytype eq '-' ? : 2 1 3
Condition100%3/3
keys %types > 1 or $arraytype eq "-"
l!l&&r!l&&!r
111
MC/DC100%2/2
keys %types > 1 or $arraytype eq "-"
keys %types > 1 $arraytype eq "-"
Truth table100%3/3
A or B
A= keys %types > 1B= $arraytype eq "-"
ABresult
1X1
011
000
1294 ? SOAP::Utils::qualify(xsd => $self->xmlschemaclass->anyTypeValue)
1295 : $arraytype;
1296  
1297 3 ▶ $type = SOAP::Utils::qualify($self->encprefix => 'Array')
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 2 1 3
1298 if !defined $type;
1299  
1300 3 ▶ return [$name || SOAP::Utils::qualify($self->encprefix => 'Array'),
Condition66%2/3
$name || SOAP::Utils::qualify($self->encprefix, 'Array')
l!l&&r!l&&!r
210
MC/DC0%0/2
$name || SOAP::Utils::qualify($self->encprefix, 'Array')
$name SOAP::Utils::qualify($self->encprefix, 'Array')
Truth table66%2/3
A || B
A= $nameB= SOAP::Utils::qualify($self->encprefix, 'Array')
ABresult
1X1
011
000
1301 {
1302 SOAP::Utils::qualify($self->encprefix => 'arrayType') => $arraytype,
1303 'xsi:type' => $self->maptypetouri($type), %$attr
1304 },
1305 [ @items ],
1306 $self->gen_id($array)
1307 ];
1308 }
1309 else {
1310 #
1311 # literal arrays are different - { array => [ 5,6 ] }
1312 # results in <array>5</array><array>6</array>
1313 # This means that if there's a literal inside the array (not a
1314 # reference), we have to encode it this way. If there's only
1315 # nested tags, encode as
1316 # <array><foo>1</foo><foo>2</foo></array>
1317 #
1318  
1319 3 my $literal = undef;
1320 my @items = map {
1321 3 ref $_
1322 ? $self->encode_object($_)
1323 6 ▶ : do {
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 2 4 6
1324 4 $literal++;
1325 4 $_
1326 }
1327  
1328 } @$array;
1329  
1330 3 ▶ if ($literal) {
Branch: 1 branch
BranchTrueFalseTotal
if ($literal) { } 2 1 3
1331 2 return map { [ $name , $attr , $_, $self->gen_id($array) ] } @items;
1332 }
1333 else {
1334 1 ▶ return [$name || SOAP::Utils::qualify($self->encprefix => 'Array'),
Condition33%1/3
$name || SOAP::Utils::qualify($self->encprefix, 'Array')
l!l&&r!l&&!r
100
MC/DC0%0/2
$name || SOAP::Utils::qualify($self->encprefix, 'Array')
$name SOAP::Utils::qualify($self->encprefix, 'Array')
Truth table33%1/3
A || B
A= $nameB= SOAP::Utils::qualify($self->encprefix, 'Array')
ABresult
1X1
011
000
1335 $attr,
1336 [ @items ],
1337 $self->gen_id($array)
1338 ];
1339 }
1340 }
1341 }
1342  
1343 10 ▶sub encode_hash {
Subroutine encode_hash: called CC=11 SCAR=30.6
1344 10 my($self, $hash, $name, $type, $attr) = @_;
1345  
1346 10 ▶ if ($self->autotype && grep {!/$SOAP::Constants::ELMASK/o} keys %$hash) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->autotype and grep {not /$SOAP::Constants::ELMASK/o;} keys %$hash) 0 10 10
Condition66%2/3
$self->autotype and grep {not /$SOAP::Constants::ELMASK/o;} keys %$hash
!ll&&!rl&&r
640
MC/DC0%0/2
$self->autotype and grep {not /$SOAP::Constants::ELMASK/o;} keys %$hash
$self->autotype grep {not /$SOAP::Constants::ELMASK/o;} keys %$hash
Truth table66%2/3
A and B
A= $self->autotypeB= grep {not /$SOAP::Constants::ELMASK/o;} keys %$hash
ABresult
0X0
100
111
1347 0 ▶ warn qq!Cannot encode @{[$name ? "'$name'" : 'unnamed']} element as 'hash'. Will be encoded as 'map' instead\n! if $^W;
Branch: 2 branches
BranchTrueFalseTotal
if $^W 0 0 0
$name ? : 0 0 0
1348 0 ▶ return $self->as_map($hash, $name || gen_name, $type, $attr);
Condition0%0/3
$name || gen_name()
l!l&&r!l&&!r
000
MC/DC0%0/2
$name || gen_name()
$name gen_name()
Truth table0%0/3
A || B
A= $nameB= gen_name()
ABresult
1X1
011
000
1349 }
1350  
1351 $type = 'SOAPStruct'
1352 10 ▶ if $self->autotype && !defined($type) && exists $self->maptype->{SOAPStruct};
Branch: 1 branch
BranchTrueFalseTotal
if $self->autotype and not defined $type and exists $self->maptype->{"SOAPStruct"} 0 10 10
Condition83%5/6
$self->autotype and not defined $type and exists $self->maptype->{"SOAPStruct"}
!ll&&!rl&&r
910
$self->autotype and not defined $type
!ll&&!rl&&r
631
MC/DC0%0/3
$self->autotype and not defined $type and exists $self->maptype->{"SOAPStruct"}
$self->autotype not defined $type exists $self->maptype->{"SOAPStruct"}
Truth table75%3/4
A and not(B) and C
A= $self->autotypeB= not defined $typeC= exists $self->maptype->{"SOAPStruct"}
ABCresult
0XX0
10X0
1100
1111
1353 return [$name || gen_name,
1354 $self->autotype ? {'xsi:type' => $self->maptypetouri($type), %$attr} : { %$attr },
1355 10 ▶ [map {$self->encode_object($hash->{$_}, $_)} keys %$hash],
Branch: 1 branch
BranchTrueFalseTotal
$self->autotype ? : 4 6 10
Condition66%2/3
$name || gen_name()
l!l&&r!l&&!r
640
MC/DC0%0/2
$name || gen_name()
$name gen_name()
Truth table66%2/3
A || B
A= $nameB= gen_name()
ABresult
1X1
011
000
1356 $self->gen_id($hash)
1357 ];
1358 }
1359  
1360 0 ▶sub as_ordered_hash {
Subroutine as_ordered_hash: not called CC=2 SCAR=17.9
1361 0 my ($self, $value, $name, $type, $attr) = @_;
1362 0 ▶ die "Not an ARRAY reference for 'ordered_hash' type" unless UNIVERSAL::isa($value => 'ARRAY');
Branch: 1 branch
BranchTrueFalseTotal
unless UNIVERSAL::isa($value, "ARRAY") 0 0 0
1363 return [ $name, $attr,
1364 0 [map{$self->encode_object(@{$value}[2*$_+1,2*$_])} 0..$#$value/2 ],
1365 $self->gen_id($value)
1366 ];
1367 }
1368  
1369 0 ▶sub as_map {
Subroutine as_map: not called CC=3 SCAR=24.8
1370 0 my ($self, $value, $name, $type, $attr) = @_;
1371 0 ▶ die "Not a HASH reference for 'map' type" unless UNIVERSAL::isa($value => 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
unless UNIVERSAL::isa($value, "HASH") 0 0 0
1372 0 ▶ my $prefix = ($self->namespaces->{$SOAP::Constants::NS_APS} ||= 'apachens');
Condition0%0/2
$self->namespaces->{$SOAP::Constants::NS_APS} ||= "apachens"
l!l
00
MC/DC0%0/1
$self->namespaces->{$SOAP::Constants::NS_APS} ||= "apachens"
$self->namespaces->{$SOAP::Constants::NS_APS}
Truth table0%0/2
A
A= $self->namespaces->{$SOAP::Constants::NS_APS}
Aresult
11
00
1373 my @items = map {
1374 0 $self->encode_object(
1375 SOAP::Data->type(
1376 ordered_hash => [
1377 key => $_,
1378 0 value => $value->{$_}
1379 ]
1380 ),
1381 'item',
1382 ''
1383 )} sort keys %$value;
1384 return [
1385 0 $name,
1386 {'xsi:type' => "$prefix:Map", %$attr},
1387 [@items],
1388 $self->gen_id($value)
1389 ];
1390 }
1391  
1392 0 ▶sub as_xml {
Subroutine as_xml: not called CC=1 SCAR=6.9
1393 0 my $self = shift;
1394 0 my($value, $name, $type, $attr) = @_;
1395 0 return [$name, {'_xml' => 1}, $value];
1396 }
1397  
1398 357 ▶sub typecast {
Subroutine typecast: called CC=6 SCAR=17.9
1399 357 my $self = shift;
1400 357 my($value, $name, $type, $attr) = @_;
1401 357 ▶ return if ref $value; # skip complex object, caller knows how to deal with it
Branch: 1 branch
BranchTrueFalseTotal
if ref $value 277 80 357
1402 80 ▶ return if $self->autotype && !defined $type; # we don't know, autotype knows
Branch: 1 branch
BranchTrueFalseTotal
if $self->autotype and not defined $type 46 34 80
Condition100%3/3
$self->autotype and not defined $type
!ll&&!rl&&r
23246
MC/DC100%2/2
$self->autotype and not defined $type
$self->autotype not defined $type
Truth table100%3/3
A and not(B)
A= $self->autotypeB= not defined $type
ABresult
0X0
100
111
1403 34 ▶ return [$name,
Branch: 1 branch
BranchTrueFalseTotal
defined $type && $type gt '' ? : 1 33 34
Condition100%3/3
defined $type and $type gt ""
!ll&&!rl&&r
2311
MC/DC100%2/2
defined $type and $type gt ""
defined $type $type gt ""
Truth table100%3/3
A and B
A= defined $typeB= $type gt ""
ABresult
0X0
100
111
1404 {(defined $type && $type gt '' ? ('xsi:type' => $self->maptypetouri($type, 'simple type')) : ()), %$attr},
1405 $value
1406 ];
1407 }
1408  
1409 178 ▶sub register_ns {
Subroutine register_ns: called CC=3 SCAR=11.0
1410 178 my $self = shift->new();
1411 178 my ($ns,$prefix) = @_;
1412 178 ▶ $prefix = gen_ns if !$prefix;
Branch: 1 branch
BranchTrueFalseTotal
unless $prefix 9 169 178
1413 178 ▶ $self->{'_namespaces'}->{$ns} = $prefix if $ns;
Branch: 1 branch
BranchTrueFalseTotal
if $ns 160 18 178
1414 }
1415  
1416 6 ▶sub find_prefix {
Subroutine find_prefix: called CC=2 SCAR=6.9
1417 6 my ($self, $ns) = @_;
1418 return (exists $self->{'_namespaces'}->{$ns})
1419 6 ▶ ? $self->{'_namespaces'}->{$ns}
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{'_namespaces'}{$ns} ? : 4 2 6
1420 : ();
1421 }
1422  
1423 342 ▶sub fixattrs {
Subroutine fixattrs: called CC=15 SCAR=28.6
1424 342 my ($self, $data) = @_;
1425 342 my ($name, $attr) = ($data->SOAP::Data::name, {%{$data->SOAP::Data::attr}});
1426 342 my ($xmlns, $prefix) = ($data->uri, $data->prefix);
1427 342 ▶ unless (defined($xmlns) || defined($prefix)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $xmlns or defined $prefix) 205 137 342
Condition100%3/3
defined $xmlns or defined $prefix
l!l&&r!l&&!r
1136205
MC/DC100%2/2
defined $xmlns or defined $prefix
defined $xmlns defined $prefix
Truth table100%3/3
A or B
A= defined $xmlnsB= defined $prefix
ABresult
1X1
011
000
1428 205 ▶ $self->register_ns($xmlns,$prefix) unless ($self->use_default_ns);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->use_default_ns 9 196 205
1429 205 return ($name, $attr);
1430 }
1431 137 ▶ $name ||= gen_name(); # local name
Condition66%2/3
$name ||= gen_name()
l!l&&r!l&&!r
13610
MC/DC0%0/2
$name ||= gen_name()
$name gen_name()
Truth table66%2/3
A ||= B
A= $nameB= gen_name()
ABresult
1X1
011
000
1432 137 ▶ $prefix = gen_ns() if !defined $prefix && $xmlns gt '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $prefix and $xmlns gt "" 1 136 137
Condition66%2/3
not defined $prefix and $xmlns gt ""
!ll&&!rl&&r
13601
MC/DC50%1/2
not defined $prefix and $xmlns gt ""
not defined $prefix $xmlns gt ""
Truth table66%2/3
not(A) and B
A= not defined $prefixB= $xmlns gt ""
ABresult
0X0
100
111
1433 137 ▶ $prefix = ''
Branch: 1 branch
BranchTrueFalseTotal
if defined $xmlns and $xmlns eq "" or defined $prefix and $prefix eq "" 0 137 137
Condition44%4/9
defined $xmlns and $xmlns eq "" or defined $prefix and $prefix eq ""
l!l&&r!l&&!r
00137
defined $xmlns and $xmlns eq ""
!ll&&!rl&&r
13610
defined $prefix and $prefix eq ""
!ll&&!rl&&r
01370
MC/DC0%0/4
defined $xmlns and $xmlns eq "" or defined $prefix and $prefix eq ""
defined $xmlns $xmlns eq "" defined $prefix $prefix eq ""
Truth table28%2/7
A and B or C and D
A= defined $xmlnsB= $xmlns eq ""C= defined $prefixD= $prefix eq ""
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
1434 if defined $xmlns && $xmlns eq ''
1435 || defined $prefix && $prefix eq '';
1436  
1437 137 ▶ $attr->{join ':', xmlns => $prefix || ()} = $xmlns if defined $xmlns;
Branch: 1 branch
BranchTrueFalseTotal
if defined $xmlns 1 136 137
Condition33%1/3
$prefix || ()
l!l&&r!l&&!r
100
MC/DC0%0/2
$prefix || ()
$prefix ()
Truth table33%1/3
A || B
A= $prefixB= ()
ABresult
1X1
011
000
1438 137 ▶ $name = join ':', $prefix, $name if $prefix;
Branch: 1 branch
BranchTrueFalseTotal
if $prefix 137 0 137
1439  
1440 137 ▶ $self->register_ns($xmlns,$prefix) unless ($self->use_default_ns);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->use_default_ns 9 128 137
1441  
1442 137 return ($name, $attr);
1443  
1444 }
1445  
1446 59 ▶sub toqname {
Subroutine toqname: called CC=3 SCAR=12.0
1447 59 my $self = shift;
1448 59 my $long = shift;
1449  
1450 59 ▶ return $long unless $long =~ /^\{(.*)\}(.+)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $long =~ /^\{(.*)\}(.+)$/ 0 59 59
1451 59 ▶ return SOAP::Utils::qualify $self->namespaces->{$1} ||= gen_ns, $2;
Condition33%1/3
$self->namespaces->{$1} ||= gen_ns()
l!l&&r!l&&!r
5900
MC/DC0%0/2
$self->namespaces->{$1} ||= gen_ns()
$self->namespaces->{$1} gen_ns()
Truth table33%1/3
A ||= B
A= $self->namespaces->{$1}B= gen_ns()
ABresult
1X1
011
000
1452 }
1453  
1454 342 ▶sub attrstoqname {
Subroutine attrstoqname: called CC=4 SCAR=14.6
1455 342 my $self = shift;
1456 342 my $attrs = shift;
1457  
1458 return {
1459 342 map { /^\{(.*)\}(.+)$/
1460 ? ($self->toqname($_) => $2 eq 'type'
1461 || $2 eq 'arrayType'
1462 ? $self->toqname($attrs->{$_})
1463 : $attrs->{$_})
1464 93 ▶ : ($_ => $attrs->{$_})
Branch: 2 branches
BranchTrueFalseTotal
/^\{(.*)\}(.+)$/ ? : 59 34 93
$2 eq 'type' || $2 eq 'arrayType' ? : 0 59 59
Condition33%1/3
$2 eq "type" or $2 eq "arrayType"
l!l&&r!l&&!r
0059
MC/DC0%0/2
$2 eq "type" or $2 eq "arrayType"
$2 eq "type" $2 eq "arrayType"
Truth table33%1/3
A or B
A= $2 eq "type"B= $2 eq "arrayType"
ABresult
1X1
011
000
1465 } keys %$attrs
1466 };
1467 }
1468  
1469 292 ▶sub tag {
Subroutine tag: called CC=18 SCAR=29.2
1470 292 my ($self, $tag, $attrs, @values) = @_;
1471  
1472 292 my $readable = $self->{ _readable };
1473  
1474 292 my $value = join '', @values;
1475 292 ▶ my $indent = $readable ? ' ' x (($self->{ _level }-1)*2) : '';
Branch: 1 branch
BranchTrueFalseTotal
$readable ? : 6 286 292
1476  
1477 # check for special attribute
1478 292 ▶ return "$indent$value" if exists $attrs->{_xml} && delete $attrs->{_xml};
Branch: 1 branch
BranchTrueFalseTotal
if exists $attrs->{"_xml"} and delete $attrs->{"_xml"} 0 292 292
Condition33%1/3
exists $attrs->{"_xml"} and delete $attrs->{"_xml"}
!ll&&!rl&&r
29200
MC/DC0%0/2
exists $attrs->{"_xml"} and delete $attrs->{"_xml"}
exists $attrs->{"_xml"} delete $attrs->{"_xml"}
Truth table33%1/3
A and B
A= exists $attrs->{"_xml"}B= delete $attrs->{"_xml"}
ABresult
0X0
100
111
1479  
1480 292 ▶ die "Element '$tag' can't be allowed in valid XML message. Died."
Branch: 1 branch
BranchTrueFalseTotal
unless $tag =~ /^$SOAP::Constants::NSMASK$/o 1 291 292
1481 if $tag !~ /^$SOAP::Constants::NSMASK$/o;
1482  
1483 291 ▶ warn "Element '$tag' uses the reserved prefix 'XML' (in any case)"
Branch: 1 branch
BranchTrueFalseTotal
unless $tag =~ /^(?![Xx][Mm][Ll])/ 1 290 291
1484 if $tag !~ /^(?![Xx][Mm][Ll])/;
1485  
1486 291 ▶ my $prolog = $readable ? "\n" : "";
Branch: 1 branch
BranchTrueFalseTotal
$readable ? : 6 285 291
1487 291 ▶ my $epilog = $readable ? "\n" : "";
Branch: 1 branch
BranchTrueFalseTotal
$readable ? : 6 285 291
1488 291 my $tagjoiner = " ";
1489 291 ▶ if ($self->{ _level } == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_level"} == 1) 76 215 291
1490 76 my $namespaces = $self->namespaces;
1491 76 foreach (keys %$namespaces) {
1492 295 $attrs->{SOAP::Utils::qualify(xmlns => $namespaces->{$_})} = $_
1493 }
1494 76 ▶ $prolog = qq!<?xml version="1.0" encoding="@{[$self->encoding]}"?>!
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->encoding 76 0 76
1495 if defined $self->encoding;
1496 76 ▶ $prolog .= "\n" if $readable;
Branch: 1 branch
BranchTrueFalseTotal
if $readable 1 75 76
1497 76 ▶ $tagjoiner = " \n".(' ' x 4 ) if $readable;
Branch: 1 branch
BranchTrueFalseTotal
if $readable 1 75 76
1498 }
1499 my $tagattrs = join($tagjoiner, '',
1500 468 map { sprintf '%s="%s"', $_, SOAP::Utils::encode_attribute($attrs->{$_}) }
1501 291 ▶ grep { $_ && defined $attrs->{$_} && ($_ ne 'xsi:type' || $attrs->{$_} ne '') }
Condition66%6/9
$_ && defined $attrs->{$_} && ($_ ne 'xsi:type' || $attrs->{$_} ne '')
!ll&&!rl&&r
1770468
$_ and defined $attrs->{$_}
!ll&&!rl&&r
0177468
$_ ne "xsi:type" or $attrs->{$_} ne ""
l!l&&r!l&&!r
414540
MC/DC25%1/4
$_ && defined $attrs->{$_} && ($_ ne 'xsi:type' || $attrs->{$_} ne '')
$_ defined $attrs->{$_} $_ ne "xsi:type" $attrs->{$_} ne ""
Truth table60%3/5
A and B && C or D
A= $_B= defined $attrs->{$_}C= $_ ne "xsi:type"D= $attrs->{$_} ne ""
ABCDresult
0XXX0
10XX0
11000
111X1
11011
1502 sort keys %$attrs);
1503  
1504 291 ▶ if ($value gt '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($value gt '') { } 264 27 291
1505 264 ▶ return sprintf("$prolog$indent<%s%s>%s%s</%s>$epilog",$tag,$tagattrs,$value,($value =~ /^\s*</ ? $indent : ""),$tag);
Branch: 1 branch
BranchTrueFalseTotal
$value =~ /^\s*</ ? : 181 83 264
1506 }
1507 else {
1508 27 return sprintf("$prolog$indent<%s%s />$epilog$indent",$tag,$tagattrs);
1509 }
1510 }
1511  
1512 288 ▶sub xmlize {
Subroutine xmlize: called CC=7 SCAR=19.5
1513 288 my $self = shift;
1514 288 my($name, $attrs, $values, $id) = @{$_[0]};
1515 288 ▶ $attrs ||= {};
Condition50%1/2
$attrs ||= {}
l!l
2880
MC/DC0%0/1
$attrs ||= {}
$attrs
Truth table50%1/2
A
A= $attrs
Aresult
11
00
1516  
1517 288 local $self->{_level} = $self->{_level} + 1;
1518  
1519 288 ▶ return $self->tag($name, $attrs)
Branch: 1 branch
BranchTrueFalseTotal
unless defined $values 16 272 288
1520 unless defined $values;
1521  
1522 272 ▶ return $self->tag($name, $attrs, $values)
Branch: 1 branch
BranchTrueFalseTotal
unless ref $values eq "ARRAY" 85 187 272
1523 unless ref $values eq "ARRAY";
1524  
1525 return $self->tag($name, {%$attrs, href => '#'.$self->multiref_anchor($id)})
1526 187 ▶ if $self->is_href($id, delete($attrs->{_id}));
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_href($id, delete $attrs->{"_id"}) 5 182 187
1527  
1528 # we have seen this element as a reference
1529 182 ▶ if (defined $id && $self->{ _seen }->{ $id }->{ multiref}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $id and $self->{'_seen'}{$id}{'multiref'}) { } 5 177 182
Condition66%2/3
defined $id and $self->{"_seen"}{$id}{"multiref"}
!ll&&!rl&&r
01775
MC/DC50%1/2
defined $id and $self->{"_seen"}{$id}{"multiref"}
defined $id $self->{"_seen"}{$id}{"multiref"}
Truth table66%2/3
A and B
A= defined $idB= $self->{"_seen"}{$id}{"multiref"}
ABresult
0X0
100
111
1530 return $self->tag($name,
1531 {
1532 %$attrs, id => $self->multiref_anchor($id)
1533 },
1534 5 map {$self->xmlize($_)} @$values
1535 );
1536 }
1537 else {
1538 177 return $self->tag($name, $attrs, map {$self->xmlize($_)} @$values);
1539 }
1540 }
1541  
1542 16 ▶sub uriformethod {
Subroutine uriformethod: called CC=14 SCAR=42.2
1543 16 my $self = shift;
1544  
1545 16 ▶ my $method_is_data = ref $_[0] && UNIVERSAL::isa($_[0] => 'SOAP::Data');
Condition33%1/3
ref $_[0] && UNIVERSAL::isa($_[0], 'SOAP::Data')
!ll&&!rl&&r
1600
MC/DC0%0/2
ref $_[0] && UNIVERSAL::isa($_[0], 'SOAP::Data')
ref $_[0] UNIVERSAL::isa($_[0], 'SOAP::Data')
Truth table33%1/3
A && B
A= ref $_[0]B= UNIVERSAL::isa($_[0], 'SOAP::Data')
ABresult
0X0
100
111
1546  
1547 # drop prefix from method that could be string or SOAP::Data object
1548 16 ▶ my($prefix, $method) = $method_is_data
Branch: 1 branch
BranchTrueFalseTotal
$method_is_data ? : 0 16 16
1549 ? ($_[0]->prefix, $_[0]->name)
1550 : SOAP::Utils::splitqname($_[0]);
1551  
1552 16 my $attr = {reverse %{$self->namespaces}};
1553 # try to define namespace that could be stored as
1554 # a) method is SOAP::Data
1555 # ? attribute in method's element as xmlns= or xmlns:${prefix}=
1556 # : uri
1557 # b) attribute in Envelope element as xmlns= or xmlns:${prefix}=
1558 # c) no prefix or prefix equal serializer->envprefix
1559 # ? '', but see comment below
1560 # : die with error message
1561 my $uri = $method_is_data
1562 16 ▶ ? ref $_[0]->attr && ($_[0]->attr->{$prefix ? "xmlns:$prefix" : 'xmlns'} || $_[0]->uri)
Branch: 2 branches
BranchTrueFalseTotal
$method_is_data ? : 0 16 16
$prefix ? : 0 0 0
Condition0%0/6
ref $_[0]->attr and $_[0]->attr->{$prefix ? "xmlns:$prefix" : "xmlns"} || $_[0]->uri
!ll&&!rl&&r
000
$_[0]->attr->{$prefix ? "xmlns:$prefix" : "xmlns"} or $_[0]->uri
l!l&&r!l&&!r
000
MC/DC0%0/3
ref $_[0]->attr and $_[0]->attr->{$prefix ? "xmlns:$prefix" : "xmlns"} || $_[0]->uri
ref $_[0]->attr $_[0]->attr->{$prefix ? "xmlns:$prefix" : "xmlns"} $_[0]->uri
Truth table0%0/4
A and B or C
A= ref $_[0]->attrB= $_[0]->attr->{$prefix ? "xmlns:$prefix" : "xmlns"}C= $_[0]->uri
ABCresult
0XX0
1000
11X1
1011
1563 : $self->uri;
1564  
1565 16 ▶ defined $uri or $uri = $attr->{$prefix || ''};
Branch: 1 branch
BranchTrueFalseTotal
defined $uri or $uri = $$attr{$prefix or ""} 16 0 16
Condition0%0/2
$prefix || ''
l!l
00
MC/DC0%0/1
$prefix || ''
$prefix
Truth table0%0/2
A
A= $prefix
Aresult
11
00
1566  
1567 16 ▶ defined $uri or $uri = !$prefix || $prefix eq $self->envprefix
Branch: 3 branches
BranchTrueFalseTotal
defined $uri or $uri = !$prefix || $prefix eq $self->envprefix ? ($method_is_data && $^W && warn("URI is not provided as an attribute for method ($method)\n"), "") : die("Can't find namespace for method (${prefix}:$method)\n") 16 0 16
!$prefix || $prefix eq $self->envprefix ? : 0 0 0
$method_is_data and $^W and warn "URI is not provided as an attribute for method ($method)\n" 0 0 0
Condition0%0/6
not $prefix or $prefix eq $self->envprefix
l!l&&r!l&&!r
000
$method_is_data and $^W
!ll&&!rl&&r
000
MC/DC0%0/2
not $prefix or $prefix eq $self->envprefix
not $prefix $prefix eq $self->envprefix
MC/DC0%0/2
$method_is_data and $^W
$method_is_data $^W
Truth table0%0/3
not(A) or B
A= not $prefixB= $prefix eq $self->envprefix
ABresult
1X1
011
000
Truth table0%0/3
A and B
A= $method_is_dataB= $^W
ABresult
0X0
100
111
1568 # still in doubts what should namespace be in this case
1569 # but will keep it like this for now and be compatible with our server
1570 ? ( $method_is_data
1571 && $^W
1572 && warn("URI is not provided as an attribute for method ($method)\n"),
1573 ''
1574 )
1575 : die "Can't find namespace for method ($prefix:$method)\n";
1576  
1577 16 return ($uri, $method);
1578 }
1579  
1580 18 ▶sub serialize { SOAP::Trace::trace('()');
Subroutine serialize: called CC=3 SCAR=11.0
1581 18 my $self = shift->new;
1582 18 ▶ @_ == 1 or Carp::croak "serialize() method accepts one parameter";
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 or Carp::croak("serialize() method accepts one parameter") 18 0 18
1583  
1584 18 $self->seen({}); # reinitialize multiref table
1585 18 my($encoded) = $self->encode_object($_[0]);
1586  
1587 # now encode multirefs if any
1588 # v -------------- subelements of Envelope
1589 17 ▶ push(@{$encoded->[2]}, $self->encode_multirefs) if ref $encoded->[2];
Branch: 1 branch
BranchTrueFalseTotal
if ref $encoded->[2] 11 6 17
1590 17 return $self->xmlize($encoded);
1591 }
1592  
1593 59 ▶sub envelope {
Subroutine envelope: called CC=32 SCAR=36.9
1594 59 SOAP::Trace::trace('()');
1595 59 my $self = shift->new;
1596 59 my $type = shift;
1597 59 my(@parameters, @header);
1598 59 for (@_) {
1599 # Find all the SOAP Headers
1600 131 ▶ if (defined($_) && ref($_) && UNIVERSAL::isa($_ => 'SOAP::Header')) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $_ and ref $_ and UNIVERSAL::isa($_, 'SOAP::Header')) { } 0 131 131
elsif (defined $_ and ref $_ and $self->context and $self->context->packager->is_supported_part($_)) { } 0 131 131
Condition83%5/6
defined $_ and ref $_ and UNIVERSAL::isa($_, "SOAP::Header")
!ll&&!rl&&r
12380
defined $_ and ref $_
!ll&&!rl&&r
30938
MC/DC0%0/3
defined $_ and ref $_ and UNIVERSAL::isa($_, "SOAP::Header")
defined $_ ref $_ UNIVERSAL::isa($_, "SOAP::Header")
Truth table75%3/4
A and B and C
A= defined $_B= ref $_C= UNIVERSAL::isa($_, "SOAP::Header")
ABCresult
0XX0
10X0
1100
1111
1601 0 push(@header, $_);
1602 }
1603 # Find all the SOAP Message Parts (attachments)
1604 ▶ elsif (defined($_) && ref($_) && $self->context
Condition88%8/9
defined $_ and ref $_ and $self->context and $self->context->packager->is_supported_part($_)
!ll&&!rl&&r
12830
defined $_ and ref $_ and $self->context
!ll&&!rl&&r
12353
defined $_ and ref $_
!ll&&!rl&&r
30938
MC/DC0%0/4
defined $_ and ref $_ and $self->context and $self->context->packager->is_supported_part($_)
defined $_ ref $_ $self->context $self->context->packager->is_supported_part($_)
Truth table80%4/5
A and B and C and D
A= defined $_B= ref $_C= $self->contextD= $self->context->packager->is_supported_part($_)
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1605 && $self->context->packager->is_supported_part($_)
1606 ) {
1607 0 $self->context->packager->push_part($_);
1608 }
1609 # Find all the SOAP Body elements
1610 else {
1611 # proposed resolution for [ 1700326 ] encode_data called incorrectly in envelope
1612 131 push(@parameters, $_);
1613 # push (@parameters, SOAP::Utils::encode_data($_));
1614 }
1615 }
1616 59 ▶ my $header = @header ? SOAP::Data->set_value(@header) : undef;
Branch: 1 branch
BranchTrueFalseTotal
@header ? : 0 59 59
1617 59 my($body,$parameters);
1618 59 ▶ if ($type eq 'method' || $type eq 'response') {
Branch: 4 branches
BranchTrueFalseTotal
if ($type eq 'method' or $type eq 'response') { } 42 17 59
elsif ($type eq 'fault') { } 15 2 17
elsif ($type eq 'freeform') { } 2 0 2
elsif (not defined $type) { } 0 0 0
Condition100%3/3
$type eq "method" or $type eq "response"
l!l&&r!l&&!r
222017
MC/DC100%2/2
$type eq "method" or $type eq "response"
$type eq "method" $type eq "response"
Truth table100%3/3
A or B
A= $type eq "method"B= $type eq "response"
ABresult
1X1
011
000
1619 42 SOAP::Trace::method(@parameters);
1620  
1621 42 my $method = shift(@parameters);
1622 # or die "Unspecified method for SOAP call\n";
1623  
1624 42 ▶ $parameters = @parameters ? SOAP::Data->set_value(@parameters) : undef;
Branch: 1 branch
BranchTrueFalseTotal
@parameters ? : 29 13 42
1625 42 ▶ if (!defined($method)) {}
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $method) { } 0 42 42
elsif (UNIVERSAL::isa($method, 'SOAP::Data')) { } 0 42 42
elsif ($self->use_default_ns) { } 39 3 42
1626 elsif (UNIVERSAL::isa($method => 'SOAP::Data')) {
1627 0 $body = $method;
1628 }
1629 elsif ($self->use_default_ns) {
1630 39 ▶ if ($self->{'_ns_uri'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_ns_uri'}) { } 29 10 39
1631 $body = SOAP::Data->name($method)
1632 29 ->attr({'xmlns' => $self->{'_ns_uri'} } );
1633 }
1634 else {
1635 10 $body = SOAP::Data->name($method);
1636 }
1637 }
1638 else {
1639 # Commented out by Byrne on 1/4/2006 - to address default namespace problems
1640 # $body = SOAP::Data->name($method)->uri($self->{'_ns_uri'});
1641 # $body = $body->prefix($self->{'_ns_prefix'}) if ($self->{'_ns_prefix'});
1642  
1643 # Added by Byrne on 1/4/2006 - to avoid the unnecessary creation of a new
1644 # namespace
1645 # Begin New Code (replaces code commented out above)
1646 3 $body = SOAP::Data->name($method);
1647 3 my $pre = $self->find_prefix($self->{'_ns_uri'});
1648 3 ▶ $body = $body->prefix($pre) if ($self->{'_ns_prefix'});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_ns_prefix"} 3 0 3
1649 # End new code
1650 }
1651  
1652 # This is breaking a unit test right now...
1653 # proposed resolution for [ 1700326 ] encode_data called incorrectly in envelope
1654 # $body->set_value(SOAP::Utils::encode_data($parameters ? \$parameters : ()))
1655 # if $body;
1656 # must call encode_data on nothing to enforce xsi:nil="true" to be set.
1657 42 ▶ $body->set_value($parameters ? \$parameters : SOAP::Utils::encode_data()) if $body;
Branch: 2 branches
BranchTrueFalseTotal
if $body 42 0 42
$parameters ? : 29 13 42
1658 }
1659 elsif ($type eq 'fault') {
1660 15 SOAP::Trace::fault(@parameters);
1661 # -> attr({'xmlns' => ''})
1662 # Parameter order fixed thanks to Tom Fischer
1663 $body = SOAP::Data-> name(SOAP::Utils::qualify($self->envprefix => 'Fault'))
1664 -> value(\SOAP::Data->set_value(
1665 SOAP::Data->name(faultcode => SOAP::Utils::qualify($self->envprefix => $parameters[0]))->type(""),
1666 SOAP::Data->name(faultstring => SOAP::Utils::encode_data($parameters[1]))->type(""),
1667 defined($parameters[3])
1668 ? SOAP::Data->name(faultactor => $parameters[3])->type("")
1669 : (),
1670 defined($parameters[2])
1671 15 ▶ ? SOAP::Data->name(detail => do{
Branch: 2 branches
BranchTrueFalseTotal
defined $parameters[3] ? : 1 14 15
defined $parameters[2] ? : 1 14 15
1672 1 my $detail = $parameters[2];
1673 1 ▶ ref $detail
Branch: 1 branch
BranchTrueFalseTotal
ref $detail ? : 0 1 1
1674 ? \$detail
1675 : SOAP::Utils::encode_data($detail)
1676 })
1677 : (),
1678 ));
1679 }
1680 elsif ($type eq 'freeform') {
1681 2 SOAP::Trace::freeform(@parameters);
1682 2 $body = SOAP::Data->set_value(@parameters);
1683 }
1684 elsif (!defined($type)) {
1685 # This occurs when the Body is intended to be null. When no method has been
1686 # passed in of any kind.
1687 }
1688 else {
1689 0 die "Wrong type of envelope ($type) for SOAP call\n";
1690 }
1691  
1692 59 $self->{ _seen } = {}; # reinitialize multiref table
1693  
1694 # Build the envelope
1695 # Right now it is possible for $body to be a SOAP::Data element that has not
1696 # XML escaped any values. How do you remedy this?
1697 59 ▶ my($encoded) = $self->encode_object(
Branch: 2 branches
BranchTrueFalseTotal
$header ? : 0 59 59
$body ? : 59 0 59
1698 SOAP::Data->name(
1699 SOAP::Utils::qualify($self->envprefix => 'Envelope') => \SOAP::Data->value(
1700 ($header
1701 ? SOAP::Data->name( SOAP::Utils::qualify($self->envprefix => 'Header') => \$header)->attr( $self->headerattr)
1702 : ()
1703 ),
1704 ($body
1705 ? SOAP::Data->name(SOAP::Utils::qualify($self->envprefix => 'Body') => \$body)
1706 : SOAP::Data->name(SOAP::Utils::qualify($self->envprefix => 'Body'))
1707 )->attr( $self->bodyattr),
1708 )
1709 )->attr($self->attr)
1710 );
1711  
1712 59 ▶ $self->signature($parameters->signature) if ref $parameters;
Branch: 1 branch
BranchTrueFalseTotal
if ref $parameters 29 30 59
1713  
1714 # IMHO multirefs should be encoded after Body, but only some
1715 # toolkits understand this encoding, so we'll keep them for now (04/15/2001)
1716 # as the last element inside the Body
1717 # v -------------- subelements of Envelope
1718 # vv -------- last of them (Body)
1719 # v --- subelements
1720 59 ▶ push(@{$encoded->[2]->[-1]->[2]}, $self->encode_multirefs) if ref $encoded->[2]->[-1]->[2];
Branch: 1 branch
BranchTrueFalseTotal
if ref $encoded->[2][-1][2] 59 0 59
1721  
1722 # Sometimes SOAP::Serializer is invoked statically when there is no context.
1723 # So first check to see if a context exists.
1724 # TODO - a context needs to be initialized by a constructor?
1725 59 ▶ if ($self->context && $self->context->packager->parts) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->context and $self->context->packager->parts) 46 13 59
Condition66%2/3
$self->context and $self->context->packager->parts
!ll&&!rl&&r
13046
MC/DC50%1/2
$self->context and $self->context->packager->parts
$self->context $self->context->packager->parts
Truth table66%2/3
A and B
A= $self->contextB= $self->context->packager->parts
ABresult
0X0
100
111
1726 # TODO - this needs to be called! Calling it though wraps the payload twice!
1727 # return $self->context->packager->package($self->xmlize($encoded));
1728 }
1729  
1730 59 return $self->xmlize($encoded);
1731 }
1732  
1733 # ======================================================================
1734  
1735 package SOAP::Parser;
1736  
1737 127 ▶sub DESTROY { SOAP::Trace::objects('()') }
Subroutine DESTROY: called CC=1 SCAR=0.0
1738  
1739 118 ▶sub xmlparser {
Subroutine xmlparser: called CC=5 SCAR=20.3
1740 118 my $self = shift;
1741 return eval {
1742 $SOAP::Constants::DO_NOT_USE_XML_PARSER
1743 ? undef
1744 118 ▶ : do {
Branch: 1 branch
BranchTrueFalseTotal
$SOAP::Constants::DO_NOT_USE_XML_PARSER ? : 0 118 118
1745 118 require XML::Parser;
1746 0 ▶ XML::Parser->new( NoExpand => 1, Handlers => { Default => sub {} } ) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
1747 }
1748 118 ▶ || eval { require XML::Parser::Lite; XML::Parser::Lite->new }
Condition40%2/5
eval { do { $SOAP::Constants::DO_NOT_USE_XML_PARSER ? undef : do { require XML::Parser; 'XML::Parser'->new('NoExpand', 1, 'Handlers', {'Default', sub { } }) } } } || eval { do { require XML::Parser::Lite; 'XML::Parser::Lite'->new } } || die("XML::Parser is not @{[$SOAP::Constants::DO_NOT_USE_XML_PARSER ? 'used' : 'available'];} and ", $@)
l!l
1180
eval { do { $SOAP::Constants::DO_NOT_USE_XML_PARSER ? undef : do { require XML::Parser; "XML::Parser"->new("NoExpand", 1, "Handlers", {"Default", sub { } }) } } } or eval { do { require XML::Parser::Lite; "XML::Parser::Lite"->new } }
l!l&&r!l&&!r
01180
MC/DC0%0/2
eval { do { $SOAP::Constants::DO_NOT_USE_XML_PARSER ? undef : do { require XML::Parser; 'XML::Parser'->new('NoExpand', 1, 'Handlers', {'Default', sub { } }) } } } || eval { do { require XML::Parser::Lite; 'XML::Parser::Lite'->new } } || die("XML::Parser is not @{[$SOAP::Constants::DO_NOT_USE_XML_PARSER ? 'used' : 'available'];} and ", $@)
eval { do { $SOAP::Constants::DO_NOT_USE_XML_PARSER ? undef : do { require XML::Parser; "XML::Parser"->new("NoExpand", 1, "Handlers", {"Default", sub { } }) } } } eval { do { require XML::Parser::Lite; "XML::Parser::Lite"->new } }
Truth table33%1/3
A or B
A= eval { do { $SOAP::Constants::DO_NOT_USE_XML_PARSER ? undef : do { require XML::Parser; "XML::Parser"->new("NoExpand", 1, "Handlers", {"Default", sub { } }) } } }B= eval { do { require XML::Parser::Lite; "XML::Parser::Lite"->new } }
ABresult
1X1
011
000
1749 0 ▶ || die "XML::Parser is not @{[$SOAP::Constants::DO_NOT_USE_XML_PARSER ? 'used' : 'available']} and ", $@;
Branch: 1 branch
BranchTrueFalseTotal
$SOAP::Constants::DO_NOT_USE_XML_PARSER ? : 0 0 0
1750 }
1751  
1752 408 ▶sub parser {
Subroutine parser: called CC=3 SCAR=12.7
1753 408 my $self = shift->new;
1754  
1755 # set the parser if passed
1756 408 ▶ if (my $parser = shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $parser = shift()) 0 408 408
1757 0 $self->{'_parser'} = shift;
1758 0 return $self;
1759 }
1760  
1761 # else return the parser or use XML::Parser::Lite
1762 408 ▶ return ($self->{'_parser'} ||= $self->xmlparser);
Condition66%2/3
$self->{"_parser"} ||= $self->xmlparser
l!l&&r!l&&!r
2901180
MC/DC0%0/2
$self->{"_parser"} ||= $self->xmlparser
$self->{"_parser"} $self->xmlparser
Truth table66%2/3
A ||= B
A= $self->{"_parser"}B= $self->xmlparser
ABresult
1X1
011
000
1763 }
1764  
1765 541 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
1766 541 my $self = shift;
1767 541 ▶ return $self if ref $self;
Branch: 1 branch
BranchTrueFalseTotal
if ref $self 408 133 541
1768 133 my $class = $self;
1769 133 SOAP::Trace::objects('()');
1770 133 return bless {_parser => shift}, $class;
1771 }
1772  
1773 135 ▶sub decode { SOAP::Trace::trace('()');
Subroutine decode: called CC=2 SCAR=6.9
1774 135 my $self = shift;
1775  
1776 $self->parser->setHandlers(
1777 122 ▶ Final => sub { shift; $self->final(@_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
1778 600 ▶ Start => sub { shift; $self->start(@_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
1779 591 ▶ End => sub { shift; $self->end(@_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
1780 778 ▶ Char => sub { shift; $self->char(@_) },
Subroutine __ANON__: called CC=1 SCAR=0.0
1781 0 ▶ ExternEnt => sub { shift; die "External entity (pointing to '$_[1]') is not allowed" },
Subroutine __ANON__: not called CC=1 SCAR=6.9
1782 135 );
1783 # my $parsed = $self->parser->parse($_[0]);
1784 # return $parsed;
1785 #
1786 135 my $ret = undef;
1787 135 eval {
1788 135 $ret = $self->parser->parse($_[0]);
1789 };
1790 135 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 13 122 135
1791 13 $self->final; # Clean up in the event of an error
1792 13 die $@; # Pass back the error
1793 }
1794 122 return $ret;
1795 }
1796  
1797 135 ▶sub final {
Subroutine final: called CC=1 SCAR=0.0
1798 135 my $self = shift;
1799  
1800 # clean handlers, otherwise SOAP::Parser won't be deleted:
1801 # it refers to XML::Parser which refers to subs from SOAP::Parser
1802 # Thanks to Ryan Adams <iceman@mit.edu>
1803 # and Craig Johnston <craig.johnston@pressplay.com>
1804 # checked by number of tests in t/02-payload.t
1805  
1806 135 undef $self->{_values};
1807 135 $self->parser->setHandlers(
1808 Final => undef,
1809 Start => undef,
1810 End => undef,
1811 Char => undef,
1812 ExternEnt => undef,
1813 );
1814 135 $self->{_done};
1815 }
1816  
1817 600 ▶sub start { push @{shift->{_values}}, [shift, {@_}] }
Subroutine start: called CC=1 SCAR=0.0
1818  
1819 # string concatenation changed to arrays which should improve performance
1820 # for strings with many entity-encoded elements.
1821 # Thanks to Mathieu Longtin <mrdamnfrenchy@yahoo.com>
1822 778 ▶sub char { push @{shift->{_values}->[-1]->[3]}, shift }
Subroutine char: called CC=1 SCAR=0.0
1823  
1824 591 ▶sub end {
Subroutine end: called CC=4 SCAR=13.9
1825 591 my $self = shift;
1826 591 my $done = pop @{$self->{_values}};
1827 $done->[2] = defined $done->[3]
1828 591 ▶ ? join('',@{$done->[3]})
Branch: 2 branches
BranchTrueFalseTotal
unless ref $done->[2] 300 291 591
defined $done->[3] ? : 227 73 300
1829 : '' unless ref $done->[2];
1830 591 undef $done->[3];
1831 591 @{$self->{_values}}
1832 469 ? (push @{$self->{_values}->[-1]->[2]}, $done)
1833 591 ▶ : ($self->{_done} = $done);
Branch: 1 branch
BranchTrueFalseTotal
@{$self->{'_values'};} ? : 469 122 591
1834 }
1835  
1836 # ======================================================================
1837  
1838 package SOAP::SOM;
1839  
1840 44 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
1841 44 ▶use SOAP::Lite::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
1842  
1843 44 ▶sub BEGIN {
Subroutine BEGIN: called CC=4 SCAR=13.9
1844 44 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
1845 44 my %path = (
1846 root => '/',
1847 envelope => '/Envelope',
1848 body => '/Envelope/Body',
1849 header => '/Envelope/Header',
1850 headers => '/Envelope/Header/[>0]',
1851 fault => '/Envelope/Body/Fault',
1852 faultcode => '/Envelope/Body/Fault/faultcode',
1853 faultstring => '/Envelope/Body/Fault/faultstring',
1854 faultactor => '/Envelope/Body/Fault/faultactor',
1855 faultdetail => '/Envelope/Body/Fault/detail',
1856 );
1857 44 for my $method (keys %path) {
1858 144 ▶ *$method = sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
1859 144 my $self = shift;
1860 144 ▶ ref $self or return $path{$method};
Branch: 1 branch
BranchTrueFalseTotal
ref $self or return $path{$method} 89 55 144
1861 89 ▶ Carp::croak "Method '$method' is readonly and doesn't accept any parameters" if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 89 89
1862 89 return $self->valueof($path{$method});
1863 440 };
1864 }
1865 44 my %results = (
1866 method => '/Envelope/Body/[1]',
1867 result => '/Envelope/Body/[1]/[1]',
1868 freeform => '/Envelope/Body/[>0]',
1869 paramsin => '/Envelope/Body/[1]/[>0]',
1870 paramsall => '/Envelope/Body/[1]/[>0]',
1871 paramsout => '/Envelope/Body/[1]/[>1]'
1872 );
1873 44 for my $method (keys %results) {
1874 98 ▶ *$method = sub {
Subroutine __ANON__: called CC=4 SCAR=14.2
1875 98 my $self = shift;
1876 98 ▶ ref $self or return $results{$method};
Branch: 1 branch
BranchTrueFalseTotal
ref $self or return $results{$method} 46 52 98
1877 46 ▶ Carp::croak "Method '$method' is readonly and doesn't accept any parameters" if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 46 46
1878 46 ▶ defined $self->fault ? return : return $self->valueof($results{$method});
Branch: 1 branch
BranchTrueFalseTotal
defined $self->fault ? : 0 46 46
1879 264 };
1880 }
1881  
1882 44 for my $method (qw(o_child o_value o_lname o_lattr o_qname)) { # import from SOAP::Utils
1883 220 *$method = \&{'SOAP::Utils::'.$method};
1884 }
1885  
1886 44 __PACKAGE__->__mk_accessors('context');
1887  
1888 }
1889  
1890 # use object in boolean context return true/false on last match
1891 # Ex.: $som->match('//Fault') ? 'SOAP call failed' : 'success';
1892 44 ▶use overload fallback => 1, 'bool' => sub { @{shift->{_current}} > 0 };
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
1893  
1894 94 ▶sub DESTROY { SOAP::Trace::objects('()') }
Subroutine DESTROY: called CC=1 SCAR=0.0
1895  
1896 94 ▶sub new {
Subroutine new: called CC=2 SCAR=7.2
1897 94 my $self = shift;
1898 94 ▶ my $class = ref($self) || $self;
Condition33%1/3
ref $self || $self
l!l&&r!l&&!r
0940
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table33%1/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
1899 94 my $content = shift;
1900 94 SOAP::Trace::objects('()');
1901 94 return bless { _content => $content, _current => [$content] } => $class;
1902 }
1903  
1904 0 ▶sub parts {
Subroutine parts: not called CC=2 SCAR=17.9
1905 0 my $self = shift;
1906 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
1907 0 $self->context->packager->parts(@_);
1908 0 return $self;
1909 }
1910 else {
1911 0 return $self->context->packager->parts;
1912 }
1913 }
1914  
1915 0 ▶sub is_multipart {
Subroutine is_multipart: not called CC=1 SCAR=6.9
1916 0 my $self = shift;
1917 0 return defined($self->parts);
1918 }
1919  
1920 0 ▶sub current {
Subroutine current: not called CC=3 SCAR=24.8
1921 0 my $self = shift;
1922 0 ▶ $self->{_current} = [@_], return $self if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
1923 0 ▶ return wantarray ? @{$self->{_current}} : $self->{_current}->[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1924 }
1925  
1926 169 ▶sub valueof {
Subroutine valueof: called CC=4 SCAR=13.9
1927 169 my $self = shift;
1928 169 local $self->{_current} = $self->{_current};
1929 169 ▶ $self->match(shift) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 169 0 169
1930 return wantarray
1931 31 ▶ ? map {o_value($_)} @{$self->{_current}}
Branch: 1 branch
BranchTrueFalseTotal
@{$self->{'_current'};} ? : 89 60 149
1932 169 ▶ : @{$self->{_current}} ? o_value($self->{_current}->[0]) : undef;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 20 149 169
1933 }
1934  
1935 0 ▶sub headerof { # SOAP::Header is the same as SOAP::Data, so just rebless it
Subroutine headerof: not called CC=3 SCAR=24.8
1936 wantarray
1937 0 ? map { bless $_ => 'SOAP::Header' } shift->dataof(@_)
1938 0 ▶ : do { # header returned by ->dataof can be undef in scalar context
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
1939 0 my $header = shift->dataof(@_);
1940 0 ▶ ref $header ? bless($header => 'SOAP::Header') : undef;
Branch: 1 branch
BranchTrueFalseTotal
ref $header ? : 0 0 0
1941 };
1942 }
1943  
1944 53 ▶sub dataof {
Subroutine dataof: called CC=4 SCAR=14.0
1945 53 my $self = shift;
1946 53 local $self->{_current} = $self->{_current};
1947 53 ▶ $self->match(shift) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 28 25 53
1948 return wantarray
1949 0 ▶ ? map {$self->_as_data($_)} @{$self->{_current}}
Branch: 1 branch
BranchTrueFalseTotal
@{$self->{'_current'};} ? : 26 0 26
1950 26 : @{$self->{_current}}
1951 53 ▶ ? $self->_as_data($self->{_current}->[0])
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 27 26 53
1952 : undef;
1953 }
1954  
1955 25 ▶sub namespaceuriof {
Subroutine namespaceuriof: called CC=4 SCAR=15.9
1956 25 my $self = shift;
1957 25 local $self->{_current} = $self->{_current};
1958 25 ▶ $self->match(shift) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 25 25
1959 return wantarray
1960 0 ▶ ? map {(SOAP::Utils::splitlongname(o_lname($_)))[0]} @{$self->{_current}}
Branch: 1 branch
BranchTrueFalseTotal
@{$self->{'_current'};} ? : 25 0 25
1961 25 ▶ : @{$self->{_current}} ? (SOAP::Utils::splitlongname(o_lname($self->{_current}->[0])))[0] : undef;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 25 25
1962 }
1963  
1964 #sub _as_data {
1965 # my $self = shift;
1966 # my $pointer = shift;
1967 #
1968 # SOAP::Data
1969 # -> new(prefix => '', name => o_qname($pointer), name => o_lname($pointer), attr => o_lattr($pointer))
1970 # -> set_value(o_value($pointer));
1971 #}
1972  
1973 69 ▶sub _as_data {
Subroutine _as_data: called CC=3 SCAR=11.0
1974 69 my $self = shift;
1975 69 my $node = shift;
1976  
1977 69 my $data = SOAP::Data->new( prefix => '',
1978 # name => o_qname has side effect: sets namespace !
1979 name => o_qname($node),
1980 name => o_lname($node),
1981 attr => o_lattr($node) );
1982  
1983 69 ▶ if ( defined o_child($node) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined o_child($node)) { } 23 46 69
1984 23 my @children;
1985 23 foreach my $child ( @{ o_child($node) } ) {
1986 43 push( @children, $self->_as_data($child) );
1987 }
1988 23 $data->set_value( \SOAP::Data->value(@children) );
1989 }
1990 else {
1991 46 $data->set_value( o_value($node) );
1992 }
1993  
1994 69 return $data;
1995 }
1996  
1997  
1998 277 ▶sub match {
Subroutine match: called CC=3 SCAR=14.2
1999 277 my $self = shift;
2000 277 my $path = shift;
2001 $self->{_current} = [
2002 0 $path =~ s!^/!! || !@{$self->{_current}}
2003 ? $self->_traverse($self->{_content}, 1 => split '/' => $path)
2004 0 ▶ : map {$self->_traverse_tree(o_child($_), split '/' => $path)} @{$self->{_current}}
Branch: 1 branch
BranchTrueFalseTotal
$path =~ s[^/][] || !@{$self->{'_current'};} ? : 277 0 277
Condition33%1/3
$path =~ s[^/][] or not @{$self->{"_current"};}
l!l&&r!l&&!r
27700
MC/DC0%0/2
$path =~ s[^/][] or not @{$self->{"_current"};}
$path =~ s[^/][] not @{$self->{"_current"};}
Truth table33%1/3
A or not(B)
A= $path =~ s[^/][]B= not @{$self->{"_current"};}
ABresult
1X1
011
000
2005 ];
2006 277 return $self;
2007 }
2008  
2009 996 ▶sub _traverse {
Subroutine _traverse: called CC=26 SCAR=34.7
2010 996 my ($self, $pointer, $itself, $path, @path) = @_;
2011  
2012 996 ▶ die "Incorrect parameter" unless $itself =~/^\d+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $itself =~ /^\d+$/ 0 996 996
2013  
2014 996 ▶ if ($path && substr($path, 0, 1) eq '{') {
Branch: 1 branch
BranchTrueFalseTotal
if ($path and substr($path, 0, 1) eq "{") 0 996 996
Condition66%2/3
$path and substr($path, 0, 1) eq "{"
!ll&&!rl&&r
2007960
MC/DC0%0/2
$path and substr($path, 0, 1) eq "{"
$path substr($path, 0, 1) eq "{"
Truth table66%2/3
A and B
A= $pathB= substr($path, 0, 1) eq "{"
ABresult
0X0
100
111
2015 0 ▶ $path = join '/', $path, shift @path while @path && $path !~ /}/;
Branch: 1 branch
BranchTrueFalseTotal
@path and not $path =~ /}/ and do { $path = join("/", $path, shift @path) } 0 0 0
Condition0%0/3
@path and not $path =~ /}/
!ll&&!rl&&r
000
MC/DC0%0/2
@path and not $path =~ /}/
@path not $path =~ /}/
Truth table0%0/3
A and not(B)
A= @pathB= not $path =~ /}/
ABresult
0X0
100
111
2016 }
2017  
2018 996 ▶ my($op, $num) = $path =~ /^\[(<=|<|>=|>|=|!=?)?(\d+)\]$/ if defined $path;
Branch: 1 branch
BranchTrueFalseTotal
if defined $path 970 26 996
2019  
2020 996 ▶ return $pointer unless defined $path;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $path 26 970 996
2021  
2022 970 ▶ if (! $op) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $op) { } 935 35 970
elsif ($op eq '=' or $op eq '!') { } 0 35 35
2023 935 $op = '==';
2024 }
2025 ▶ elsif ($op eq '=' || $op eq '!') {
Condition33%1/3
$op eq "=" or $op eq "!"
l!l&&r!l&&!r
0035
MC/DC0%0/2
$op eq "=" or $op eq "!"
$op eq "=" $op eq "!"
Truth table33%1/3
A or B
A= $op eq "="B= $op eq "!"
ABresult
1X1
011
000
2026 0 $op .= '=';
2027 }
2028 970 ▶ my $numok = defined $num && eval "$itself $op $num";
Condition100%3/3
defined $num && eval "$itself $op $num"
!ll&&!rl&&r
8174149
MC/DC100%2/2
defined $num && eval "$itself $op $num"
defined $num eval "$itself $op $num"
Truth table100%3/3
A && B
A= defined $numB= eval "$itself $op $num"
ABresult
0X0
100
111
2029 970 ▶ my $nameok = (o_lname($pointer) || '') =~ /(?:^|\})$path$/ if defined $path; # name can be with namespace
Branch: 1 branch
BranchTrueFalseTotal
if defined $path 970 0 970
Condition50%1/2
o_lname($pointer) || ''
l!l
9700
MC/DC0%0/1
o_lname($pointer) || ''
o_lname($pointer)
Truth table50%1/2
A
A= o_lname($pointer)
Aresult
11
00
2030  
2031 970 my $anynode = $path eq '';
2032 970 ▶ unless ($anynode) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($anynode) 796 174 970
2033 796 ▶ if (@path) {
Branch: 1 branch
BranchTrueFalseTotal
if (@path) { } 422 374 796
2034 422 ▶ return if defined $num && !$numok || !defined $num && !$nameok;
Branch: 1 branch
BranchTrueFalseTotal
if defined $num and not $numok or not defined $num || $nameok 30 392 422
Condition77%7/9
defined $num and not $numok or not defined $num || $nameok
l!l&&r!l&&!r
030392
defined $num and not $numok
!ll&&!rl&&r
376460
defined $num || $nameok
l!l&&r!l&&!r
4634630
MC/DC75%3/4
defined $num and not $numok or not defined $num || $nameok
defined $num not $numok defined $num $nameok
Truth table42%3/7
A and not(B) or not(C || D)
A= defined $numB= not $numokC= defined $numD= $nameok
ABCDresult
11XX1
0X001
10001
0X1X0
0X010
101X0
10010
2035 }
2036 else {
2037 374 ▶ return $pointer if defined $num && $numok || !defined $num && $nameok;
Branch: 1 branch
BranchTrueFalseTotal
if defined $num and $numok or not defined $num and $nameok 172 202 374
Condition100%9/9
defined $num and $numok or not defined $num and $nameok
l!l&&r!l&&!r
10369202
defined $num and $numok
!ll&&!rl&&r
2674103
not defined $num and $nameok
!ll&&!rl&&r
419869
MC/DC75%3/4
defined $num and $numok or not defined $num and $nameok
defined $num $numok not defined $num $nameok
Truth table57%4/7
A and B or not(C) and D
A= defined $numB= $numokC= not defined $numD= $nameok
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
2038 202 return;
2039 }
2040 }
2041  
2042 566 my @walk;
2043 566 ▶ push @walk, $self->_traverse_tree([$pointer], @path) if $anynode;
Branch: 1 branch
BranchTrueFalseTotal
if $anynode 174 392 566
2044 566 ▶ push @walk, $self->_traverse_tree(o_child($pointer), $anynode ? ($path, @path) : @path);
Branch: 1 branch
BranchTrueFalseTotal
$anynode ? : 174 392 566
2045 566 return @walk;
2046 }
2047  
2048 740 ▶sub _traverse_tree {
Subroutine _traverse_tree: called CC=4 SCAR=14.0
2049 740 my ($self, $pointer, @path) = @_;
2050  
2051 # can be list of children or value itself. Traverse only children
2052 740 ▶ return unless ref $pointer eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $pointer eq "ARRAY" 76 664 740
2053  
2054 664 my $itself = 1;
2055  
2056 394 grep {defined}
2057 719 map {$self->_traverse($_, $itself++, @path)}
2058 664 grep {!ref o_lattr($_) ||
2059 !exists o_lattr($_)->{"{$SOAP::Constants::NS_ENC}root"} ||
2060 737 ▶ o_lattr($_)->{"{$SOAP::Constants::NS_ENC}root"} ne '0'}
Condition66%4/6
!(ref o_lattr($_) && exists o_lattr($_)->{"{$SOAP::Constants::NS_ENC}root"}) || o_lattr($_)->{"{$SOAP::Constants::NS_ENC}root"} ne '0'
l!l&&r!l&&!r
719018
ref o_lattr($_) && exists o_lattr($_)->{"{$SOAP::Constants::NS_ENC}root"}
!ll&&!rl&&r
071918
MC/DC33%1/3
!(ref o_lattr($_) && exists o_lattr($_)->{"{$SOAP::Constants::NS_ENC}root"}) || o_lattr($_)->{"{$SOAP::Constants::NS_ENC}root"} ne '0'
ref o_lattr($_) exists o_lattr($_)->{"{$SOAP::Constants::NS_ENC}root"} o_lattr($_)->{"{$SOAP::Constants::NS_ENC}root"} ne '0'
Truth table50%2/4
not(A && B) || C
A= ref o_lattr($_)B= exists o_lattr($_)->{"{$SOAP::Constants::NS_ENC}root"}C= o_lattr($_)->{"{$SOAP::Constants::NS_ENC}root"} ne '0'
ABCresult
0XX1
10X1
1111
1100
2061 @$pointer;
2062 }
2063  
2064 # ======================================================================
2065  
2066 package SOAP::Deserializer;
2067  
2068 44 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
2069 44 ▶use SOAP::Lite::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
2070 44 ▶use Class::Inspector;
Subroutine BEGIN: called CC=1 SCAR=0.0
2071 44 ▶use URI::Escape qw{uri_unescape};
Subroutine BEGIN: called CC=1 SCAR=0.0
2072  
2073 44 @ISA = qw(SOAP::Cloneable);
2074  
2075 133 ▶sub DESTROY { SOAP::Trace::objects('()') }
Subroutine DESTROY: called CC=1 SCAR=0.0
2076  
2077 44 ▶sub BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
2078 44 __PACKAGE__->__mk_accessors( qw(ids hrefs parts parser
2079 base xmlschemas xmlschema context) );
2080 }
2081  
2082 # Cache (slow) Class::Inspector results
2083 44 my %_class_loaded=();
2084  
2085 326 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
2086 326 my $self = shift;
2087 326 ▶ return $self if ref $self;
Branch: 1 branch
BranchTrueFalseTotal
if ref $self 193 133 326
2088 133 my $class = $self;
2089 133 SOAP::Trace::objects('()');
2090 return bless {
2091 '_ids' => {},
2092 '_hrefs' => {},
2093 '_parser' => SOAP::Parser->new,
2094 '_xmlschemas' => {
2095 $SOAP::Constants::NS_APS => 'SOAP::XMLSchemaApacheSOAP::Deserializer',
2096 # map {
2097 # $_ => $SOAP::Constants::XML_SCHEMAS{$_} . '::Deserializer'
2098 # } keys %SOAP::Constants::XML_SCHEMAS
2099 map {
2100 133 $_ => 'SOAP::Lite::Deserializer::' . $SOAP::Constants::XML_SCHEMA_OF{$_}
2101 } keys %SOAP::Constants::XML_SCHEMA_OF
2102  
2103 },
2104 }, $class;
2105 }
2106  
2107 133 ▶sub is_xml {
Subroutine is_xml: called CC=2 SCAR=6.9
2108 # Added check for envelope delivery. Fairly standard with MMDF and sendmail
2109 # Thanks to Chris Davies <Chris.Davies@ManheimEurope.com>
2110 133 ▶ $_[1] =~ /^\s*</ || $_[1] !~ /^(?:[\w-]+:|From )/;
Branch: 1 branch
BranchTrueFalseTotal
$_[1] =~ /^\s*</ or not $_[1] =~ /^(?:[\w-]+:|From )/ 104 29 133
2111 }
2112  
2113 25 ▶sub baselocation {
Subroutine baselocation: called CC=4 SCAR=13.9
2114 25 my $self = shift;
2115 25 my $location = shift;
2116 25 ▶ if ($location) {
Branch: 1 branch
BranchTrueFalseTotal
if ($location) 8 17 25
2117 8 my $uri = URI->new($location);
2118 # make absolute location if relative
2119 8 ▶ $location = $uri->abs($self->base || 'thismessage:/')->as_string unless $uri->scheme;
Branch: 1 branch
BranchTrueFalseTotal
unless $uri->scheme 4 4 8
Condition50%1/2
$self->base || 'thismessage:/'
l!l
04
MC/DC0%0/1
$self->base || 'thismessage:/'
$self->base
Truth table50%1/2
A
A= $self->base
Aresult
11
00
2120 }
2121 25 return $location;
2122 }
2123  
2124 # Returns the envelope and populates SOAP::Packager with parts
2125 17 ▶sub decode_parts {
Subroutine decode_parts: called CC=7 SCAR=19.7
2126 17 my $self = shift;
2127 17 my $env = $self->context->packager->unpackage($_[0],$self->context);
2128 17 my $body = $self->parser->decode($env);
2129 # TODO - This shouldn't be here! This is packager specific!
2130 # However this does need to pull out all the cid's
2131 # to populate ids hash with.
2132 17 foreach (@{$self->context->packager->parts}) {
2133 23 my $data = $_->bodyhandle->as_string;
2134 23 my $type = $_->head->mime_attr('Content-Type');
2135 23 my $location = $_->head->mime_attr('Content-Location');
2136 23 my $id = $_->head->mime_attr('Content-Id');
2137 23 $location = $self->baselocation($location);
2138 23 ▶ my $part = lc($type) eq 'text/xml' && !$SOAP::Constants::DO_NOT_PROCESS_XML_IN_MIME
Branch: 1 branch
BranchTrueFalseTotal
lc $type eq 'text/xml' && !$SOAP::Constants::DO_NOT_PROCESS_XML_IN_MIME ? : 2 21 23
Condition66%2/3
lc $type eq "text/xml" and not $SOAP::Constants::DO_NOT_PROCESS_XML_IN_MIME
!ll&&!rl&&r
2102
MC/DC50%1/2
lc $type eq "text/xml" and not $SOAP::Constants::DO_NOT_PROCESS_XML_IN_MIME
lc $type eq "text/xml" not $SOAP::Constants::DO_NOT_PROCESS_XML_IN_MIME
Truth table66%2/3
A and not(B)
A= lc $type eq "text/xml"B= not $SOAP::Constants::DO_NOT_PROCESS_XML_IN_MIME
ABresult
0X0
100
111
2139 ? $self->parser->decode($data)
2140 : ['mimepart', {}, $data];
2141 # This below looks like unnecessary bloat!!!
2142 # I should probably dereference the mimepart, provide a callback to get the string data
2143 23 ▶ $self->ids->{$1} = $part if ($id && $id =~ m/^<([^>]+)>$/); # strip any leading and trailing brackets
Branch: 1 branch
BranchTrueFalseTotal
if $id and $id =~ /^<([^>]+)>$/ 23 0 23
Condition33%1/3
$id and $id =~ /^<([^>]+)>$/
!ll&&!rl&&r
0023
MC/DC0%0/2
$id and $id =~ /^<([^>]+)>$/
$id $id =~ /^<([^>]+)>$/
Truth table33%1/3
A and B
A= $idB= $id =~ /^<([^>]+)>$/
ABresult
0X0
100
111
2144 23 ▶ $self->ids->{$location} = $part if $location;
Branch: 1 branch
BranchTrueFalseTotal
if $location 6 17 23
2145 }
2146 17 return $body;
2147 }
2148  
2149 # decode returns a parsed body in the form of an ARRAY
2150 # each element of the ARRAY is a HASH, ARRAY or SCALAR
2151 133 ▶sub decode {
Subroutine decode: called CC=2 SCAR=6.9
2152 133 my $self = shift->new; # this actually is important
2153 133 ▶ return $self->is_xml($_[0])
Branch: 1 branch
BranchTrueFalseTotal
$self->is_xml($_[0]) ? : 116 17 133
2154 ? $self->parser->decode($_[0])
2155 : $self->decode_parts($_[0]);
2156 }
2157  
2158 # deserialize returns a SOAP::SOM object and parses straight
2159 # text as input
2160 133 ▶sub deserialize {
Subroutine deserialize: called CC=2 SCAR=6.9
2161 133 SOAP::Trace::trace('()');
2162 133 my $self = shift->new;
2163  
2164 # initialize
2165 133 $self->hrefs({});
2166 133 $self->ids({});
2167  
2168 # If the document is XML, then ids will be empty
2169 # If the document is MIME, then ids will hold a list of cids
2170 133 my $parsed = $self->decode($_[0]);
2171  
2172 # Having this code here makes multirefs in the Body work, but multirefs
2173 # that reference XML fragments in a MIME part do not work.
2174 120 ▶ if (keys %{$self->ids()}) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %{$self->ids;}) { } 13 107 120
2175 13 $self->traverse_ids($parsed);
2176 }
2177 else {
2178 # delay - set ids to be traversed later in decode_object, they only get
2179 # traversed if an href is found that is referencing an id.
2180 107 $self->ids($parsed);
2181 }
2182 120 $self->decode_object($parsed);
2183 94 my $som = SOAP::SOM->new($parsed);
2184 94 $som->context($self->context); # TODO - try removing this and see if it works!
2185 94 return $som;
2186 }
2187  
2188 98 ▶sub traverse_ids {
Subroutine traverse_ids: called CC=4 SCAR=13.9
2189 98 my $self = shift;
2190 98 my $ref = shift;
2191 98 my($undef, $attrs, $children) = @$ref;
2192 # ^^^^^^ to fix nasty error on Mac platform (Carl K. Cunningham)
2193 98 ▶ $self->ids->{$attrs->{'id'}} = $ref if exists $attrs->{'id'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $attrs->{"id"} 21 77 98
2194 98 ▶ return unless ref $children;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $children 43 55 98
2195 55 for (@$children) {
2196 83 $self->traverse_ids($_)
2197 };
2198 }
2199  
2200 44 ▶use constant _ATTRS => 6;
Subroutine BEGIN: called CC=1 SCAR=0.0
2201 44 ▶use constant _NAME => 5;
Subroutine BEGIN: called CC=1 SCAR=0.0
2202  
2203 613 ▶sub decode_object {
Subroutine decode_object: called CC=16 SCAR=28.6
2204 613 my $self = shift;
2205 613 my $ref = shift;
2206 613 my($name, $attrs_ref, $children, $value) = @$ref;
2207  
2208 613 my %attrs = %{ $attrs_ref };
2209  
2210 613 $ref->[ _ATTRS ] = \%attrs; # make a copy for long attributes
2211  
2212 44 ▶ use vars qw(%uris);
Subroutine BEGIN: called CC=1 SCAR=0.0
2213 local %uris = (%uris, map {
2214 390 do { (my $ns = $_) =~ s/^xmlns:?//; $ns } => delete $attrs{$_}
2215 613 } grep {/^xmlns(:|$)/} keys %attrs);
2216  
2217 613 foreach (keys %attrs) {
2218 358 ▶ next unless m/^($SOAP::Constants::NSMASK?):($SOAP::Constants::NSMASK)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless /^($SOAP::Constants::NSMASK?):($SOAP::Constants::NSMASK)$/ 151 207 358
2219  
2220 $1 =~ /^[xX][mM][lL]/ ||
2221 $uris{$1} &&
2222 207 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
$1 =~ /^[xX][mM][lL]/ or $SOAP::Deserializer::uris{$1} and do { $attrs{SOAP::Utils::longname($SOAP::Deserializer::uris{$1}, $2)} = do { my $value = $attrs{$_}; $2 ne "type" && $2 ne "arrayType" ? $value : SOAP::Utils::longname($value =~ /^($SOAP::Constants::NSMASK?):($SOAP::Constants::NSMASK(?:\[[\d,]*\])*)/ ? ($SOAP::Deserializer::uris{$1} || die("Unresolved prefix '$1' for attribute value '${value}'\n"), $2) : ($SOAP::Deserializer::uris{""} || die("Unspecified namespace for type '${value}'\n"), $value)) }; 1 } or die "Unresolved prefix '$1' for attribute '${_}'\n" 207 0 207
Condition33%2/6
$1 =~ /^[xX][mM][lL]/ or $SOAP::Deserializer::uris{$1} and do { $attrs{SOAP::Utils::longname($SOAP::Deserializer::uris{$1}, $2)} = do { my $value = $attrs{$_}; $2 ne "type" && $2 ne "arrayType" ? $value : SOAP::Utils::longname($value =~ /^($SOAP::Constants::NSMASK?):($SOAP::Constants::NSMASK(?:\[[\d,]*\])*)/ ? ($SOAP::Deserializer::uris{$1} || die("Unresolved prefix '$1' for attribute value '${value}'\n"), $2) : ($SOAP::Deserializer::uris{""} || die("Unspecified namespace for type '${value}'\n"), $value)) }; 1 }
l!l&&r!l&&!r
02070
$SOAP::Deserializer::uris{$1} and do { $attrs{SOAP::Utils::longname($SOAP::Deserializer::uris{$1}, $2)} = do { my $value = $attrs{$_}; $2 ne "type" && $2 ne "arrayType" ? $value : SOAP::Utils::longname($value =~ /^($SOAP::Constants::NSMASK?):($SOAP::Constants::NSMASK(?:\[[\d,]*\])*)/ ? ($SOAP::Deserializer::uris{$1} || die("Unresolved prefix '$1' for attribute value '${value}'\n"), $2) : ($SOAP::Deserializer::uris{""} || die("Unspecified namespace for type '${value}'\n"), $value)) }; 1 }
!ll&&!rl&&r
00207
MC/DC0%0/3
$1 =~ /^[xX][mM][lL]/ or $SOAP::Deserializer::uris{$1} and do { $attrs{SOAP::Utils::longname($SOAP::Deserializer::uris{$1}, $2)} = do { my $value = $attrs{$_}; $2 ne "type" && $2 ne "arrayType" ? $value : SOAP::Utils::longname($value =~ /^($SOAP::Constants::NSMASK?):($SOAP::Constants::NSMASK(?:\[[\d,]*\])*)/ ? ($SOAP::Deserializer::uris{$1} || die("Unresolved prefix '$1' for attribute value '${value}'\n"), $2) : ($SOAP::Deserializer::uris{""} || die("Unspecified namespace for type '${value}'\n"), $value)) }; 1 }
$1 =~ /^[xX][mM][lL]/ $SOAP::Deserializer::uris{$1} do { $attrs{SOAP::Utils::longname($SOAP::Deserializer::uris{$1}, $2)} = do { my $value = $attrs{$_}; $2 ne "type" && $2 ne "arrayType" ? $value : SOAP::Utils::longname($value =~ /^($SOAP::Constants::NSMASK?):($SOAP::Constants::NSMASK(?:\[[\d,]*\])*)/ ? ($SOAP::Deserializer::uris{$1} || die("Unresolved prefix '$1' for attribute value '${value}'\n"), $2) : ($SOAP::Deserializer::uris{""} || die("Unspecified namespace for type '${value}'\n"), $value)) }; 1 }
Truth table25%1/4
A or B and C
A= $1 =~ /^[xX][mM][lL]/B= $SOAP::Deserializer::uris{$1}C= do { $attrs{SOAP::Utils::longname($SOAP::Deserializer::uris{$1}, $2)} = do { my $value = $attrs{$_}; $2 ne "type" && $2 ne "arrayType" ? $value : SOAP::Utils::longname($value =~ /^($SOAP::Constants::NSMASK?):($SOAP::Constants::NSMASK(?:\[[\d,]*\])*)/ ? ($SOAP::Deserializer::uris{$1} || die("Unresolved prefix '$1' for attribute value '${value}'\n"), $2) : ($SOAP::Deserializer::uris{""} || die("Unspecified namespace for type '${value}'\n"), $value)) }; 1 }
ABCresult
1XX1
0111
00X0
0100
2223 207 $attrs{SOAP::Utils::longname($uris{$1}, $2)} = do {
2224 207 my $value = $attrs{$_};
2225 $2 ne 'type' && $2 ne 'arrayType'
2226 ? $value
2227 : SOAP::Utils::longname($value =~ m/^($SOAP::Constants::NSMASK?):(${SOAP::Constants::NSMASK}(?:\[[\d,]*\])*)/
2228 ? ($uris{$1} || die("Unresolved prefix '$1' for attribute value '$value'\n"), $2)
2229 207 ▶ : ($uris{''} || die("Unspecified namespace for type '$value'\n"), $value)
Branch: 2 branches
BranchTrueFalseTotal
$2 ne 'type' && $2 ne 'arrayType' ? : 73 134 207
$value =~ /^($SOAP::Constants::NSMASK?):($SOAP::Constants::NSMASK(?:\[[\d,]*\])*)/ ? : 134 0 134
Condition57%4/7
$2 ne "type" and $2 ne "arrayType"
!ll&&!rl&&r
132273
$SOAP::Deserializer::uris{$1} or die "Unresolved prefix '$1' for attribute value '${value}'\n"
l!l
1340
$SOAP::Deserializer::uris{""} or die "Unspecified namespace for type '${value}'\n"
l!l
00
MC/DC100%2/2
$2 ne "type" and $2 ne "arrayType"
$2 ne "type" $2 ne "arrayType"
MC/DC0%0/1
$SOAP::Deserializer::uris{$1} or die "Unresolved prefix '$1' for attribute value '${value}'\n"
$SOAP::Deserializer::uris{$1}
MC/DC0%0/1
$SOAP::Deserializer::uris{""} or die "Unspecified namespace for type '${value}'\n"
$SOAP::Deserializer::uris{""}
Truth table100%3/3
A and B
A= $2 ne "type"B= $2 ne "arrayType"
ABresult
0X0
100
111
Truth table50%1/2
A
A= $SOAP::Deserializer::uris{$1}
Aresult
11
00
Truth table0%0/2
A
A= $SOAP::Deserializer::uris{""}
Aresult
11
00
2230 );
2231 };
2232 207 1;
2233 }
2234 || die "Unresolved prefix '$1' for attribute '$_'\n";
2235 }
2236  
2237 # and now check the element
2238 613 ▶ my $ns = ($name =~ s/^($SOAP::Constants::NSMASK?):// ? $1 : '');
Branch: 1 branch
BranchTrueFalseTotal
$name =~ s/^($SOAP::Constants::NSMASK?):// ? : 211 402 613
2239 $ref->[ _NAME ] = SOAP::Utils::longname(
2240 $ns
2241 ? ($uris{$ns} || die "Unresolved prefix '$ns' for element '$name'\n")
2242 613 ▶ : (defined $uris{''} ? $uris{''} : undef),
Branch: 2 branches
BranchTrueFalseTotal
$ns ? : 211 402 613
defined $SOAP::Deserializer::uris{''} ? : 72 330 402
Condition50%1/2
$SOAP::Deserializer::uris{$ns} or die "Unresolved prefix '${ns}' for element '${name}'\n"
l!l
2110
MC/DC0%0/1
$SOAP::Deserializer::uris{$ns} or die "Unresolved prefix '${ns}' for element '${name}'\n"
$SOAP::Deserializer::uris{$ns}
Truth table50%1/2
A
A= $SOAP::Deserializer::uris{$ns}
Aresult
11
00
2243 $name
2244 );
2245  
2246 613 ▶ ($children, $value) = (undef, $children) unless ref $children;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $children 312 301 613
2247  
2248 613 return $name => ($ref->[4] = $self->decode_value(
2249 [$ref->[ _NAME ], \%attrs, $children, $value]
2250 ));
2251 }
2252  
2253 424 ▶sub decode_value {
Subroutine decode_value: called CC=78 SCAR=48.2
2254 424 my $self = shift;
2255 424 my($name, $attrs, $children, $value) = @{ $_[0] };
2256  
2257 # check SOAP version if applicable
2258 44 ▶ use vars '$level'; local $level = $level || 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
Condition100%2/2
$SOAP::Deserializer::level || 0
l!l
306118
MC/DC100%1/1
$SOAP::Deserializer::level || 0
$SOAP::Deserializer::level
Truth table100%2/2
A
A= $SOAP::Deserializer::level
Aresult
11
00
2259 424 ▶ if (++$level == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$SOAP::Deserializer::level == 1) 118 306 424
2260 118 my($namespace, $envelope) = SOAP::Utils::splitlongname($name);
2261 118 ▶ SOAP::Lite->soapversion($namespace) if $envelope eq 'Envelope' && $namespace;
Branch: 1 branch
BranchTrueFalseTotal
if $envelope eq "Envelope" and $namespace 63 55 118
Condition100%3/3
$envelope eq "Envelope" and $namespace
!ll&&!rl&&r
52363
MC/DC100%2/2
$envelope eq "Envelope" and $namespace
$envelope eq "Envelope" $namespace
Truth table100%3/3
A and B
A= $envelope eq "Envelope"B= $namespace
ABresult
0X0
100
111
2262 }
2263  
2264 424 ▶ if (exists $attrs->{"{$SOAP::Constants::NS_ENV}encodingStyle"}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$attrs{"{$SOAP::Constants::NS_ENV}encodingStyle"}) 52 372 424
2265 # check encodingStyle
2266 # future versions may bind deserializer to encodingStyle
2267 52 my $encodingStyle = $attrs->{"{$SOAP::Constants::NS_ENV}encodingStyle"};
2268 # TODO - SOAP 1.2 and 1.1 have different rules about valid encodingStyle values
2269 # For example, in 1.1 - any http://schemas.xmlsoap.org/soap/encoding/*
2270 # value is valid
2271 52 ▶ if (defined $encodingStyle && length($encodingStyle)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $encodingStyle and length $encodingStyle) 52 0 52
Condition33%1/3
defined $encodingStyle and length $encodingStyle
!ll&&!rl&&r
0052
MC/DC0%0/2
defined $encodingStyle and length $encodingStyle
defined $encodingStyle length $encodingStyle
Truth table33%1/3
A and B
A= defined $encodingStyleB= length $encodingStyle
ABresult
0X0
100
111
2272 52 my %styles = map { $_ => undef } @SOAP::Constants::SUPPORTED_ENCODING_STYLES;
2273 52 my $found = 0;
2274 52 foreach my $e (split(/ +/,$encodingStyle)) {
2275 52 ▶ if (exists $styles{$e}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $styles{$e}) 52 0 52
2276 52 $found ++;
2277 }
2278 }
2279 52 ▶ die "Unrecognized/unsupported value of encodingStyle attribute '$encodingStyle'"
Branch: 1 branch
BranchTrueFalseTotal
unless $found or "SOAP::Lite"->soapversion == "1.1" and $encodingStyle =~ /(?:^|\b)$SOAP::Constants::NS_ENC/ 0 52 52
Condition16%1/6
$found or "SOAP::Lite"->soapversion == "1.1" and $encodingStyle =~ /(?:^|\b)$SOAP::Constants::NS_ENC/
l!l&&r!l&&!r
5200
"SOAP::Lite"->soapversion == "1.1" and $encodingStyle =~ /(?:^|\b)$SOAP::Constants::NS_ENC/
!ll&&!rl&&r
000
MC/DC0%0/3
$found or "SOAP::Lite"->soapversion == "1.1" and $encodingStyle =~ /(?:^|\b)$SOAP::Constants::NS_ENC/
$found "SOAP::Lite"->soapversion == "1.1" $encodingStyle =~ /(?:^|\b)$SOAP::Constants::NS_ENC/
Truth table25%1/4
A or B and C
A= $foundB= "SOAP::Lite"->soapversion == "1.1"C= $encodingStyle =~ /(?:^|\b)$SOAP::Constants::NS_ENC/
ABCresult
1XX1
0111
00X0
0100
2280 if (! $found) && !(SOAP::Lite->soapversion == 1.1 && $encodingStyle =~ /(?:^|\b)$SOAP::Constants::NS_ENC/);
2281 }
2282 }
2283 44 ▶ use vars '$arraytype'; # type of Array element specified on Array itself
Subroutine BEGIN: called CC=1 SCAR=0.0
2284 # either specified with xsi:type, or <enc:name/> or array element
2285 556 my ($type) = grep { defined }
2286 424 ▶ map($attrs->{$_}, sort grep {/^\{$SOAP::Constants::NS_XSI_ALL\}type$/o} keys %$attrs),
Branch: 1 branch
BranchTrueFalseTotal
$name =~ /^\{$SOAP::Constants::NS_ENC\}/ ? : 1 423 424
2287 $name =~ /^\{$SOAP::Constants::NS_ENC\}/ ? $name : $arraytype;
2288 424 local $arraytype; # it's used only for one level, we don't need it anymore
2289  
2290 # $name is not used here since type should be encoded as type, not as name
2291 424 ▶ my ($schema, $class) = SOAP::Utils::splitlongname($type) if $type;
Branch: 1 branch
BranchTrueFalseTotal
if $type 133 291 424
2292 424 ▶ my $schemaclass = defined($schema) && $self->{ _xmlschemas }->{$schema}
Condition83%5/6
defined $schema && $self->{'_xmlschemas'}{$schema} || $self
l!l&&r!l&&!r
1173070
defined $schema and $self->{"_xmlschemas"}{$schema}
!ll&&!rl&&r
29116117
MC/DC0%0/3
defined $schema && $self->{'_xmlschemas'}{$schema} || $self
defined $schema $self->{"_xmlschemas"}{$schema} $self
Truth table60%3/5
A and B || C
A= defined $schemaB= $self->{"_xmlschemas"}{$schema}C= $self
ABCresult
11X1
0X11
1011
0X00
1000
2293 || $self;
2294  
2295 424 ▶ if (! exists $_class_loaded{$schemaclass}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $_class_loaded{$schemaclass}) 70 354 424
2296 44 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
2297 70 ▶ if (! Class::Inspector->loaded($schemaclass) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ("Class::Inspector"->loaded($schemaclass)) 66 4 70
2298 66 ▶ eval "require $schemaclass" or die $@ if not ref $schemaclass;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $schemaclass 9 57 66
Condition60%3/5
ref $schemaclass || (eval "require $schemaclass" || die($@))
l!l
5790
eval "require $schemaclass" or die $@
l!l
90
MC/DC0%0/2
ref $schemaclass || (eval "require $schemaclass" || die($@))
ref $schemaclass eval "require $schemaclass"
Truth table66%2/3
A || B
A= ref $schemaclassB= eval "require $schemaclass"
ABresult
1X1
011
000
2299 }
2300 70 $_class_loaded{$schemaclass} = undef;
2301 }
2302  
2303 # store schema that is used in parsed message
2304 424 ▶ $self->{ _xmlschema } = $schema if ($schema) && $schema =~ /XMLSchema/;
Branch: 1 branch
BranchTrueFalseTotal
if $schema and $schema =~ /XMLSchema/ 109 315 424
Condition100%3/3
$schema and $schema =~ /XMLSchema/
!ll&&!rl&&r
29124109
MC/DC100%2/2
$schema and $schema =~ /XMLSchema/
$schema $schema =~ /XMLSchema/
Truth table100%3/3
A and B
A= $schemaB= $schema =~ /XMLSchema/
ABresult
0X0
100
111
2305  
2306 # don't use class/type if anyType/ur-type is specified on wire
2307 424 ▶ undef $class
Branch: 1 branch
BranchTrueFalseTotal
if $schemaclass->can("anyTypeValue") and $schemaclass->anyTypeValue eq $class 2 422 424
Condition100%3/3
$schemaclass->can("anyTypeValue") and $schemaclass->anyTypeValue eq $class
!ll&&!rl&&r
3131092
MC/DC100%2/2
$schemaclass->can("anyTypeValue") and $schemaclass->anyTypeValue eq $class
$schemaclass->can("anyTypeValue") $schemaclass->anyTypeValue eq $class
Truth table100%3/3
A and B
A= $schemaclass->can("anyTypeValue")B= $schemaclass->anyTypeValue eq $class
ABresult
0X0
100
111
2308 if $schemaclass->can('anyTypeValue')
2309 && $schemaclass->anyTypeValue eq $class;
2310  
2311 424 ▶ my $method = 'as_' . ($class || '-'); # dummy type if not defined
Condition100%2/2
$class || '-'
l!l
131293
MC/DC100%1/1
$class || '-'
$class
Truth table100%2/2
A
A= $class
Aresult
11
00
2312 424 ▶ $class =~ s/__|\./::/g if $class;
Branch: 1 branch
BranchTrueFalseTotal
if $class 131 293 424
2313  
2314 424 my $id = $attrs->{id};
2315 424 ▶ if (defined $id && exists $self->hrefs->{$id}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $id and exists $self->hrefs->{$id}) { } 10 414 424
elsif (exists $attrs->{'href'}) { } 31 383 414
Condition100%3/3
defined $id and exists $self->hrefs->{$id}
!ll&&!rl&&r
3912310
MC/DC100%2/2
defined $id and exists $self->hrefs->{$id}
defined $id exists $self->hrefs->{$id}
Truth table100%3/3
A and B
A= defined $idB= exists $self->hrefs->{$id}
ABresult
0X0
100
111
2316 10 return $self->hrefs->{$id};
2317 }
2318 elsif (exists $attrs->{href}) {
2319 31 (my $id = delete $attrs->{href}) =~ s/^(#|cid:|uuid:)?//;
2320 31 my $type=$1;
2321 31 ▶ $id=uri_unescape($id) if (defined($type) and $type eq 'cid:');
Branch: 1 branch
BranchTrueFalseTotal
if defined $type and $type eq "cid:" 17 14 31
Condition100%3/3
defined $type and $type eq "cid:"
!ll&&!rl&&r
21217
MC/DC100%2/2
defined $type and $type eq "cid:"
defined $type $type eq "cid:"
Truth table100%3/3
A and B
A= defined $typeB= $type eq "cid:"
ABresult
0X0
100
111
2322 # convert to absolute if not internal '#' or 'cid:'
2323 31 ▶ $id = $self->baselocation($id) unless $type;
Branch: 1 branch
BranchTrueFalseTotal
unless $type 2 29 31
2324 31 ▶ return $self->hrefs->{$id} if exists $self->hrefs->{$id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->hrefs->{$id} 2 29 31
2325 # First time optimization. we don't traverse IDs unless asked for it.
2326 # This is where traversing id's is delayed from before
2327 # - the first time through - ids should contain a copy of the parsed XML
2328 # structure! seems silly to make so many copies
2329 29 my $ids = $self->ids;
2330 29 ▶ if (ref($ids) ne 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ids ne "HASH") 2 27 29
2331 2 $self->ids({}); # reset list of ids first time through
2332 2 $self->traverse_ids($ids);
2333 }
2334 29 ▶ if (exists($self->ids->{$id})) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->ids->{$id}) { } 29 0 29
2335 29 my $obj = ($self->decode_object(delete($self->ids->{$id})))[1];
2336 29 return $self->hrefs->{$id} = $obj;
2337 }
2338 else {
2339 0 die "Unresolved (wrong?) href ($id) in element '$name'\n";
2340 }
2341 }
2342  
2343 return undef if grep {
2344 383 ▶ /^$SOAP::Constants::NS_XSI_NILS$/ && do {
Branch: 1 branch
BranchTrueFalseTotal
if grep {/^$SOAP::Constants::NS_XSI_NILS$/ and do { my $class = $self->xmlschemas->{$1 or $2}; eval "require $class" or die @$; $class->as_undef($attrs->{$_}) };} keys %$attrs 3 380 383
Condition66%2/3
/^$SOAP::Constants::NS_XSI_NILS$/ && do { my $class = $self->xmlschemas->{$1 or $2}; eval "require $class" or die @$; $class->as_undef($attrs->{$_}) }
!ll&&!rl&&r
39803
MC/DC50%1/2
/^$SOAP::Constants::NS_XSI_NILS$/ && do { my $class = $self->xmlschemas->{$1 or $2}; eval "require $class" or die @$; $class->as_undef($attrs->{$_}) }
/^$SOAP::Constants::NS_XSI_NILS$/ do { my $class = $self->xmlschemas->{$1 or $2}; eval "require $class" or die @$; $class->as_undef($attrs->{$_}) }
Truth table66%2/3
A && B
A= /^$SOAP::Constants::NS_XSI_NILS$/B= do { my $class = $self->xmlschemas->{$1 or $2}; eval "require $class" or die @$; $class->as_undef($attrs->{$_}) }
ABresult
0X0
100
111
2345 3 ▶ my $class = $self->xmlschemas->{ $1 || $2 };
Condition66%2/3
$1 || $2
l!l&&r!l&&!r
120
MC/DC0%0/2
$1 || $2
$1 $2
Truth table66%2/3
A || B
A= $1B= $2
ABresult
1X1
011
000
2346 3 ▶ eval "require $class" or die @$;;
Branch: 1 branch
BranchTrueFalseTotal
eval "require $class" or die @$ 3 0 3
2347 3 $class->as_undef($attrs->{$_})
2348 }
2349 } keys %$attrs;
2350  
2351 # try to handle with typecasting
2352 380 my $res = $self->typecast($value, $name, $attrs, $children, $type);
2353 380 ▶ return $res if defined $res;
Branch: 1 branch
BranchTrueFalseTotal
if defined $res 0 380 380
2354  
2355 # ok, continue with others
2356 380 ▶ if (exists $attrs->{"{$SOAP::Constants::NS_ENC}arrayType"}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $$attrs{"{$SOAP::Constants::NS_ENC}arrayType"}) { } 2 378 380
elsif ($name =~ /^\{$SOAP::Constants::NS_ENC\}Struct$/ or not $schemaclass->can($method) and ref $children || defined $class && $value =~ /^\s*$/) { } 211 167 378
2357 2 my $res = [];
2358 2 ▶ $self->hrefs->{$id} = $res if defined $id;
Branch: 1 branch
BranchTrueFalseTotal
if defined $id 0 2 2
2359  
2360 # check for arrayType which could be [1], [,2][5] or []
2361 # [,][1] will NOT be allowed right now (multidimensional sparse array)
2362 2 ▶ my($type, $multisize) = $attrs->{"{$SOAP::Constants::NS_ENC}arrayType"}
Branch: 1 branch
BranchTrueFalseTotal
() = $$attrs{"{$SOAP::Constants::NS_ENC}arrayType"} =~ /^(.+)\[(\d*(?:,\d+)*)\](?:\[(?:\d+(?:,\d+)*)\])*$/ or die qq[Unrecognized/unsupported format of arrayType attribute '@{[$$attrs{"{$SOAP::Constants::NS_ENC}arrayType"}];}'\n] 2 0 2
2363 =~ /^(.+)\[(\d*(?:,\d+)*)\](?:\[(?:\d+(?:,\d+)*)\])*$/
2364 0 or die qq!Unrecognized/unsupported format of arrayType attribute '@{[$attrs->{"{$SOAP::Constants::NS_ENC}arrayType"}]}'\n!;
2365  
2366 2 ▶ my @dimensions = map { $_ || undef } split /,/, $multisize;
Condition50%1/2
$_ || undef
l!l
20
MC/DC0%0/1
$_ || undef
$_
Truth table50%1/2
A
A= $_
Aresult
11
00
2367 2 my $size = 1;
2368 2 ▶ foreach (@dimensions) { $size *= $_ || 0 }
Condition50%1/2
$_ || 0
l!l
20
MC/DC0%0/1
$_ || 0
$_
Truth table50%1/2
A
A= $_
Aresult
11
00
2369  
2370 # TODO ähm, shouldn't this local be my?
2371 2 local $arraytype = $type;
2372  
2373 # multidimensional
2374 2 ▶ if ($multisize =~ /,/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($multisize =~ /,/) { } 0 2 2
2375 @$res = splitarray(
2376 [@dimensions],
2377 0 ▶ [map { scalar(($self->decode_object($_))[1]) } @{$children || []}]
Condition0%0/2
$children || []
l!l
00
MC/DC0%0/1
$children || []
$children
Truth table0%0/2
A
A= $children
Aresult
11
00
2378 );
2379 }
2380 # normal
2381 else {
2382 2 ▶ @$res = map { scalar(($self->decode_object($_))[1]) } @{$children || []};
Condition50%1/2
$children || []
l!l
20
MC/DC0%0/1
$children || []
$children
Truth table50%1/2
A
A= $children
Aresult
11
00
2383 }
2384  
2385 # sparse (position)
2386 2 ▶ if (ref $children && exists SOAP::Utils::o_lattr($children->[0])->{"{$SOAP::Constants::NS_ENC}position"}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $children and exists SOAP::Utils::o_lattr($children->[0])->{"{$SOAP::Constants::NS_ENC}position"}) 0 2 2
Condition33%1/3
ref $children and exists SOAP::Utils::o_lattr($children->[0])->{"{$SOAP::Constants::NS_ENC}position"}
!ll&&!rl&&r
020
MC/DC0%0/2
ref $children and exists SOAP::Utils::o_lattr($children->[0])->{"{$SOAP::Constants::NS_ENC}position"}
ref $children exists SOAP::Utils::o_lattr($children->[0])->{"{$SOAP::Constants::NS_ENC}position"}
Truth table33%1/3
A and B
A= ref $childrenB= exists SOAP::Utils::o_lattr($children->[0])->{"{$SOAP::Constants::NS_ENC}position"}
ABresult
0X0
100
111
2387 0 my @new;
2388 0 ▶ for (my $pos = 0; $pos < @$children; $pos++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos < @$children) 0 0 0
2389 # TBD implement position in multidimensional array
2390 0 ▶ my($position) = SOAP::Utils::o_lattr($children->[$pos])->{"{$SOAP::Constants::NS_ENC}position"} =~ /^\[(\d+)\]$/
Branch: 1 branch
BranchTrueFalseTotal
my($position) = SOAP::Utils::o_lattr($children->[$pos])->{"{$SOAP::Constants::NS_ENC}position"} =~ /^\[(\d+)\]$/ or die "Position must be specified for all elements of sparse array\n" 0 0 0
2391 or die "Position must be specified for all elements of sparse array\n";
2392 0 $new[$position] = $res->[$pos];
2393 }
2394 0 @$res = @new;
2395 }
2396  
2397 # partially transmitted (offset)
2398 # TBD implement offset in multidimensional array
2399 my($offset) = $attrs->{"{$SOAP::Constants::NS_ENC}offset"} =~ /^\[(\d+)\]$/
2400 2 ▶ if exists $attrs->{"{$SOAP::Constants::NS_ENC}offset"};
Branch: 1 branch
BranchTrueFalseTotal
if exists $$attrs{"{$SOAP::Constants::NS_ENC}offset"} 0 2 2
2401 2 ▶ unshift(@$res, (undef) x $offset) if $offset;
Branch: 1 branch
BranchTrueFalseTotal
if $offset 0 2 2
2402  
2403 0 ▶ die "Too many elements in array. @{[scalar@$res]} instead of claimed $multisize ($size)\n"
Branch: 1 branch
BranchTrueFalseTotal
if $multisize and $size < @$res 0 2 2
Condition33%1/3
$multisize and $size < @$res
!ll&&!rl&&r
020
MC/DC0%0/2
$multisize and $size < @$res
$multisize $size < @$res
Truth table33%1/3
A and B
A= $multisizeB= $size < @$res
ABresult
0X0
100
111
2404 if $multisize && $size < @$res;
2405  
2406 # extend the array if number of elements is specified
2407 2 ▶ $#$res = $dimensions[0]-1 if defined $dimensions[0] && @$res < $dimensions[0];
Branch: 1 branch
BranchTrueFalseTotal
if defined $dimensions[0] and @$res < $dimensions[0] 0 2 2
Condition33%1/3
defined $dimensions[0] and @$res < $dimensions[0]
!ll&&!rl&&r
020
MC/DC0%0/2
defined $dimensions[0] and @$res < $dimensions[0]
defined $dimensions[0] @$res < $dimensions[0]
Truth table33%1/3
A and B
A= defined $dimensions[0]B= @$res < $dimensions[0]
ABresult
0X0
100
111
2408  
2409 2 ▶ return defined $class && $class ne 'Array' ? bless($res => $class) : $res;
Branch: 1 branch
BranchTrueFalseTotal
defined $class && $class ne 'Array' ? : 1 1 2
Condition66%2/3
defined $class and $class ne "Array"
!ll&&!rl&&r
011
MC/DC50%1/2
defined $class and $class ne "Array"
defined $class $class ne "Array"
Truth table66%2/3
A and B
A= defined $classB= $class ne "Array"
ABresult
0X0
100
111
2410  
2411 }
2412 ▶ elsif ($name =~ /^\{$SOAP::Constants::NS_ENC\}Struct$/
Condition91%11/12
$name =~ /^\{$SOAP::Constants::NS_ENC\}Struct$/ or not $schemaclass->can($method) and ref $children || defined $class && $value =~ /^\s*$/
l!l&&r!l&&!r
0211167
not $schemaclass->can($method) and ref $children || defined $class && $value =~ /^\s*$/
!ll&&!rl&&r
8780211
ref $children or defined $class and $value =~ /^\s*$/
l!l&&r!l&&!r
210180
defined $class and $value =~ /^\s*$/
!ll&&!rl&&r
56241
MC/DC80%4/5
$name =~ /^\{$SOAP::Constants::NS_ENC\}Struct$/ or not $schemaclass->can($method) and ref $children || defined $class && $value =~ /^\s*$/
$name =~ /^\{$SOAP::Constants::NS_ENC\}Struct$/ not $schemaclass->can($method) ref $children defined $class $value =~ /^\s*$/
Truth table83%5/6
A or not(B) and C or D and E
A= $name =~ /^\{$SOAP::Constants::NS_ENC\}Struct$/B= not $schemaclass->can($method)C= ref $childrenD= defined $classE= $value =~ /^\s*$/
ABCDEresult
1XXXX1
011XX1
010111
00XXX0
0100X0
010100
2413 || !$schemaclass->can($method)
2414 && (ref $children || defined $class && $value =~ /^\s*$/)) {
2415 211 my $res = {};
2416 211 ▶ $self->hrefs->{$id} = $res if defined $id;
Branch: 1 branch
BranchTrueFalseTotal
if defined $id 20 191 211
2417  
2418 # Patch code introduced in 0.65 - deserializes array properly
2419 # Decode each element of the struct.
2420 211 my %child_count_of = ();
2421 211 ▶ foreach my $child (@{$children || []}) {
Condition100%2/2
$children || []
l!l
2101
MC/DC100%1/1
$children || []
$children
Truth table100%2/2
A
A= $children
Aresult
11
00
2422 264 my ($child_name, $child_value) = $self->decode_object($child);
2423 # Store the decoded element in the struct. If the element name is
2424 # repeated, replace the previous scalar value with a new array
2425 # containing both values.
2426 264 ▶ if (not $child_count_of{$child_name}) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $child_count_of{$child_name}) { } 253 11 264
elsif ($child_count_of{$child_name} == 1) { } 4 7 11
2427 # first time to see this value: use scalar
2428 253 $res->{$child_name} = $child_value;
2429 }
2430 elsif ($child_count_of{$child_name} == 1) {
2431 # second time to see this value: convert scalar to array
2432 4 $res->{$child_name} = [ $res->{$child_name}, $child_value ];
2433 }
2434 else {
2435 # already have an array: append to it
2436 7 push @{$res->{$child_name}}, $child_value;
2437 }
2438 264 $child_count_of{$child_name}++;
2439 }
2440 # End patch code
2441  
2442 211 ▶ return defined $class && $class ne 'SOAPStruct' ? bless($res => $class) : $res;
Branch: 1 branch
BranchTrueFalseTotal
defined $class && $class ne 'SOAPStruct' ? : 8 203 211
Condition66%2/3
defined $class and $class ne "SOAPStruct"
!ll&&!rl&&r
20308
MC/DC50%1/2
defined $class and $class ne "SOAPStruct"
defined $class $class ne "SOAPStruct"
Truth table66%2/3
A and B
A= defined $classB= $class ne "SOAPStruct"
ABresult
0X0
100
111
2443 }
2444 else {
2445 167 my $res;
2446 167 ▶ if (my $method_ref = $schemaclass->can($method)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $method_ref = $schemaclass->can($method)) { } 87 80 167
2447 87 $res = $method_ref->($self, $value, $name, $attrs, $children, $type);
2448 }
2449 else {
2450 80 $res = $self->typecast($value, $name, $attrs, $children, $type);
2451 80 ▶ $res = $class ? die "Unrecognized type '$type'\n" : $value
Branch: 2 branches
BranchTrueFalseTotal
unless defined $res 80 0 80
$class ? : 24 56 80
2452 unless defined $res;
2453 }
2454 141 ▶ $self->hrefs->{$id} = $res if defined $id;
Branch: 1 branch
BranchTrueFalseTotal
if defined $id 3 138 141
2455 141 return $res;
2456 }
2457 }
2458  
2459 0 ▶sub splitarray {
Subroutine splitarray: not called CC=5 SCAR=34.0
2460 0 my @sizes = @{+shift};
2461 0 my $size = shift @sizes;
2462 0 my $array = shift;
2463  
2464 0 ▶ return splice(@$array, 0, $size) unless @sizes;
Branch: 1 branch
BranchTrueFalseTotal
unless @sizes 0 0 0
2465 0 my @array = ();
2466 0 ▶ push @array, [
Branch: 1 branch
BranchTrueFalseTotal
@$array and !defined($size) || $size-- and do { push @array, [splitarray([@sizes], $array)] } 0 0 0
Condition0%0/6
@$array and !defined($size) || $size--
!ll&&!rl&&r
000
not defined $size or $size--
l!l&&r!l&&!r
000
MC/DC0%0/3
@$array and !defined($size) || $size--
@$array not defined $size $size--
Truth table0%0/4
A and not(B) or C
A= @$arrayB= not defined $sizeC= $size--
ABCresult
0XX0
1000
11X1
1011
2467 splitarray([@sizes], $array)
2468 ] while @$array && (!defined $size || $size--);
2469 0 return @array;
2470 }
2471  
2472 460 ▶sub typecast { } # typecast is called for both objects AND scalar types
Subroutine typecast: called CC=1 SCAR=0.0
2473 # check ref of the second parameter (first is the object)
2474 # return undef if you don't want to handle it
2475  
2476 # ======================================================================
2477  
2478 package SOAP::Client;
2479  
2480  
2481 44 ▶use SOAP::Lite::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
2482  
2483 44 our $VERSION = '1.27'; # VERSION
2484 44 ▶sub BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
2485 44 __PACKAGE__->__mk_accessors(qw(endpoint code message
2486 is_success status options));
2487 }
2488  
2489 # ======================================================================
2490  
2491 package SOAP::Server::Object;
2492  
2493 44 sub gen_id; *gen_id = \&SOAP::Serializer::gen_id;
2494  
2495 44 my %alive;
2496 my %objects;
2497  
2498 0 ▶sub objects_by_reference {
Subroutine objects_by_reference: not called CC=3 SCAR=24.8
2499 0 shift;
2500 0 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
2501 @alive{shift()} = ref $_[0]
2502 ? shift
2503 0 ▶ : sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
2504 0 ▶ $_[1]-$_[$_[5] ? 5 : 4] > $SOAP::Constants::OBJS_BY_REF_KEEPALIVE
Branch: 1 branch
BranchTrueFalseTotal
$_[5] ? : 0 0 0
2505 }
2506 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
2507 0 keys %alive;
2508 }
2509  
2510 0 ▶sub reference {
Subroutine reference: not called CC=2 SCAR=17.9
2511 0 my $self = shift;
2512 0 my $stamp = time;
2513 0 my $object = shift;
2514 0 my $id = $stamp . $self->gen_id($object);
2515  
2516 # this is code for garbage collection
2517 0 my $time = time;
2518 0 my $type = ref $object;
2519 0 my @objects = grep { $objects{$_}->[1] eq $type } keys %objects;
2520 0 for (grep { $alive{$type}->(scalar @objects, $time, @{$objects{$_}}) } @objects) {
2521 0 delete $objects{$_};
2522 }
2523  
2524 0 $objects{$id} = [$object, $type, $stamp];
2525 0 bless { id => $id } => ref $object;
2526 }
2527  
2528 19 ▶sub references {
Subroutine references: called CC=4 SCAR=23.2
2529 19 my $self = shift;
2530 19 ▶ return @_ unless %alive; # small optimization
Branch: 1 branch
BranchTrueFalseTotal
unless %alive 19 0 19
2531 return map {
2532 0 ▶ ref($_) && exists $alive{ref $_}
Branch: 1 branch
BranchTrueFalseTotal
ref $_ && exists $alive{ref $_} ? : 0 0 0
Condition0%0/3
ref $_ and exists $alive{ref $_}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_ and exists $alive{ref $_}
ref $_ exists $alive{ref $_}
Truth table0%0/3
A and B
A= ref $_B= exists $alive{ref $_}
ABresult
0X0
100
111
2533 ? $self->reference($_)
2534 : $_
2535 } @_;
2536 }
2537  
2538 0 ▶sub object {
Subroutine object: not called CC=6 SCAR=37.4
2539 0 my $self = shift;
2540 0 ▶ my $class = ref($self) || $self;
Condition0%0/3
ref $self || $self
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $self || $self
ref $self $self
Truth table0%0/3
A || B
A= ref $selfB= $self
ABresult
1X1
011
000
2541 0 my $object = shift;
2542 0 ▶ return $object unless ref($object) && $alive{ref $object} && exists $object->{id};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $object and $alive{ref $object} and exists $object->{"id"} 0 0 0
Condition0%0/6
ref $object and $alive{ref $object} and exists $object->{"id"}
!ll&&!rl&&r
000
ref $object and $alive{ref $object}
!ll&&!rl&&r
000
MC/DC0%0/3
ref $object and $alive{ref $object} and exists $object->{"id"}
ref $object $alive{ref $object} exists $object->{"id"}
Truth table0%0/4
A and B and C
A= ref $objectB= $alive{ref $object}C= exists $object->{"id"}
ABCresult
0XX0
10X0
1100
1111
2543  
2544 0 my $reference = $objects{$object->{id}};
2545 0 ▶ die "Object with specified id couldn't be found\n" unless ref $reference->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless ref $reference->[0] 0 0 0
2546  
2547 0 $reference->[3] = time; # last access time
2548 0 return $reference->[0]; # reference to actual object
2549 }
2550  
2551 19 ▶sub objects {
Subroutine objects: called CC=5 SCAR=28.4
2552 19 my $self = shift;
2553 19 ▶ return @_ unless %alive; # small optimization
Branch: 1 branch
BranchTrueFalseTotal
unless %alive 19 0 19
2554 return map {
2555 0 ref($_) && exists $alive{ref $_} && exists $_->{id}
2556 0 ▶ ? $self->object($_)
Branch: 1 branch
BranchTrueFalseTotal
ref $_ && exists $alive{ref $_} && exists $_->{'id'} ? : 0 0 0
Condition0%0/6
ref $_ and exists $alive{ref $_} and exists $_->{"id"}
!ll&&!rl&&r
000
ref $_ and exists $alive{ref $_}
!ll&&!rl&&r
000
MC/DC0%0/3
ref $_ and exists $alive{ref $_} and exists $_->{"id"}
ref $_ exists $alive{ref $_} exists $_->{"id"}
Truth table0%0/4
A and B and C
A= ref $_B= exists $alive{ref $_}C= exists $_->{"id"}
ABCresult
0XX0
10X0
1100
1111
2557 : $_
2558 } @_;
2559 }
2560  
2561 # ======================================================================
2562  
2563 package SOAP::Server::Parameters;
2564  
2565 0 ▶sub byNameOrOrder {
Subroutine byNameOrOrder: not called CC=5 SCAR=34.0
2566 0 ▶ unless (UNIVERSAL::isa($_[-1] => 'SOAP::SOM')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (UNIVERSAL::isa($_[-1], "SOAP::SOM")) 0 0 0
2567 0 ▶ warn "Last parameter is expected to be envelope\n" if $^W;
Branch: 1 branch
BranchTrueFalseTotal
if $^W 0 0 0
2568 0 pop;
2569 0 return @_;
2570 }
2571 0 my $params = pop->method;
2572 my @mandatory = ref $_[0] eq 'ARRAY'
2573 0 ▶ ? @{shift()}
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'ARRAY' ? : 0 0 0
2574 : die "list of parameters expected as the first parameter for byName";
2575 0 my $byname = 0;
2576 0 my @res = map { $byname += exists $params->{$_}; $params->{$_} } @mandatory;
2577 0 ▶ return $byname
Branch: 1 branch
BranchTrueFalseTotal
$byname ? : 0 0 0
2578 ? @res
2579 : @_;
2580 }
2581  
2582 0 ▶sub byName {
Subroutine byName: not called CC=4 SCAR=30.0
2583 0 ▶ unless (UNIVERSAL::isa($_[-1] => 'SOAP::SOM')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (UNIVERSAL::isa($_[-1], "SOAP::SOM")) 0 0 0
2584 0 ▶ warn "Last parameter is expected to be envelope\n" if $^W;
Branch: 1 branch
BranchTrueFalseTotal
if $^W 0 0 0
2585 0 pop;
2586 0 return @_;
2587 }
2588 0 ▶ return @{pop->method}{ref $_[0] eq 'ARRAY' ? @{shift()} : die "list of parameters expected as the first parameter for byName"};
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'ARRAY' ? : 0 0 0
2589 }
2590  
2591 # ======================================================================
2592  
2593 package SOAP::Server;
2594  
2595 44 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
2596 44 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
2597 20 ▶sub DESTROY { SOAP::Trace::objects('()') }
Subroutine DESTROY: called CC=1 SCAR=0.0
2598  
2599 25 ▶sub initialize {
Subroutine initialize: called CC=1 SCAR=0.0
2600 return (
2601 packager => SOAP::Packager::MIME->new,
2602 transport => SOAP::Transport->new,
2603 serializer => SOAP::Serializer->new,
2604 deserializer => SOAP::Deserializer->new,
2605 24 ▶ on_action => sub { ; },
Subroutine __ANON__: called CC=1 SCAR=0.0
2606 25 ▶ on_dispatch => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
2607 25 return;
2608 },
2609 25 );
2610 }
2611  
2612 474 ▶sub new {
Subroutine new: called CC=14 SCAR=31.2
2613 474 my $self = shift;
2614 474 ▶ return $self if ref $self;
Branch: 1 branch
BranchTrueFalseTotal
if ref $self 449 25 474
2615  
2616 25 ▶ unless (ref $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self) 25 0 25
2617 25 my $class = $self;
2618 25 my(@params, @methods);
2619  
2620 25 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 25 26
2621 1 my($method, $params) = splice(@_,0,2);
2622 1 ▶ $class->can($method)
Branch: 1 branch
BranchTrueFalseTotal
$class->can($method) ? : 1 0 1
Condition0%0/3
$^W and Carp::carp("Unrecognized parameter '${method}' in new()")
!ll&&!rl&&r
000
MC/DC0%0/2
$^W and Carp::carp("Unrecognized parameter '${method}' in new()")
$^W Carp::carp("Unrecognized parameter '${method}' in new()")
Truth table0%0/3
A and B
A= $^WB= Carp::carp("Unrecognized parameter '${method}' in new()")
ABresult
0X0
100
111
2623 ? push(@methods, $method, $params)
2624 : $^W && Carp::carp "Unrecognized parameter '$method' in new()";
2625 }
2626  
2627 25 $self = bless {
2628 _dispatch_to => [],
2629 _dispatch_with => {},
2630 _dispatched => [],
2631 _action => '',
2632 _options => {},
2633 } => $class;
2634 25 unshift(@methods, $self->initialize);
2635 44 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
2636 25 ▶ while (@methods) {
Branch: 1 branch
BranchTrueFalseTotal
if (@methods) 151 25 176
2637 151 my($method, $params) = splice(@methods,0,2);
2638 151 ▶ $self->$method(ref $params eq 'ARRAY' ? @$params : $params)
Branch: 1 branch
BranchTrueFalseTotal
ref $params eq 'ARRAY' ? : 0 151 151
2639 }
2640 25 SOAP::Trace::objects('()');
2641 }
2642  
2643 25 ▶ Carp::carp "Odd (wrong?) number of parameters in new()"
Branch: 1 branch
BranchTrueFalseTotal
if $^W and @_ & 1 0 25 25
Condition33%1/3
$^W and @_ & 1
!ll&&!rl&&r
2500
MC/DC0%0/2
$^W and @_ & 1
$^W @_ & 1
Truth table33%1/3
A and B
A= $^WB= @_ & 1
ABresult
0X0
100
111
2644 if $^W && (@_ & 1);
2645  
2646 44 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
2647 25 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 25 25
2648 0 my($method, $params) = splice(@_,0,2);
2649 0 ▶ $self->can($method)
Branch: 2 branches
BranchTrueFalseTotal
$self->can($method) ? : 0 0 0
ref $params eq 'ARRAY' ? : 0 0 0
Condition0%0/3
$^W and Carp::carp("Unrecognized parameter '${method}' in new()")
!ll&&!rl&&r
000
MC/DC0%0/2
$^W and Carp::carp("Unrecognized parameter '${method}' in new()")
$^W Carp::carp("Unrecognized parameter '${method}' in new()")
Truth table0%0/3
A and B
A= $^WB= Carp::carp("Unrecognized parameter '${method}' in new()")
ABresult
0X0
100
111
2650 ? $self->$method(ref $params eq 'ARRAY' ? @$params : $params)
2651 : $^W && Carp::carp "Unrecognized parameter '$method' in new()"
2652 }
2653  
2654 25 return $self;
2655 }
2656  
2657 30 ▶sub init_context {
Subroutine init_context: called CC=1 SCAR=0.0
2658 30 my $self = shift;
2659 30 $self->{'_deserializer'}->{'_context'} = $self;
2660 # weaken circular reference to avoid a memory hole
2661 30 weaken($self->{'_deserializer'}->{'_context'});
2662  
2663 30 $self->{'_serializer'}->{'_context'} = $self;
2664 # weaken circular reference to avoid a memory hole
2665 30 weaken($self->{'_serializer'}->{'_context'});
2666 }
2667  
2668 44 ▶sub BEGIN {
Subroutine BEGIN: called CC=5 SCAR=16.1
2669 44 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
2670 44 for my $method (qw(serializer deserializer transport)) {
2671 132 my $field = '_' . $method;
2672 261 ▶ *$method = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
2673 261 my $self = shift->new();
2674 261 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 75 186 261
2675 75 my $context = $self->{$field}->{'_context'}; # save the old context
2676 75 $self->{$field} = shift;
2677 75 $self->{$field}->{'_context'} = $context; # restore the old context
2678 75 return $self;
2679 }
2680 else {
2681 186 return $self->{$field};
2682 }
2683 }
2684 132 }
2685  
2686 44 for my $method (qw(action myuri options dispatch_with packager)) {
2687 220 my $field = '_' . $method;
2688 177 ▶ *$method = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
2689 177 my $self = shift->new();
2690 (@_)
2691 ? do {
2692 33 $self->{$field} = shift;
2693 33 return $self;
2694 }
2695 177 ▶ : return $self->{$field};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 33 144 177
2696 }
2697 220 }
2698 44 for my $method (qw(on_action on_dispatch)) {
2699 88 my $field = '_' . $method;
2700 100 ▶ *$method = sub {
Subroutine __ANON__: called CC=4 SCAR=14.0
2701 100 my $self = shift->new;
2702 # my $self = shift;
2703 100 ▶ return $self->{$field} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 50 50 100
2704 50 local $@;
2705 # commented out because that 'eval' was unsecure
2706 # > ref $_[0] eq 'CODE' ? shift : eval shift;
2707 # Am I paranoid enough?
2708 50 $self->{$field} = shift;
2709 50 ▶ Carp::croak $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 50 50
2710 Carp::croak "$method() expects subroutine (CODE) or string that evaluates into subroutine (CODE)"
2711 50 ▶ unless ref $self->{$field} eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self->{$field} eq "CODE" 0 50 50
2712 50 return $self;
2713 }
2714 88 }
2715  
2716 # __PACKAGE__->__mk_accessors( qw(dispatch_to) );
2717 44 for my $method (qw(dispatch_to)) {
2718 44 my $field = '_' . $method;
2719 38 ▶ *$method = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
2720 38 my $self = shift->new;
2721 # my $self = shift;
2722 (@_)
2723 ? do {
2724 12 $self->{$field} = [@_];
2725 12 return $self;
2726 }
2727 38 ▶ : return @{ $self->{$field} };
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 12 26 38
2728 }
2729 44 }
2730 }
2731  
2732 0 ▶sub objects_by_reference {
Subroutine objects_by_reference: not called CC=3 SCAR=24.8
2733 0 my $self = shift;
2734 0 ▶ $self = $self->new() if not ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
2735 @_
2736 0 ▶ ? (SOAP::Server::Object->objects_by_reference(@_), return $self)
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
2737 : SOAP::Server::Object->objects_by_reference;
2738 }
2739  
2740 1 ▶sub dispatched {
Subroutine dispatched: called CC=3 SCAR=12.0
2741 1 my $self = shift;
2742 1 ▶ $self = $self->new() if not ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 1 1
2743 @_
2744 0 ? (push(@{$self->{_dispatched}}, @_), return $self)
2745 1 ▶ : return @{$self->{_dispatched}};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 1 1
2746 }
2747  
2748 25 ▶sub find_target {
Subroutine find_target: called CC=30 SCAR=36.5
2749 25 my $self = shift;
2750 25 my $request = shift;
2751  
2752 # try to find URI/method from on_dispatch call first
2753 25 my($method_uri, $method_name) = $self->on_dispatch->($request);
2754  
2755 # if nothing there, then get it from envelope itself
2756 25 $request->match((ref $request)->method);
2757 25 ▶ ($method_uri, $method_name) = ($request->namespaceuriof || '', $request->dataof->name)
Branch: 1 branch
BranchTrueFalseTotal
unless $method_name 25 0 25
Condition100%2/2
$request->namespaceuriof || ''
l!l
214
MC/DC100%1/1
$request->namespaceuriof || ''
$request->namespaceuriof
Truth table100%2/2
A
A= $request->namespaceuriof
Aresult
11
00
2758 unless $method_name;
2759  
2760 25 $self->on_action->(my $action = $self->action, $method_uri, $method_name);
2761  
2762 # check to avoid security vulnerability: Protected->Unprotected::method(@parameters)
2763 # see for more details: http://www.phrack.org/phrack/58/p58-0x09
2764 25 ▶ die "Denied access to method ($method_name)\n" unless $method_name =~ /^\w+$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $method_name =~ /^\w+$/ 0 25 25
2765  
2766 25 my ($class, $static);
2767 # try to bind directly
2768 25 ▶ if (defined($class = $self->dispatch_with->{$method_uri}
Branch: 2 branches
BranchTrueFalseTotal
if (defined($class = $self->dispatch_with->{$method_uri} || $self->dispatch_with->{$action or ''} || (defined $action && $action =~ /^"(.+)"$/ ? $self->dispatch_with->{$1} : undef))) { } 4 21 25
defined $action && $action =~ /^"(.+)"$/ ? : 1 21 22
Condition100%11/11
$self->dispatch_with->{$method_uri} || $self->dispatch_with->{$action or ''} || (defined $action && $action =~ /^"(.+)"$/ ? $self->dispatch_with->{$1} : undef)
l!l&&r!l&&!r
3121
$self->dispatch_with->{$method_uri} or $self->dispatch_with->{$action or ""}
l!l&&r!l&&!r
2122
$action || ''
l!l
221
defined $action and $action =~ /^"(.+)"$/
!ll&&!rl&&r
1201
MC/DC100%4/4
$self->dispatch_with->{$method_uri} || $self->dispatch_with->{$action or ''} || (defined $action && $action =~ /^"(.+)"$/ ? $self->dispatch_with->{$1} : undef)
$self->dispatch_with->{$method_uri} $self->dispatch_with->{$action or ""} defined $action $action =~ /^"(.+)"$/
MC/DC100%1/1
$action || ''
$action
Truth table100%5/5
A or B || C and D
A= $self->dispatch_with->{$method_uri}B= $self->dispatch_with->{$action or ""}C= defined $actionD= $action =~ /^"(.+)"$/
ABCDresult
1XXX1
01XX1
00111
000X0
00100
Truth table100%2/2
A
A= $action
Aresult
11
00
2769 || $self->dispatch_with->{$action || ''}
2770 || (defined($action) && $action =~ /^"(.+)"$/
2771 ? $self->dispatch_with->{$1}
2772 : undef))) {
2773 # return object, nothing else to do here
2774 4 ▶ return ($class, $method_uri, $method_name) if ref $class;
Branch: 1 branch
BranchTrueFalseTotal
if ref $class 1 3 4
2775 3 $static = 1;
2776 }
2777 else {
2778 21 ▶ die "URI path shall map to class" unless defined ($class = URI->new($method_uri)->path);
Branch: 1 branch
BranchTrueFalseTotal
unless defined($class = "URI"->new($method_uri)->path) 0 21 21
2779  
2780 21 for ($class) { s!^/|/$!!g; s!/!::!g; s/^$/main/; }
2781 21 ▶ die "Failed to access class ($class)" unless $class =~ /^(\w[\w:]*)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $class =~ /^(\w[\w:]*)$/ 0 21 21
2782  
2783 21 my $fullname = "$class\::$method_name";
2784 21 foreach ($self->dispatch_to) {
2785 21 ▶ return ($_, $method_uri, $method_name) if ref eq $class; # $OBJECT
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ eq $class 1 20 21
2786 20 ▶ next if ref; # skip other objects
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ 0 20 20
2787 # will ignore errors, because it may complain on
2788 # d:\foo\bar, which is PATH and not regexp
2789 20 eval {
2790 20 ▶ $static ||= $class =~ /^$_$/ # MODULE
Condition50%6/12
$static ||= $class =~ /^$_$/ || $fullname =~ /^$_$/ || $method_name =~ /^$_$/ && $class eq "main"
l!l&&r!l&&!r
0200
$class =~ /^$_$/ || $fullname =~ /^$_$/ || $method_name =~ /^$_$/ && $class eq 'main'
l!l&&r!l&&!r
1810
$class =~ /^$_$/ or $fullname =~ /^$_$/
l!l&&r!l&&!r
1801
$method_name =~ /^$_$/ and $class eq "main"
!ll&&!rl&&r
001
MC/DC0%0/5
$static ||= $class =~ /^$_$/ || $fullname =~ /^$_$/ || $method_name =~ /^$_$/ && $class eq "main"
$static $class =~ /^$_$/ $fullname =~ /^$_$/ $method_name =~ /^$_$/ $class eq "main"
Truth table0%0/6
A ||= B or C || D and E
A= $staticB= $class =~ /^$_$/C= $fullname =~ /^$_$/D= $method_name =~ /^$_$/E= $class eq "main"
ABCDEresult
1XXXX1
01XXX1
001XX1
000111
0000X0
000100
2791 || $fullname =~ /^$_$/ # MODULE::method
2792 || $method_name =~ /^$_$/ && ($class eq 'main'); # method ('main' assumed)
2793 };
2794 }
2795 }
2796  
2797 44 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
2798  
2799 # TODO - sort this mess out:
2800 # The task is to test whether the class in question has already been loaded.
2801 #
2802 # SOAP::Lite 0.60:
2803 # unless (defined %{"${class}::"}) {
2804 # Patch to SOAP::Lite 0.60:
2805 # The following patch does not work for packages defined within a BEGIN block
2806 # unless (exists($INC{join '/', split /::/, $class.'.pm'})) {
2807 # Combination of 0.60 and patch did not work reliably, either.
2808 #
2809 # Now we do the following: Check whether the class is main (always loaded)
2810 # or the class implements the method in question
2811 # or the package exists as file in %INC.
2812 #
2813 # This is still sort of a hack - but I don't know anything better
2814 # If you have some idea, please help me out...
2815 #
2816 23 ▶ unless (($class eq 'main') || $class->can($method_name)
Branch: 1 branch
BranchTrueFalseTotal
unless ($class eq "main" or $class->can($method_name) or exists $INC{join "/", split(/::/, $class . '.pm', 0)}) 5 18 23
Condition83%5/6
$class eq "main" or $class->can($method_name) or exists $INC{join "/", split(/::/, $class . '.pm', 0)}
l!l&&r!l&&!r
1805
$class eq "main" or $class->can($method_name)
l!l&&r!l&&!r
4145
MC/DC66%2/3
$class eq "main" or $class->can($method_name) or exists $INC{join "/", split(/::/, $class . '.pm', 0)}
$class eq "main" $class->can($method_name) exists $INC{join "/", split(/::/, $class . '.pm', 0)}
Truth table75%3/4
A or B or C
A= $class eq "main"B= $class->can($method_name)C= exists $INC{join "/", split(/::/, $class . '.pm', 0)}
ABCresult
1XX1
01X1
0011
0000
2817 || exists($INC{join '/', split /::/, $class . '.pm'})) {
2818  
2819 # allow all for static and only specified path for dynamic bindings
2820 5 ▶ local @INC = (($static ? @INC : ()), grep {!ref && m![/\\.]!} $self->dispatch_to());
Branch: 1 branch
BranchTrueFalseTotal
$static ? : 5 0 5
Condition33%1/3
!ref($_) && m[[/\\.]]
!ll&&!rl&&r
050
MC/DC0%0/2
!ref($_) && m[[/\\.]]
!ref($_) m[[/\\.]]
Truth table33%1/3
not(A) && B
A= !ref($_)B= m[[/\\.]]
ABresult
0X0
100
111
2821 5 eval 'local $^W; ' . "require $class";
2822 5 ▶ die "Failed to access class ($class): $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 5 0 5
2823 0 ▶ $self->dispatched($class) unless $static;
Branch: 1 branch
BranchTrueFalseTotal
unless $static 0 0 0
2824 }
2825  
2826 die "Denied access to method ($method_name) in class ($class)"
2827 0 ▶ unless $static || grep {/^$class$/} $self->dispatched;
Branch: 1 branch
BranchTrueFalseTotal
unless $static or grep {/^$class$/;} $self->dispatched 1 17 18
Condition66%2/3
$static or grep {/^$class$/;} $self->dispatched
l!l&&r!l&&!r
1701
MC/DC50%1/2
$static or grep {/^$class$/;} $self->dispatched
$static grep {/^$class$/;} $self->dispatched
Truth table66%2/3
A or B
A= $staticB= grep {/^$class$/;} $self->dispatched
ABresult
1X1
011
000
2828  
2829 17 return ($class, $method_uri, $method_name);
2830 }
2831  
2832 30 ▶sub handle {
Subroutine handle: called CC=26 SCAR=41.5
2833 30 SOAP::Trace::trace('()');
2834 30 my $self = shift;
2835 30 ▶ $self = $self->new if !ref $self; # inits the server when called in a static context
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 4 26 30
2836 30 $self->init_context();
2837 # we want to restore it when we are done
2838 30 local $SOAP::Constants::DEFAULT_XML_SCHEMA
2839 = $SOAP::Constants::DEFAULT_XML_SCHEMA;
2840  
2841 # SOAP version WILL NOT be restored when we are done.
2842 # is it problem?
2843  
2844 30 my $result = eval {
2845 30 local $SIG{__DIE__};
2846 # why is this here:
2847 30 $self->serializer->soapversion(1.1);
2848 30 my $request = eval { $self->deserializer->deserialize($_[0]) };
2849  
2850 30 ▶ die SOAP::Fault
Branch: 1 branch
BranchTrueFalseTotal
if $@ and $@ =~ /^$SOAP::Constants::WRONG_VERSION/ 0 30 30
Condition66%2/3
$@ and $@ =~ /^$SOAP::Constants::WRONG_VERSION/
!ll&&!rl&&r
2820
MC/DC0%0/2
$@ and $@ =~ /^$SOAP::Constants::WRONG_VERSION/
$@ $@ =~ /^$SOAP::Constants::WRONG_VERSION/
Truth table66%2/3
A and B
A= $@B= $@ =~ /^$SOAP::Constants::WRONG_VERSION/
ABresult
0X0
100
111
2851 ->faultcode($SOAP::Constants::FAULT_VERSION_MISMATCH)
2852 ->faultstring($@)
2853 if $@ && $@ =~ /^$SOAP::Constants::WRONG_VERSION/;
2854  
2855 30 ▶ die "Application failed during request deserialization: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 2 28 30
2856 28 my $som = ref $request;
2857 28 ▶ die "Can't find root element in the message"
Branch: 1 branch
BranchTrueFalseTotal
unless $request->match($som->envelope) 1 27 28
2858 unless $request->match($som->envelope);
2859 27 $self->serializer->soapversion(SOAP::Lite->soapversion);
2860 27 ▶ $self->serializer->xmlschema($SOAP::Constants::DEFAULT_XML_SCHEMA
Branch: 1 branch
BranchTrueFalseTotal
if $self->deserializer->xmlschema 20 7 27
2861 = $self->deserializer->xmlschema)
2862 if $self->deserializer->xmlschema;
2863  
2864 die SOAP::Fault
2865 ->faultcode($SOAP::Constants::FAULT_MUST_UNDERSTAND)
2866 ->faultstring("Unrecognized header has mustUnderstand attribute set to 'true'")
2867 if !$SOAP::Constants::DO_NOT_CHECK_MUSTUNDERSTAND &&
2868 grep {
2869 0 ▶ $_->mustUnderstand
Branch: 1 branch
BranchTrueFalseTotal
if not $SOAP::Constants::DO_NOT_CHECK_MUSTUNDERSTAND and grep {$_->mustUnderstand and !$_->actor || $_->actor eq $SOAP::Constants::NEXT_ACTOR;} $request->dataof($som->headers) 0 27 27
Condition11%1/9
not $SOAP::Constants::DO_NOT_CHECK_MUSTUNDERSTAND and grep {$_->mustUnderstand and !$_->actor || $_->actor eq $SOAP::Constants::NEXT_ACTOR;} $request->dataof($som->headers)
!ll&&!rl&&r
0270
$_->mustUnderstand && (!$_->actor || $_->actor eq $SOAP::Constants::NEXT_ACTOR)
!ll&&!rl&&r
000
not $_->actor or $_->actor eq $SOAP::Constants::NEXT_ACTOR
l!l&&r!l&&!r
000
MC/DC0%0/2
not $SOAP::Constants::DO_NOT_CHECK_MUSTUNDERSTAND and grep {$_->mustUnderstand and !$_->actor || $_->actor eq $SOAP::Constants::NEXT_ACTOR;} $request->dataof($som->headers)
not $SOAP::Constants::DO_NOT_CHECK_MUSTUNDERSTAND grep {$_->mustUnderstand and !$_->actor || $_->actor eq $SOAP::Constants::NEXT_ACTOR;} $request->dataof($som->headers)
MC/DC0%0/3
$_->mustUnderstand && (!$_->actor || $_->actor eq $SOAP::Constants::NEXT_ACTOR)
$_->mustUnderstand not $_->actor $_->actor eq $SOAP::Constants::NEXT_ACTOR
Truth table33%1/3
not(A) and B
A= not $SOAP::Constants::DO_NOT_CHECK_MUSTUNDERSTANDB= grep {$_->mustUnderstand and !$_->actor || $_->actor eq $SOAP::Constants::NEXT_ACTOR;} $request->dataof($som->headers)
ABresult
0X0
100
111
Truth table0%0/4
A && not(B) or C
A= $_->mustUnderstandB= not $_->actorC= $_->actor eq $SOAP::Constants::NEXT_ACTOR
ABCresult
0XX0
1000
11X1
1011
2870 && (!$_->actor || $_->actor eq $SOAP::Constants::NEXT_ACTOR)
2871 } $request->dataof($som->headers);
2872  
2873 27 ▶ die "Can't find method element in the message"
Branch: 1 branch
BranchTrueFalseTotal
unless $request->match($som->method) 2 25 27
2874 unless $request->match($som->method);
2875 # TODO - SOAP::Dispatcher plugs in here
2876 # my $handler = $self->dispatcher->find_handler($request);
2877 25 my($class, $method_uri, $method_name) = $self->find_target($request);
2878 19 my @results = eval {
2879 19 local $^W;
2880 19 my @parameters = $request->paramsin;
2881  
2882 # SOAP::Trace::dispatch($fullname);
2883 19 SOAP::Trace::parameters(@parameters);
2884  
2885 19 ▶ push @parameters, $request
Branch: 1 branch
BranchTrueFalseTotal
if UNIVERSAL::isa($class, "SOAP::Server::Parameters") 0 19 19
2886 if UNIVERSAL::isa($class => 'SOAP::Server::Parameters');
2887  
2888 44 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
2889 SOAP::Server::Object->references(
2890 defined $parameters[0]
2891 && ref $parameters[0]
2892 && UNIVERSAL::isa($parameters[0] => $class)
2893 19 ▶ ? do {
Branch: 1 branch
BranchTrueFalseTotal
defined $parameters[0] && ref $parameters[0] && UNIVERSAL::isa($parameters[0], $class) ? : 0 19 19
Condition50%3/6
defined $parameters[0] and ref $parameters[0] and UNIVERSAL::isa($parameters[0], $class)
!ll&&!rl&&r
1900
defined $parameters[0] and ref $parameters[0]
!ll&&!rl&&r
3160
MC/DC0%0/3
defined $parameters[0] and ref $parameters[0] and UNIVERSAL::isa($parameters[0], $class)
defined $parameters[0] ref $parameters[0] UNIVERSAL::isa($parameters[0], $class)
Truth table50%2/4
A and B and C
A= defined $parameters[0]B= ref $parameters[0]C= UNIVERSAL::isa($parameters[0], $class)
ABCresult
0XX0
10X0
1100
1111
2894 0 my $object = shift @parameters;
2895 0 ▶ SOAP::Server::Object->object(ref $class
Branch: 1 branch
BranchTrueFalseTotal
ref $class ? : 0 0 0
2896 ? $class
2897 : $object
2898 )->$method_name(SOAP::Server::Object->objects(@parameters)),
2899  
2900 # send object back as a header
2901 # preserve name, specify URI
2902 SOAP::Header
2903 ->uri($SOAP::Constants::NS_SL_HEADER => $object)
2904 ->name($request->dataof($som->method.'/[1]')->name)
2905 } # end do block
2906  
2907 # SOAP::Dispatcher will plug-in here as well
2908 # $handler->dispatch(SOAP::Server::Object->objects(@parameters)
2909 : $class->$method_name(SOAP::Server::Object->objects(@parameters)) );
2910 }; # end eval block
2911 19 SOAP::Trace::result(@results);
2912  
2913 # let application errors pass through with 'Server' code
2914 19 ▶ die ref $@
Branch: 3 branches
BranchTrueFalseTotal
if $@ 0 19 19
ref $@ ? : 0 0 0
$@ =~ /^Can\'t locate object method "$method_name"/ ? : 0 0 0
2915 ? $@
2916 : $@ =~ /^Can\'t locate object method "$method_name"/
2917 ? "Failed to locate method ($method_name) in class ($class)"
2918 : SOAP::Fault->faultcode($SOAP::Constants::FAULT_SERVER)->faultstring($@)
2919 if $@;
2920  
2921 19 my $result = $self->serializer
2922 ->prefix('s') # distinguish generated element names between client and server
2923 ->uri($method_uri)
2924 ->envelope(response => $method_name . 'Response', @results);
2925 19 return $result;
2926 };
2927  
2928 # void context
2929 30 ▶ return unless defined wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless defined wantarray 0 30 30
2930  
2931 # normal result
2932 30 ▶ return $result unless $@;
Branch: 1 branch
BranchTrueFalseTotal
unless $@ 19 11 30
2933  
2934 # check fails, something wrong with message
2935 11 ▶ return $self->make_fault($SOAP::Constants::FAULT_CLIENT, $@) unless ref $@;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $@ 11 0 11
2936  
2937 # died with SOAP::Fault
2938 0 ▶ return $self->make_fault($@->faultcode || $SOAP::Constants::FAULT_SERVER,
Branch: 1 branch
BranchTrueFalseTotal
if UNIVERSAL::isa($@, "SOAP::Fault") 0 0 0
Condition0%0/5
$@->faultcode || $SOAP::Constants::FAULT_SERVER
l!l&&r!l&&!r
000
$@->faultstring || 'Application error'
l!l
00
MC/DC0%0/2
$@->faultcode || $SOAP::Constants::FAULT_SERVER
$@->faultcode $SOAP::Constants::FAULT_SERVER
MC/DC0%0/1
$@->faultstring || 'Application error'
$@->faultstring
Truth table0%0/3
A || B
A= $@->faultcodeB= $SOAP::Constants::FAULT_SERVER
ABresult
1X1
011
000
Truth table0%0/2
A
A= $@->faultstring
Aresult
11
00
2939 $@->faultstring || 'Application error',
2940 $@->faultdetail, $@->faultactor)
2941 if UNIVERSAL::isa($@ => 'SOAP::Fault');
2942  
2943 # died with complex detail
2944 0 return $self->make_fault($SOAP::Constants::FAULT_SERVER, 'Application error' => $@);
2945  
2946 } # end of handle()
2947  
2948 13 ▶sub make_fault {
Subroutine make_fault: called CC=2 SCAR=7.6
2949 13 my $self = shift;
2950 13 my($code, $string, $detail, $actor) = @_;
2951 13 ▶ $self->serializer->fault($code, $string, $detail, $actor || $self->myuri);
Condition33%1/3
$actor || $self->myuri
l!l&&r!l&&!r
0013
MC/DC0%0/2
$actor || $self->myuri
$actor $self->myuri
Truth table33%1/3
A || B
A= $actorB= $self->myuri
ABresult
1X1
011
000
2952 }
2953  
2954 # ======================================================================
2955  
2956 package SOAP::Trace;
2957  
2958 44 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
2959  
2960 44 my @list = qw(
2961 transport dispatch result
2962 parameters headers objects
2963 method fault freeform
2964 trace debug);
2965 {
2966 44 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
2967 44 for (@list) {
2968 3055 ▶ *$_ = sub {}
Subroutine __ANON__: called CC=1 SCAR=0.0
2969 484 }
2970 }
2971  
2972 0 ▶sub defaultlog {
Subroutine defaultlog: not called CC=2 SCAR=17.9
2973 0 my $caller = (caller(1))[3]; # the 4th element returned by caller is the subroutine name
2974 0 ▶ $caller = (caller(2))[3] if $caller =~ /eval/;
Branch: 1 branch
BranchTrueFalseTotal
if $caller =~ /eval/ 0 0 0
2975 0 chomp(my $msg = join ' ', @_);
2976 0 printf STDERR "%s: %s\n", $caller, $msg;
2977 }
2978  
2979 2 ▶sub import {
Subroutine import: called CC=11 SCAR=25.4
2980 44 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
2981 44 ▶ no warnings qw{ redefine }; # suppress warnings about redefining
Subroutine BEGIN: called CC=1 SCAR=0.0
2982 2 my $pack = shift;
2983 2 my(@notrace, @symbols);
2984 2 for (@_) {
2985 3 ▶ if (ref eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_ eq 'CODE') { } 1 2 3
2986 1 my $call = $_;
2987 0 ▶ foreach (@symbols) { *$_ = sub { $call->(@_) } }
Subroutine __ANON__: not called CC=1 SCAR=0.4
2988 1 @symbols = ();
2989 }
2990 else {
2991 2 local $_ = $_;
2992 2 my $minus = s/^-//;
2993 2 my $all = $_ eq 'all';
2994 2 ▶ Carp::carp "Illegal symbol for tracing ($_)" unless $all || $pack->can($_);
Branch: 1 branch
BranchTrueFalseTotal
unless $all or $pack->can($_) 0 2 2
Condition33%1/3
$all or $pack->can($_)
l!l&&r!l&&!r
020
MC/DC0%0/2
$all or $pack->can($_)
$all $pack->can($_)
Truth table33%1/3
A or B
A= $allB= $pack->can($_)
ABresult
1X1
011
000
2995 2 ▶ $minus ? push(@notrace, $all ? @list : $_) : push(@symbols, $all ? @list : $_);
Branch: 3 branches
BranchTrueFalseTotal
$minus ? : 0 2 2
$all ? : 0 0 0
$all ? : 0 2 2
2996 }
2997 }
2998 2 foreach (@symbols) { *$_ = \&defaultlog }
2999 0 ▶ foreach (@notrace) { *$_ = sub {} }
Subroutine __ANON__: not called CC=1 SCAR=1.2
3000 }
3001  
3002 # ======================================================================
3003  
3004 package SOAP::Custom::XML::Data;
3005  
3006 44 ▶use vars qw(@ISA $AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
3007 44 @ISA = qw(SOAP::Data);
3008  
3009 44 ▶use overload fallback => 1, '""' => sub { shift->value };
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
3010  
3011 201 ▶sub _compileit {
Subroutine _compileit: called CC=1 SCAR=0.0
3012 44 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
3013 201 my $method = shift;
3014 202 ▶ *$method = sub {
Subroutine __ANON__: called CC=5 SCAR=16.1
3015 return __PACKAGE__->SUPER::name($method => $_[0]->attr->{$method})
3016 202 ▶ if exists $_[0]->attr->{$method};
Branch: 1 branch
BranchTrueFalseTotal
if exists $_[0]->attr->{$method} 41 161 202
3017 my @elems = grep {
3018 161 ▶ ref $_ && UNIVERSAL::isa($_ => __PACKAGE__)
Condition83%5/6
ref $_ && UNIVERSAL::isa($_, __PACKAGE__) && $_->SUPER::name =~ /(^|:)$method$/
!ll&&!rl&&r
5172189
ref $_ and UNIVERSAL::isa($_, __PACKAGE__)
!ll&&!rl&&r
50361
MC/DC66%2/3
ref $_ && UNIVERSAL::isa($_, __PACKAGE__) && $_->SUPER::name =~ /(^|:)$method$/
ref $_ UNIVERSAL::isa($_, __PACKAGE__) $_->SUPER::name =~ /(^|:)$method$/
Truth table75%3/4
A and B && C
A= ref $_B= UNIVERSAL::isa($_, __PACKAGE__)C= $_->SUPER::name =~ /(^|:)$method$/
ABCresult
0XX0
10X0
1100
1111
3019 && $_->SUPER::name =~ /(^|:)$method$/
3020 } $_[0]->value;
3021 161 ▶ return wantarray? @elems : $elems[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 79 82 161
3022 201 };
3023 }
3024  
3025 44 ▶sub BEGIN { foreach (qw(name type import use)) { _compileit($_) } }
Subroutine BEGIN: called CC=2 SCAR=6.9
3026  
3027 25 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=2 SCAR=7.0
3028 25 my $method = substr($AUTOLOAD, rindex($AUTOLOAD, '::') + 2);
3029 25 ▶ return if $method eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $method eq "DESTROY" 0 25 25
3030  
3031 25 _compileit($method);
3032 25 goto &$AUTOLOAD;
3033 }
3034  
3035 # ======================================================================
3036  
3037 package SOAP::Custom::XML::Deserializer;
3038  
3039 44 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
3040 44 @ISA = qw(SOAP::Deserializer);
3041  
3042 189 ▶sub decode_value {
Subroutine decode_value: called CC=4 SCAR=14.0
3043 189 my $self = shift;
3044 189 my $ref = shift;
3045 189 my($name, $attrs, $children, $value) = @$ref;
3046 # base class knows what to do with it
3047 189 ▶ return $self->SUPER::decode_value($ref) if exists $attrs->{href};
Branch: 1 branch
BranchTrueFalseTotal
if exists $attrs->{"href"} 0 189 189
3048  
3049 189 ▶ SOAP::Custom::XML::Data
Branch: 1 branch
BranchTrueFalseTotal
ref $children && @$children ? : 76 113 189
Condition66%2/3
ref $children and @$children
!ll&&!rl&&r
113076
MC/DC50%1/2
ref $children and @$children
ref $children @$children
Truth table66%2/3
A and B
A= ref $childrenB= @$children
ABresult
0X0
100
111
3050 -> SOAP::Data::name($name)
3051 -> attr($attrs)
3052 -> set_value(ref $children && @$children
3053 ? map(scalar(($self->decode_object($_))[1]), @$children)
3054 : $value);
3055 }
3056  
3057 # ======================================================================
3058  
3059 package SOAP::Schema::Deserializer;
3060  
3061 44 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
3062 44 @ISA = qw(SOAP::Custom::XML::Deserializer);
3063  
3064 # ======================================================================
3065  
3066 package SOAP::Schema::WSDL;
3067  
3068 44 ▶use vars qw(%imported @ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
3069 44 @ISA = qw(SOAP::Schema);
3070  
3071 6 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
3072 6 my $self = shift;
3073  
3074 6 ▶ unless (ref $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self) 2 4 6
3075 2 my $class = $self;
3076 2 $self = $class->SUPER::new(@_);
3077 }
3078 6 return $self;
3079 }
3080  
3081 2 ▶sub base {
Subroutine base: called CC=2 SCAR=6.9
3082 2 my $self = shift->new;
3083 @_
3084 ? ($self->{_base} = shift, return $self)
3085 2 ▶ : return $self->{_base};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 1 1 2
3086 }
3087  
3088 1 ▶sub import {
Subroutine import: called CC=10 SCAR=39.1
3089 1 my $self = shift->new;
3090 1 my $s = shift;
3091 1 ▶ my $base = shift || $self->base || die "Missing base argument for ", __PACKAGE__, "\n";
Condition40%2/5
shift() || $self->base || die('Missing base argument for ', __PACKAGE__, "\n")
l!l
10
shift() or $self->base
l!l&&r!l&&!r
010
MC/DC0%0/2
shift() || $self->base || die('Missing base argument for ', __PACKAGE__, "\n")
shift() $self->base
Truth table33%1/3
A or B
A= shift()B= $self->base
ABresult
1X1
011
000
3092  
3093 1 my @a = $s->import;
3094 1 local %imported = %imported;
3095 1 foreach (@a) {
3096 0 ▶ next unless $_->location;
Branch: 1 branch
BranchTrueFalseTotal
unless $_->location 0 0 0
3097 0 my $location = URI->new_abs($_->location->value, $base)->as_string;
3098 0 ▶ if ($imported{$location}++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($SOAP::Schema::WSDL::imported{$location}++) 0 0 0
3099 0 ▶ warn "Recursion loop detected in service description from '$location'. Ignored\n" if $^W;
Branch: 1 branch
BranchTrueFalseTotal
if $^W 0 0 0
3100 0 return $s;
3101 }
3102 0 my $root = $self->import(
3103 $self->deserializer->deserialize(
3104 $self->access($location)
3105 )->root, $location);
3106  
3107 $root->SOAP::Data::name eq 'definitions' ? $s->set_value($s->value, $root->value) :
3108 0 ▶ $root->SOAP::Data::name eq 'schema' ? do { # add <types> element if there is no one
Branch: 2 branches
BranchTrueFalseTotal
$root->SOAP::Data::name eq 'definitions' ? : 0 0 0
$root->SOAP::Data::name eq 'schema' ? : 0 0 0
3109 0 ▶ $s->set_value($s->value, $self->deserializer->deserialize('<types></types>')->root) unless $s->types;
Branch: 1 branch
BranchTrueFalseTotal
unless $s->types 0 0 0
3110 0 $s->types->set_value($s->types->value, $root) } :
3111 0 die "Don't know what to do with '@{[$root->SOAP::Data::name]}' in schema imported from '$location'\n";
3112 }
3113  
3114 # return the parsed WSDL file
3115 1 $s;
3116 }
3117  
3118 # TODO - This is woefully incomplete!
3119 1 ▶sub parse_schema_element {
Subroutine parse_schema_element: called CC=5 SCAR=20.9
3120 1 my $element = shift;
3121 # Current element is a complex type
3122 1 ▶ if (defined($element->complexType)) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $element->complexType) { } 1 0 1
elsif ($element->simpleType) { } 0 0 0
3123 1 my @elements = ();
3124 1 ▶ if (defined($element->complexType->sequence)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $element->complexType->sequence) 0 1 1
3125  
3126 0 foreach my $e ($element->complexType->sequence->element) {
3127 0 push @elements,parse_schema_element($e);
3128 }
3129 }
3130 1 return @elements;
3131 }
3132 elsif ($element->simpleType) {
3133 }
3134 else {
3135 0 return $element;
3136 }
3137 }
3138  
3139 1 ▶sub parse {
Subroutine parse: called CC=33 SCAR=43.7
3140 1 my $self = shift->new;
3141 1 my($s, $service, $port) = @_;
3142 1 my @result;
3143  
3144 # handle imports
3145 1 $self->import($s);
3146  
3147 # handle descriptions without <service>, aka tModel-type descriptions
3148 1 my @services = $s->service;
3149 1 my $tns = $s->{'_attr'}->{'targetNamespace'};
3150 # if there is no <service> element we'll provide it
3151 1 ▶ @services = $self->deserializer->deserialize(<<"FAKE")->root->service unless @services;
Branch: 1 branch
BranchTrueFalseTotal
unless @services 0 1 1
3152 <definitions>
3153 0 ▶ <service name="@{[$service || 'FakeService']}">
Condition0%0/2
$service || 'FakeService'
l!l
00
MC/DC0%0/1
$service || 'FakeService'
$service
Truth table0%0/2
A
A= $service
Aresult
11
00
3154 0 ▶ <port name="@{[$port || 'FakePort']}" binding="@{[$s->binding->name]}"/>
Condition0%0/2
$port || 'FakePort'
l!l
00
MC/DC0%0/1
$port || 'FakePort'
$port
Truth table0%0/2
A
A= $port
Aresult
11
00
3155 </service>
3156 </definitions>
3157 FAKE
3158  
3159 1 my $has_warned = 0;
3160 1 foreach (@services) {
3161 1 my $name = $_->name;
3162 1 ▶ next if $service && $service ne $name;
Branch: 1 branch
BranchTrueFalseTotal
if $service and $service ne $name 0 1 1
Condition33%1/3
$service and $service ne $name
!ll&&!rl&&r
100
MC/DC0%0/2
$service and $service ne $name
$service $service ne $name
Truth table33%1/3
A and B
A= $serviceB= $service ne $name
ABresult
0X0
100
111
3163 1 my %services;
3164 1 foreach ($_->port) {
3165 1 ▶ next if $port && $port ne $_->name;
Branch: 1 branch
BranchTrueFalseTotal
if $port and $port ne $_->name 0 1 1
Condition33%1/3
$port and $port ne $_->name
!ll&&!rl&&r
100
MC/DC0%0/2
$port and $port ne $_->name
$port $port ne $_->name
Truth table33%1/3
A and B
A= $portB= $port ne $_->name
ABresult
0X0
100
111
3166 1 my $binding = SOAP::Utils::disqualify($_->binding);
3167 1 ▶ my $endpoint = ref $_->address ? $_->address->location : undef;
Branch: 1 branch
BranchTrueFalseTotal
ref $_->address ? : 1 0 1
3168 1 foreach ($s->binding) {
3169 # is this a SOAP binding?
3170 1 ▶ next unless grep { $_->uri eq 'http://schemas.xmlsoap.org/wsdl/soap/' } $_->binding;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_->uri eq "http://schemas.xmlsoap.org/wsdl/soap/";} $_->binding 0 1 1
3171 1 ▶ next unless $_->name eq $binding;
Branch: 1 branch
BranchTrueFalseTotal
unless $_->name eq $binding 0 1 1
3172 1 my $default_style = $_->binding->style;
3173 1 my $porttype = SOAP::Utils::disqualify($_->type);
3174 1 foreach ($_->operation) {
3175 1 my $opername = $_->name;
3176 1 $services{$opername} = {}; # should be initialized in 5.7 and after
3177 1 my $soapaction = $_->operation->soapAction;
3178 1 ▶ my $invocationStyle = $_->operation->style || $default_style || "rpc";
Condition40%2/5
$_->operation->style || $default_style || 'rpc'
l!l
10
$_->operation->style or $default_style
l!l&&r!l&&!r
001
MC/DC0%0/2
$_->operation->style || $default_style || 'rpc'
$_->operation->style $default_style
Truth table0%0/3
A or B
A= $_->operation->styleB= $default_style
ABresult
1X1
011
000
3179 1 ▶ my $encodingStyle = $_->input->body->use || "encoded";
Condition50%1/2
$_->input->body->use || 'encoded'
l!l
10
MC/DC0%0/1
$_->input->body->use || 'encoded'
$_->input->body->use
Truth table50%1/2
A
A= $_->input->body->use
Aresult
11
00
3180 1 ▶ my $namespace = $_->input->body->namespace || $tns;
Condition33%1/3
$_->input->body->namespace || $tns
l!l&&r!l&&!r
010
MC/DC0%0/2
$_->input->body->namespace || $tns
$_->input->body->namespace $tns
Truth table33%1/3
A || B
A= $_->input->body->namespaceB= $tns
ABresult
1X1
011
000
3181 1 my @parts;
3182 1 foreach ($s->portType) {
3183 1 ▶ next unless $_->name eq $porttype;
Branch: 1 branch
BranchTrueFalseTotal
unless $_->name eq $porttype 0 1 1
3184 1 foreach ($_->operation) {
3185 2 ▶ next unless $_->name eq $opername;
Branch: 1 branch
BranchTrueFalseTotal
unless $_->name eq $opername 1 1 2
3186 1 my $inputmessage = SOAP::Utils::disqualify($_->input->message);
3187 1 foreach my $msg ($s->message) {
3188 4 ▶ next unless $msg->name eq $inputmessage;
Branch: 1 branch
BranchTrueFalseTotal
unless $msg->name eq $inputmessage 3 1 4
3189 1 ▶ if ($invocationStyle eq "document" && $encodingStyle eq "literal") {
Branch: 1 branch
BranchTrueFalseTotal
if ($invocationStyle eq 'document' and $encodingStyle eq 'literal') { } 1 0 1
Condition33%1/3
$invocationStyle eq "document" and $encodingStyle eq "literal"
!ll&&!rl&&r
001
MC/DC0%0/2
$invocationStyle eq "document" and $encodingStyle eq "literal"
$invocationStyle eq "document" $encodingStyle eq "literal"
Truth table33%1/3
A and B
A= $invocationStyle eq "document"B= $encodingStyle eq "literal"
ABresult
0X0
100
111
3190 # warn "document/literal support is EXPERIMENTAL in SOAP::Lite"
3191 # if !$has_warned && ($has_warned = 1);
3192 1 my ($input_ns,$input_name) = SOAP::Utils::splitqname($msg->part->element);
3193 1 ▶ if ($input_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($input_name) 0 1 1
3194 0 foreach my $schema ($s->types->schema) {
3195 0 foreach my $element ($schema->element) {
3196 0 ▶ next unless $element->name eq $input_name;
Branch: 1 branch
BranchTrueFalseTotal
unless $element->name eq $input_name 0 0 0
3197 0 push @parts,parse_schema_element($element);
3198 }
3199 0 $services{$opername}->{parameters} = [ @parts ];
3200 }
3201 }
3202 }
3203 else {
3204 # TODO - support all combinations of doc|rpc/lit|enc.
3205 #warn "$invocationStyle/$encodingStyle is not supported in this version of SOAP::Lite";
3206 0 @parts = $msg->part;
3207 0 $services{$opername}->{parameters} = [ @parts ];
3208 }
3209 }
3210 }
3211  
3212 1 for ($services{$opername}) {
3213 1 $_->{endpoint} = $endpoint;
3214 1 $_->{soapaction} = $soapaction;
3215 1 $_->{namespace} = $namespace;
3216 # $_->{parameters} = [@parts];
3217 }
3218 }
3219 }
3220 }
3221 }
3222 # fix nonallowed characters in package name, and add 's' if started with digit
3223 1 for ($name) { s/\W+/_/g; s/^(\d)/s$1/ }
3224 1 push @result, $name => \%services;
3225 }
3226 1 return @result;
3227 }
3228  
3229 # ======================================================================
3230  
3231 # Naming? SOAP::Service::Schema?
3232 package SOAP::Schema;
3233  
3234 44 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
3235  
3236 3 ▶sub DESTROY { SOAP::Trace::objects('()') }
Subroutine DESTROY: called CC=1 SCAR=0.0
3237  
3238 20 ▶sub new {
Subroutine new: called CC=7 SCAR=21.5
3239 20 my $self = shift;
3240 20 ▶ return $self if ref $self;
Branch: 1 branch
BranchTrueFalseTotal
if ref $self 17 3 20
3241 3 ▶ unless (ref $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self) 3 0 3
3242 3 my $class = $self;
3243 3 require LWP::UserAgent;
3244 3 $self = bless {
3245 '_deserializer' => SOAP::Schema::Deserializer->new,
3246 '_useragent' => LWP::UserAgent->new,
3247 }, $class;
3248  
3249 3 SOAP::Trace::objects('()');
3250 }
3251  
3252 3 ▶ Carp::carp "Odd (wrong?) number of parameters in new()" if $^W && (@_ & 1);
Branch: 1 branch
BranchTrueFalseTotal
if $^W and @_ & 1 0 3 3
Condition33%1/3
$^W and @_ & 1
!ll&&!rl&&r
300
MC/DC0%0/2
$^W and @_ & 1
$^W @_ & 1
Truth table33%1/3
A and B
A= $^WB= @_ & 1
ABresult
0X0
100
111
3253 44 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
3254 3 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 3 3
3255 0 my $method = shift;
3256 0 ▶ $self->$method(shift) if $self->can($method)
Branch: 1 branch
BranchTrueFalseTotal
if $self->can($method) 0 0 0
3257 }
3258  
3259 3 return $self;
3260 }
3261  
3262 0 ▶sub schema {
Subroutine schema: not called CC=1 SCAR=6.9
3263 0 warn "SOAP::Schema->schema has been deprecated. "
3264 . "Please use SOAP::Schema->schema_url instead.";
3265 0 return shift->schema_url(@_);
3266 }
3267  
3268 44 ▶sub BEGIN {
Subroutine BEGIN: called CC=2 SCAR=6.9
3269 44 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
3270 44 for my $method (qw(deserializer schema_url services useragent stub cache_dir cache_ttl)) {
3271 308 my $field = '_' . $method;
3272 15 ▶ *$method = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
3273 15 my $self = shift->new;
3274 15 ▶ @_ ? ($self->{$field} = shift, return $self) : return $self->{$field};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 3 12 15
3275 }
3276 308 }
3277 }
3278  
3279 1 ▶sub parse {
Subroutine parse: called CC=1 SCAR=0.0
3280 1 my $self = shift;
3281 1 my $s = $self->deserializer->deserialize($self->access)->root;
3282 # here should be something that defines what schema description we want to use
3283 1 $self->services({SOAP::Schema::WSDL->base($self->schema_url)->useragent($self->useragent)->parse($s, @_)});
3284  
3285 }
3286  
3287 0 ▶sub refresh_cache {
Subroutine refresh_cache: not called CC=2 SCAR=17.9
3288 0 my $self = shift;
3289 0 my ($filename,$contents) = @_;
3290 0 ▶ open CACHE,">$filename" or Carp::croak "Could not open cache file for writing: $!";
Branch: 1 branch
BranchTrueFalseTotal
open CACHE, ">$filename" or Carp::croak("Could not open cache file for writing: $!") 0 0 0
3291 0 print CACHE $contents;
3292 0 close CACHE;
3293 }
3294  
3295 1 ▶sub load {
Subroutine load: called CC=11 SCAR=32.1
3296 1 my $self = shift->new;
3297 1 local $^W; # suppress warnings about redefining
3298 1 ▶ foreach (keys %{$self->services || Carp::croak 'Nothing to load. Schema is not specified'}) {
Condition50%1/2
$self->services || Carp::croak('Nothing to load. Schema is not specified')
l!l
10
MC/DC0%0/1
$self->services || Carp::croak('Nothing to load. Schema is not specified')
$self->services
Truth table50%1/2
A
A= $self->services
Aresult
11
00
3299 # TODO - check age of cached file, and delete if older than configured amount
3300 1 ▶ if ($self->cache_dir) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->cache_dir) { } 0 1 1
3301 0 my $cached_file = File::Spec->catfile($self->cache_dir,$_.".pm");
3302 0 ▶ my $ttl = $self->cache_ttl || $SOAP::Constants::DEFAULT_CACHE_TTL;
Condition0%0/3
$self->cache_ttl || $SOAP::Constants::DEFAULT_CACHE_TTL
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->cache_ttl || $SOAP::Constants::DEFAULT_CACHE_TTL
$self->cache_ttl $SOAP::Constants::DEFAULT_CACHE_TTL
Truth table0%0/3
A || B
A= $self->cache_ttlB= $SOAP::Constants::DEFAULT_CACHE_TTL
ABresult
1X1
011
000
3303 0 open (CACHE, "<$cached_file");
3304 0 ▶ my @stat = stat($cached_file) unless eof(CACHE);
Branch: 1 branch
BranchTrueFalseTotal
unless eof CACHE 0 0 0
3305 0 close CACHE;
3306 0 ▶ if (@stat) {
Branch: 1 branch
BranchTrueFalseTotal
if (@stat) { } 0 0 0
3307 # Cache exists
3308 0 my $cache_lived = time() - $stat[9];
3309 0 ▶ if ($ttl > 0 && $cache_lived > $ttl) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ttl > 0 and $cache_lived > $ttl) 0 0 0
Condition0%0/3
$ttl > 0 and $cache_lived > $ttl
!ll&&!rl&&r
000
MC/DC0%0/2
$ttl > 0 and $cache_lived > $ttl
$ttl > 0 $cache_lived > $ttl
Truth table0%0/3
A and B
A= $ttl > 0B= $cache_lived > $ttl
ABresult
0X0
100
111
3310 0 $self->refresh_cache($cached_file,$self->generate_stub($_));
3311 }
3312 }
3313 else {
3314 # Cache doesn't exist
3315 0 $self->refresh_cache($cached_file,$self->generate_stub($_));
3316 }
3317 0 push @INC,$self->cache_dir;
3318 0 ▶ eval "require $_" or Carp::croak "Could not load cached file: $@";
Branch: 1 branch
BranchTrueFalseTotal
eval "require $_" or Carp::croak("Could not load cached file: $@") 0 0 0
3319 }
3320 else {
3321 1 ▶ eval $self->generate_stub($_) or Carp::croak "Bad stub: $@";
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=2 SCAR=6.9
Subroutine BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
eval $self->generate_stub($_) or Carp::croak("Bad stub: $@") 1 0 1
3322 }
3323 }
3324 1 $self;
3325 }
3326  
3327 1 ▶sub access {
Subroutine access: called CC=7 SCAR=23.4
3328 1 my $self = shift->new;
3329 1 ▶ my $url = shift || $self->schema_url || Carp::croak 'Nothing to access. URL is not specified';
Condition33%2/6
shift() || $self->schema_url || Carp::croak('Nothing to access. URL is not specified')
l!l
100
shift() or $self->schema_url
l!l&&r!l&&!r
010
MC/DC0%0/2
shift() || $self->schema_url || Carp::croak('Nothing to access. URL is not specified')
shift() $self->schema_url
Truth table33%1/3
A or B
A= shift()B= $self->schema_url
ABresult
1X1
011
000
3330 1 ▶ $self->useragent->env_proxy if $ENV{'HTTP_proxy'};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"HTTP_proxy"} 0 1 1
3331  
3332 1 my $req = HTTP::Request->new(GET => $url);
3333 $req->proxy_authorization_basic($ENV{'HTTP_proxy_user'}, $ENV{'HTTP_proxy_pass'})
3334 1 ▶ if ($ENV{'HTTP_proxy_user'} && $ENV{'HTTP_proxy_pass'});
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"HTTP_proxy_user"} and $ENV{"HTTP_proxy_pass"} 0 1 1
Condition33%1/3
$ENV{"HTTP_proxy_user"} and $ENV{"HTTP_proxy_pass"}
!ll&&!rl&&r
100
MC/DC0%0/2
$ENV{"HTTP_proxy_user"} and $ENV{"HTTP_proxy_pass"}
$ENV{"HTTP_proxy_user"} $ENV{"HTTP_proxy_pass"}
Truth table33%1/3
A and B
A= $ENV{"HTTP_proxy_user"}B= $ENV{"HTTP_proxy_pass"}
ABresult
0X0
100
111
3335  
3336 1 my $resp = $self->useragent->request($req);
3337 1 ▶ $resp->is_success ? $resp->content : die "Service description '$url' can't be loaded: ", $resp->status_line, "\n";
Branch: 1 branch
BranchTrueFalseTotal
$resp->is_success ? : 1 0 1
3338 }
3339  
3340 1 ▶sub generate_stub {
Subroutine generate_stub: called CC=10 SCAR=24.9
3341 1 my $self = shift->new;
3342 1 my $package = shift;
3343 1 my $services = $self->services->{$package};
3344 1 my $schema_url = $self->schema_url;
3345  
3346 1 $self->{'_stub'} = <<"EOP";
3347 package $package;
3348 # Generated by SOAP::Lite (v$SOAP::Lite::VERSION) for Perl -- soaplite.com
3349 # Copyright (C) 2000-2006 Paul Kulchenko, Byrne Reese
3350 1 # -- generated at [@{[scalar localtime]}]
3351 EOP
3352 1 ▶ $self->{'_stub'} .= "# -- generated from $schema_url\n" if $schema_url;
Branch: 1 branch
BranchTrueFalseTotal
if $schema_url 1 0 1
3353 1 $self->{'_stub'} .= 'my %methods = ('."\n";
3354 1 foreach my $service (keys %$services) {
3355 1 $self->{'_stub'} .= "'$service' => {\n";
3356 1 foreach (qw(endpoint soapaction namespace)) {
3357 3 $self->{'_stub'} .= " $_ => '".$services->{$service}{$_}."',\n";
3358 }
3359 1 $self->{'_stub'} .= " parameters => [\n";
3360 1 foreach (@{$services->{$service}{parameters}}) {
3361 # This is a workaround for https://sourceforge.net/tracker/index.php?func=detail&aid=2001592&group_id=66000&atid=513017
3362 0 ▶ next unless ref $_;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_ 0 0 0
3363 0 $self->{'_stub'} .= " SOAP::Data->new(name => '".$_->name."', type => '".$_->type."', attr => {";
3364 0 $self->{'_stub'} .= do {
3365 0 my %attr = %{$_->attr};
3366 0 join(', ', map {"'$_' => '$attr{$_}'"}
3367 0 grep {/^xmlns:(?!-)/}
3368 keys %attr);
3369 };
3370 0 $self->{'_stub'} .= "}),\n";
3371 }
3372 1 $self->{'_stub'} .= " ], # end parameters\n";
3373 1 $self->{'_stub'} .= " }, # end $service\n";
3374 }
3375 1 $self->{'_stub'} .= "); # end my %methods\n";
3376 1 $self->{'_stub'} .= <<'EOP';
3377  
3378 use SOAP::Lite;
3379 use Exporter;
3380 use Carp ();
3381  
3382 use vars qw(@ISA $AUTOLOAD @EXPORT_OK %EXPORT_TAGS);
3383 @ISA = qw(Exporter SOAP::Lite);
3384 @EXPORT_OK = (keys %methods);
3385 %EXPORT_TAGS = ('all' => [@EXPORT_OK]);
3386  
3387 sub _call {
3388 my ($self, $method) = (shift, shift);
3389 my $name = UNIVERSAL::isa($method => 'SOAP::Data') ? $method->name : $method;
3390 my %method = %{$methods{$name}};
3391 $self->proxy($method{endpoint} || Carp::croak "No server address (proxy) specified")
3392 unless $self->proxy;
3393 my @templates = @{$method{parameters}};
3394 my @parameters = ();
3395 foreach my $param (@_) {
3396 if (@templates) {
3397 my $template = shift @templates;
3398 my ($prefix,$typename) = SOAP::Utils::splitqname($template->type);
3399 my $method = 'as_'.$typename;
3400 # TODO - if can('as_'.$typename) {...}
3401 my $result = $self->serializer->$method($param, $template->name, $template->type, $template->attr);
3402 push(@parameters, $template->value($result->[2]));
3403 }
3404 else {
3405 push(@parameters, $param);
3406 }
3407 }
3408 $self->endpoint($method{endpoint})
3409 ->ns($method{namespace})
3410 ->on_action(sub{qq!"$method{soapaction}"!});
3411 EOP
3412 1 my $namespaces = $self->deserializer->ids->[1];
3413 1 foreach my $key (keys %{$namespaces}) {
3414 7 my ($ns,$prefix) = SOAP::Utils::splitqname($key);
3415 7 ▶ next if $namespaces->{$key} eq 'http://schemas.xmlsoap.org/wsdl/soap/';
Branch: 1 branch
BranchTrueFalseTotal
if $namespaces->{$key} eq "http://schemas.xmlsoap.org/wsdl/soap/" 1 6 7
3416 6 ▶ $self->{'_stub'} .= ' $self->serializer->register_ns("'.$namespaces->{$key}.'","'.$prefix.'");'."\n"
Branch: 1 branch
BranchTrueFalseTotal
if defined $ns and $ns eq "xmlns" 3 3 6
Condition66%2/3
defined $ns and $ns eq "xmlns"
!ll&&!rl&&r
303
MC/DC50%1/2
defined $ns and $ns eq "xmlns"
defined $ns $ns eq "xmlns"
Truth table66%2/3
A and B
A= defined $nsB= $ns eq "xmlns"
ABresult
0X0
100
111
3417 if (defined $ns && ($ns eq "xmlns"));
3418 }
3419 1 $self->{'_stub'} .= <<'EOP';
3420 my $som = $self->SUPER::call($method => @parameters);
3421 if ($self->want_som) {
3422 return $som;
3423 }
3424 UNIVERSAL::isa($som => 'SOAP::SOM') ? wantarray ? $som->paramsall : $som->result : $som;
3425 }
3426  
3427 sub BEGIN {
3428 no strict 'refs';
3429 for my $method (qw(want_som)) {
3430 my $field = '_' . $method;
3431 *$method = sub {
3432 my $self = shift->new;
3433 @_ ? ($self->{$field} = shift, return $self) : return $self->{$field};
3434 }
3435 }
3436 }
3437 no strict 'refs';
3438 for my $method (@EXPORT_OK) {
3439 my %method = %{$methods{$method}};
3440 *$method = sub {
3441 my $self = UNIVERSAL::isa($_[0] => __PACKAGE__)
3442 ? ref $_[0]
3443 ? shift # OBJECT
3444 # CLASS, either get self or create new and assign to self
3445 : (shift->self || __PACKAGE__->self(__PACKAGE__->new))
3446 # function call, either get self or create new and assign to self
3447 : (__PACKAGE__->self || __PACKAGE__->self(__PACKAGE__->new));
3448 $self->_call($method, @_);
3449 }
3450 }
3451  
3452 sub AUTOLOAD {
3453 my $method = substr($AUTOLOAD, rindex($AUTOLOAD, '::') + 2);
3454 return if $method eq 'DESTROY' || $method eq 'want_som';
3455 die "Unrecognized method '$method'. List of available method(s): @EXPORT_OK\n";
3456 }
3457  
3458 1;
3459 EOP
3460 1 return $self->stub;
3461 }
3462  
3463 # ======================================================================
3464  
3465 package SOAP;
3466  
3467 44 ▶use vars qw($AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
3468 44 require URI;
3469  
3470 44 my $soap; # shared between SOAP and SOAP::Lite packages
3471  
3472 {
3473 44 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
3474 118011 ▶ *AUTOLOAD = sub {
Subroutine __ANON__: called CC=23 SCAR=59.1
3475 118011 local($1,$2);
3476 118011 my($package, $method) = $AUTOLOAD =~ m/(?:(.+)::)([^:]+)$/;
3477 118011 ▶ return if $method eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $method eq "DESTROY" 118010 1 118011
3478  
3479 1 ▶ my $soap = ref $_[0] && UNIVERSAL::isa($_[0] => 'SOAP::Lite')
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] && UNIVERSAL::isa($_[0], 'SOAP::Lite') ? : 0 1 1
Condition40%2/5
ref $_[0] and UNIVERSAL::isa($_[0], "SOAP::Lite")
!ll&&!rl&&r
100
$soap or die "SOAP:: prefix shall only be used in combination with +autodispatch option\n"
l!l
01
MC/DC0%0/2
ref $_[0] and UNIVERSAL::isa($_[0], "SOAP::Lite")
ref $_[0] UNIVERSAL::isa($_[0], "SOAP::Lite")
MC/DC0%0/1
$soap or die "SOAP:: prefix shall only be used in combination with +autodispatch option\n"
$soap
Truth table33%1/3
A and B
A= ref $_[0]B= UNIVERSAL::isa($_[0], "SOAP::Lite")
ABresult
0X0
100
111
Truth table50%1/2
A
A= $soap
Aresult
11
00
3480 ? $_[0]
3481 : $soap
3482 || die "SOAP:: prefix shall only be used in combination with +autodispatch option\n";
3483  
3484 0 my $uri = URI->new($soap->uri);
3485 0 my $currenturi = $uri->path;
3486 0 ▶ $package = ref $_[0] && UNIVERSAL::isa($_[0] => 'SOAP::Lite')
Branch: 4 branches
BranchTrueFalseTotal
ref $_[0] && UNIVERSAL::isa($_[0], 'SOAP::Lite') ? : 0 0 0
$package eq 'SOAP' ? : 0 0 0
$_[0] eq 'SOAP' ? : 0 0 0
$package eq 'main' ? : 0 0 0
Condition0%0/11
ref $_[0] and UNIVERSAL::isa($_[0], "SOAP::Lite")
!ll&&!rl&&r
000
ref $_[0] or $_[0] eq "SOAP" ? $currenturi || Carp::croak("URI is not specified for method call") : $_[0]
l!l&&r!l&&!r
000
$currenturi or Carp::croak("URI is not specified for method call")
l!l
00
$currenturi or $package
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $_[0] and UNIVERSAL::isa($_[0], "SOAP::Lite")
ref $_[0] UNIVERSAL::isa($_[0], "SOAP::Lite")
MC/DC0%0/2
ref $_[0] or $_[0] eq "SOAP" ? $currenturi || Carp::croak("URI is not specified for method call") : $_[0]
ref $_[0] $_[0] eq "SOAP" ? $currenturi || Carp::croak("URI is not specified for method call") : $_[0]
MC/DC0%0/1
$currenturi or Carp::croak("URI is not specified for method call")
$currenturi
MC/DC0%0/2
$currenturi or $package
$currenturi $package
Truth table0%0/3
A and B
A= ref $_[0]B= UNIVERSAL::isa($_[0], "SOAP::Lite")
ABresult
0X0
100
111
Truth table0%0/3
A or B
A= ref $_[0]B= $_[0] eq "SOAP" ? $currenturi || Carp::croak("URI is not specified for method call") : $_[0]
ABresult
1X1
011
000
Truth table0%0/2
A
A= $currenturi
Aresult
11
00
Truth table0%0/3
A or B
A= $currenturiB= $package
ABresult
1X1
011
000
3487 ? $currenturi
3488 : $package eq 'SOAP'
3489 ? ref $_[0] || ($_[0] eq 'SOAP'
3490 ? $currenturi || Carp::croak "URI is not specified for method call"
3491 : $_[0])
3492 : $package eq 'main'
3493 ? $currenturi || $package
3494 : $package;
3495  
3496 # drop first parameter if it's a class name
3497 {
3498 0 my $pack = $package;
3499 0 for ($pack) { s!^/!!; s!/!::!g; }
3500 0 ▶ shift @_ if @_ && !ref $_[0] && ($_[0] eq $pack || $_[0] eq 'SOAP')
Branch: 1 branch
BranchTrueFalseTotal
if @_ and not ref $_[0] and $_[0] eq $pack || $_[0] eq "SOAP" or ref $_[0] and UNIVERSAL::isa($_[0], "SOAP::Lite") 0 0 0
Condition0%0/15
@_ and not ref $_[0] and $_[0] eq $pack || $_[0] eq "SOAP" or ref $_[0] and UNIVERSAL::isa($_[0], "SOAP::Lite")
l!l&&r!l&&!r
000
@_ and not ref $_[0] and $_[0] eq $pack || $_[0] eq "SOAP"
!ll&&!rl&&r
000
@_ and not ref $_[0]
!ll&&!rl&&r
000
$_[0] eq $pack or $_[0] eq "SOAP"
l!l&&r!l&&!r
000
ref $_[0] and UNIVERSAL::isa($_[0], "SOAP::Lite")
!ll&&!rl&&r
000
MC/DC0%0/6
@_ and not ref $_[0] and $_[0] eq $pack || $_[0] eq "SOAP" or ref $_[0] and UNIVERSAL::isa($_[0], "SOAP::Lite")
@_ not ref $_[0] $_[0] eq $pack $_[0] eq "SOAP" ref $_[0] UNIVERSAL::isa($_[0], "SOAP::Lite")
Truth table0%0/11
A and not(B) and C or D or E and F
A= @_B= not ref $_[0]C= $_[0] eq $packD= $_[0] eq "SOAP"E= ref $_[0]F= UNIVERSAL::isa($_[0], "SOAP::Lite")
ABCDEFresult
111XXX1
1101XX1
0XXX111
10XX111
1100111
0XXX0X0
0XXX100
10XX0X0
10XX100
11000X0
1100100
3501 || ref $_[0] && UNIVERSAL::isa($_[0] => 'SOAP::Lite');
3502 }
3503  
3504 0 for ($package) { s!::!/!g; s!^/?!/!; }
3505 0 $uri->path($package);
3506  
3507 0 my $som = $soap->uri($uri->as_string)->call($method => @_);
3508 0 ▶ UNIVERSAL::isa($som => 'SOAP::SOM')
Branch: 2 branches
BranchTrueFalseTotal
UNIVERSAL::isa($som, 'SOAP::SOM') ? : 0 0 0
wantarray ? : 0 0 0
3509 ? wantarray
3510 ? $som->paramsall
3511 : $som->result
3512 : $som;
3513 44 };
3514 }
3515  
3516 # ======================================================================
3517  
3518 package SOAP::Lite;
3519  
3520 44 ▶use vars qw($AUTOLOAD @ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
3521 44 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
3522  
3523 44 ▶use SOAP::Lite::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
3524 44 ▶use SOAP::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
3525 44 ▶use SOAP::Packager;
Subroutine BEGIN: called CC=1 SCAR=0.0
3526  
3527 44 ▶use Scalar::Util qw(weaken blessed reftype);
Subroutine BEGIN: called CC=1 SCAR=0.0
3528  
3529 44 @ISA = qw(SOAP::Cloneable);
3530  
3531 # provide access to global/autodispatched object
3532 0 ▶sub self {
Subroutine self: not called CC=2 SCAR=17.9
Pod documented
3533 0 ▶ @_ > 1
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 0 0 0
3534 ? $soap = $_[1]
3535 : $soap
3536 }
3537  
3538 # no more warnings about "used only once"
3539 44 *UNIVERSAL::AUTOLOAD if 0;
3540  
3541 0 ▶sub autodispatched { \&{*UNIVERSAL::AUTOLOAD} eq \&{*SOAP::AUTOLOAD} };
Subroutine autodispatched: not called CC=1 SCAR=6.9
Pod undocumented
3542  
3543 0 ▶sub on_debug {
Subroutine on_debug: not called CC=1 SCAR=6.9
Pod documented
3544 0 my $self = shift;
3545 0 my ($logger) = @_;
3546 #print "DEBUG: self=$self\n";
3547 #print "DEBUG: logger=$logger\n";
3548 #print "DEBUG: transport=$self->transport\n";
3549 #print "DEBUG: Lite.pm: calling setDebugLogger\n";
3550 0 $self->transport->setDebugLogger($logger);
3551 }
3552  
3553 271 ▶sub soapversion {
Subroutine soapversion: called CC=6 SCAR=18.8
Pod documented
3554 271 my $self = shift;
3555 271 ▶ my $version = shift or return $SOAP::Constants::SOAP_VERSION;
Branch: 1 branch
BranchTrueFalseTotal
my $version = shift() or return $SOAP::Constants::SOAP_VERSION 107 164 271
3556  
3557 ($version) = grep {
3558 126 $SOAP::Constants::SOAP_VERSIONS{$_}->{NS_ENV} eq $version
3559 } keys %SOAP::Constants::SOAP_VERSIONS
3560 107 ▶ unless exists $SOAP::Constants::SOAP_VERSIONS{$version};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $SOAP::Constants::SOAP_VERSIONS{$version} 63 44 107
3561  
3562 die qq!$SOAP::Constants::WRONG_VERSION Supported versions:\n@{[
3563 0 join "\n", map {" $_ ($SOAP::Constants::SOAP_VERSIONS{$_}->{NS_ENV})"} keys %SOAP::Constants::SOAP_VERSIONS
3564 ]}\n!
3565 107 ▶ unless defined($version) && defined(my $def = $SOAP::Constants::SOAP_VERSIONS{$version});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $version and defined(my $def = $SOAP::Constants::SOAP_VERSIONS{$version}) 0 107 107
Condition33%1/3
defined $version and defined(my $def = $SOAP::Constants::SOAP_VERSIONS{$version})
!ll&&!rl&&r
00107
MC/DC0%0/2
defined $version and defined(my $def = $SOAP::Constants::SOAP_VERSIONS{$version})
defined $version defined(my $def = $SOAP::Constants::SOAP_VERSIONS{$version})
Truth table33%1/3
A and B
A= defined $versionB= defined(my $def = $SOAP::Constants::SOAP_VERSIONS{$version})
ABresult
0X0
100
111
3566  
3567 107 foreach (keys %$def) {
3568 535 eval "\$SOAP::Constants::$_ = '$SOAP::Constants::SOAP_VERSIONS{$version}->{$_}'";
3569 }
3570  
3571 107 $SOAP::Constants::SOAP_VERSION = $version;
3572  
3573 107 return $self;
3574 }
3575  
3576 44 ▶BEGIN { SOAP::Lite->soapversion(1.1) }
Subroutine BEGIN: called CC=1 SCAR=0.0
3577  
3578 70 ▶sub import {
Subroutine import: called CC=25 SCAR=39.8
3579 70 my $pkg = shift;
3580 70 my $caller = caller;
3581 44 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
3582 # emulate 'use SOAP::Lite 0.99' behavior
3583 70 ▶ $pkg->require_version(shift) if defined $_[0] && $_[0] =~ /^\d/;
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[0] and $_[0] =~ /^\d/ 0 70 70
Condition66%2/3
defined $_[0] and $_[0] =~ /^\d/
!ll&&!rl&&r
6280
MC/DC0%0/2
defined $_[0] and $_[0] =~ /^\d/
defined $_[0] $_[0] =~ /^\d/
Truth table66%2/3
A and B
A= defined $_[0]B= $_[0] =~ /^\d/
ABresult
0X0
100
111
3584  
3585 70 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 10 70 80
3586 10 my $command = shift;
3587  
3588 my @parameters = UNIVERSAL::isa($_[0] => 'ARRAY')
3589 10 ▶ ? @{shift()}
Branch: 2 branches
BranchTrueFalseTotal
if @_ and $command ne "autodispatch" 9 1 10
UNIVERSAL::isa($_[0], 'ARRAY') ? : 2 7 9
Condition66%2/3
@_ and $command ne "autodispatch"
!ll&&!rl&&r
019
MC/DC50%1/2
@_ and $command ne "autodispatch"
@_ $command ne "autodispatch"
Truth table66%2/3
A and B
A= @_B= $command ne "autodispatch"
ABresult
0X0
100
111
3590 : shift
3591 if @_ && $command ne 'autodispatch';
3592  
3593 10 ▶ if ($command eq 'autodispatch' || $command eq 'dispatch_from') {
Branch: 4 branches
BranchTrueFalseTotal
if ($command eq 'autodispatch' or $command eq 'dispatch_from') { } 1 9 10
elsif ($command eq 'service') { } 0 9 9
elsif ($command eq 'debug' or $command eq 'trace') { } 2 7 9
elsif ($command eq 'import') { } 0 7 7
Condition66%2/3
$command eq "autodispatch" or $command eq "dispatch_from"
l!l&&r!l&&!r
109
MC/DC50%1/2
$command eq "autodispatch" or $command eq "dispatch_from"
$command eq "autodispatch" $command eq "dispatch_from"
Truth table66%2/3
A or B
A= $command eq "autodispatch"B= $command eq "dispatch_from"
ABresult
1X1
011
000
3594 1 ▶ $soap = ($soap||$pkg)->new;
Condition33%1/3
$soap || $pkg
l!l&&r!l&&!r
010
MC/DC0%0/2
$soap || $pkg
$soap $pkg
Truth table33%1/3
A || B
A= $soapB= $pkg
ABresult
1X1
011
000
3595 44 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
3596 1 ▶ foreach ($command eq 'autodispatch'
Branch: 1 branch
BranchTrueFalseTotal
$command eq 'autodispatch' ? : 1 0 1
3597 ? 'UNIVERSAL'
3598 : @parameters
3599 ) {
3600 1 my $sub = "${_}::AUTOLOAD";
3601 1 ▶ defined &{*$sub}
Branch: 1 branch
BranchTrueFalseTotal
\&{*$sub;} eq \&{*SOAP::AUTOLOAD;} ? : 0 0 0
3602 0 ▶ ? (\&{*$sub} eq \&{*SOAP::AUTOLOAD}
Branch: 1 branch
BranchTrueFalseTotal
defined &{*$sub;} ? : 0 1 1
3603 ? ()
3604 : Carp::croak "$sub already assigned and won't work with DISPATCH. Died")
3605 : (*$sub = *SOAP::AUTOLOAD);
3606 }
3607 }
3608 elsif ($command eq 'service') {
3609 0 foreach (keys %{SOAP::Schema->schema_url(shift(@parameters))->parse(@parameters)->load->services}) {
3610 0 $_->export_to_level(1, undef, ':all');
3611 }
3612 }
3613 ▶ elsif ($command eq 'debug' || $command eq 'trace') {
Condition66%2/3
$command eq "debug" or $command eq "trace"
l!l&&r!l&&!r
027
MC/DC50%1/2
$command eq "debug" or $command eq "trace"
$command eq "debug" $command eq "trace"
Truth table66%2/3
A or B
A= $command eq "debug"B= $command eq "trace"
ABresult
1X1
011
000
3614 2 ▶ SOAP::Trace->import(@parameters ? @parameters : 'all');
Branch: 1 branch
BranchTrueFalseTotal
@parameters ? : 2 0 2
3615 }
3616 elsif ($command eq 'import') {
3617 0 local $^W; # suppress warnings about redefining
3618 0 my $package = shift(@parameters);
3619 0 ▶ $package->export_to_level(1, undef, @parameters ? @parameters : ':all') if $package;
Branch: 2 branches
BranchTrueFalseTotal
if $package 0 0 0
@parameters ? : 0 0 0
3620 }
3621 else {
3622 7 ▶ Carp::carp "Odd (wrong?) number of parameters in import(), still continue" if $^W && !(@parameters & 1);
Branch: 1 branch
BranchTrueFalseTotal
if $^W and not @parameters & 1 0 7 7
Condition66%2/3
$^W and not @parameters & 1
!ll&&!rl&&r
520
MC/DC0%0/2
$^W and not @parameters & 1
$^W not @parameters & 1
Truth table66%2/3
A and not(B)
A= $^WB= not @parameters & 1
ABresult
0X0
100
111
3623 7 ▶ $soap = ($soap||$pkg)->$command(@parameters);
Condition66%2/3
$soap || $pkg
l!l&&r!l&&!r
250
MC/DC0%0/2
$soap || $pkg
$soap $pkg
Truth table66%2/3
A || B
A= $soapB= $pkg
ABresult
1X1
011
000
3624 }
3625 }
3626 }
3627  
3628 30 ▶sub DESTROY { SOAP::Trace::objects('()') }
Subroutine DESTROY: called CC=1 SCAR=0.0
3629  
3630 303 ▶sub new {
Subroutine new: called CC=11 SCAR=25.7
Pod documented
3631 303 my $self = shift;
3632 303 ▶ return $self if ref $self;
Branch: 1 branch
BranchTrueFalseTotal
if ref $self 272 31 303
3633 31 ▶ unless (ref $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self) 31 0 31
3634 31 my $class = $self;
3635 # Check whether we can clone. Only the SAME class allowed, no inheritance
3636 $self = ref($soap) eq $class ? $soap->clone : {
3637 _transport => SOAP::Transport->new,
3638 _serializer => SOAP::Serializer->new,
3639 _deserializer => SOAP::Deserializer->new,
3640 _packager => SOAP::Packager::MIME->new,
3641 _schema => undef,
3642 _autoresult => 0,
3643 16 ▶ _on_action => sub { sprintf '"%s#%s"', shift || '', shift },
Subroutine __ANON__: called CC=2 SCAR=6.9
Condition100%2/2
shift() || ''
l!l
115
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
3644 1 ▶ _on_fault => sub {ref $_[1] ? return $_[1] : Carp::croak $_[0]->transport->is_success ? $_[1] : $_[0]->transport->status},
Subroutine __ANON__: called CC=3 SCAR=16.0
Branch: 2 branches
BranchTrueFalseTotal
ref $_[1] ? : 1 0 1
$_[0]->transport->is_success ? : 0 0 0
3645 31 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
ref $soap eq $class ? : 5 26 31
3646 31 bless $self => $class;
3647 31 ▶ $self->on_nonserialized($self->on_nonserialized || $self->serializer->on_nonserialized);
Condition66%2/3
$self->on_nonserialized || $self->serializer->on_nonserialized
l!l&&r!l&&!r
5260
MC/DC0%0/2
$self->on_nonserialized || $self->serializer->on_nonserialized
$self->on_nonserialized $self->serializer->on_nonserialized
Truth table66%2/3
A || B
A= $self->on_nonserializedB= $self->serializer->on_nonserialized
ABresult
1X1
011
000
3648 31 SOAP::Trace::objects('()');
3649 }
3650  
3651 31 ▶ Carp::carp "Odd (wrong?) number of parameters in new()" if $^W && (@_ & 1);
Branch: 1 branch
BranchTrueFalseTotal
if $^W and @_ & 1 0 31 31
Condition66%2/3
$^W and @_ & 1
!ll&&!rl&&r
3010
MC/DC0%0/2
$^W and @_ & 1
$^W @_ & 1
Truth table66%2/3
A and B
A= $^WB= @_ & 1
ABresult
0X0
100
111
3652 44 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
3653 31 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 6 31 37
3654 6 my($method, $params) = splice(@_,0,2);
3655 6 ▶ $self->can($method)
Branch: 2 branches
BranchTrueFalseTotal
$self->can($method) ? : 6 0 6
ref $params eq 'ARRAY' ? : 0 6 6
Condition0%0/3
$^W and Carp::carp("Unrecognized parameter '${method}' in new()")
!ll&&!rl&&r
000
MC/DC0%0/2
$^W and Carp::carp("Unrecognized parameter '${method}' in new()")
$^W Carp::carp("Unrecognized parameter '${method}' in new()")
Truth table0%0/3
A and B
A= $^WB= Carp::carp("Unrecognized parameter '${method}' in new()")
ABresult
0X0
100
111
3656 ? $self->$method(ref $params eq 'ARRAY' ? @$params : $params)
3657 : $^W && Carp::carp "Unrecognized parameter '$method' in new()"
3658 }
3659  
3660 31 return $self;
3661 }
3662  
3663 19 ▶sub init_context {
Subroutine init_context: called CC=1 SCAR=0.0
Pod undocumented
3664 19 my $self = shift->new;
3665 19 $self->{'_deserializer'}->{'_context'} = $self;
3666 # weaken circular reference to avoid a memory hole
3667 19 weaken $self->{'_deserializer'}->{'_context'};
3668  
3669 19 $self->{'_serializer'}->{'_context'} = $self;
3670 # weaken circular reference to avoid a memory hole
3671 19 weaken $self->{'_serializer'}->{'_context'};
3672 }
3673  
3674 # Naming? wsdl_parser
3675 2 ▶sub schema {
Subroutine schema: called CC=3 SCAR=11.6
Pod undocumented
3676 2 my $self = shift;
3677 2 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 2 2
3678 0 $self->{'_schema'} = shift;
3679 0 return $self;
3680 }
3681 else {
3682 2 ▶ if (!defined $self->{'_schema'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_schema"}) 1 1 2
3683 1 $self->{'_schema'} = SOAP::Schema->new;
3684 }
3685 2 return $self->{'_schema'};
3686 }
3687 }
3688  
3689 44 ▶sub BEGIN {
Subroutine BEGIN: called CC=6 SCAR=18.4
3690 44 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
3691 44 for my $method (qw(serializer deserializer)) {
3692 88 my $field = '_' . $method;
3693 83 ▶ *$method = sub {
Subroutine __ANON__: called CC=2 SCAR=9.9
3694 83 my $self = shift->new;
3695 83 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 83 83
3696 0 my $context = $self->{$field}->{'_context'}; # save the old context
3697 0 $self->{$field} = shift;
3698 0 $self->{$field}->{'_context'} = $context; # restore the old context
3699 0 return $self;
3700 }
3701 else {
3702 83 return $self->{$field};
3703 }
3704 }
3705 88 }
3706  
3707 __PACKAGE__->__mk_accessors(
3708 44 qw(endpoint transport outputxml autoresult packager)
3709 );
3710 # for my $method () {
3711 # my $field = '_' . $method;
3712 # *$method = sub {
3713 # my $self = shift->new;
3714 # @_ ? ($self->{$field} = shift, return $self) : return $self->{$field};
3715 # }
3716 # }
3717 44 for my $method (qw(on_action on_fault on_nonserialized)) {
3718 132 my $field = '_' . $method;
3719 122 ▶ *$method = sub {
Subroutine __ANON__: called CC=4 SCAR=14.0
3720 122 my $self = shift->new;
3721 122 ▶ return $self->{$field} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 75 47 122
3722 47 local $@;
3723 # commented out because that 'eval' was unsecure
3724 # > ref $_[0] eq 'CODE' ? shift : eval shift;
3725 # Am I paranoid enough?
3726 47 $self->{$field} = shift;
3727 47 ▶ Carp::croak $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 47 47
3728 Carp::croak "$method() expects subroutine (CODE) or string that evaluates into subroutine (CODE)"
3729 47 ▶ unless ref $self->{$field} eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self->{$field} eq "CODE" 0 47 47
3730 47 return $self;
3731 }
3732 132 }
3733 # SOAP::Transport Shortcuts
3734 # TODO - deprecate proxy() in favor of new language endpoint_url()
3735 44 ▶ no strict qw(refs);
Subroutine BEGIN: called CC=1 SCAR=0.0
3736 44 for my $method (qw(proxy)) {
3737 52 ▶ *$method = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
3738 52 my $self = shift->new;
3739 52 ▶ @_ ? ($self->transport->$method(@_), return $self) : return $self->transport->$method();
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 19 33 52
3740 }
3741 44 }
3742  
3743 # SOAP::Seriailizer Shortcuts
3744 44 for my $method (qw(autotype readable envprefix encodingStyle
3745 bodyattr headerattr
3746 encprefix multirefinplace encoding
3747 typelookup header maptype xmlschema
3748 uri ns_prefix ns_uri use_prefix use_default_ns
3749 ns default_ns)) {
3750 16 ▶ *$method = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
3751 16 my $self = shift->new;
3752 16 ▶ @_ ? ($self->serializer->$method(@_), return $self) : return $self->serializer->$method();
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 15 1 16
3753 }
3754 880 }
3755  
3756 # SOAP::Schema Shortcuts
3757 44 for my $method (qw(cache_dir cache_ttl)) {
3758 0 ▶ *$method = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
3759 0 my $self = shift->new;
3760 0 ▶ @_ ? ($self->schema->$method(@_), return $self) : return $self->schema->$method();
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
3761 }
3762 88 }
3763 }
3764  
3765 0 ▶sub parts {
Subroutine parts: not called CC=1 SCAR=6.9
Pod documented
3766 0 my $self = shift;
3767 0 $self->packager->parts(@_);
3768 0 return $self;
3769 }
3770  
3771 # Naming? wsdl
3772 1 ▶sub service {
Subroutine service: called CC=3 SCAR=11.1
Pod documented
3773 1 my $self = shift->new;
3774 1 ▶ return $self->{'_service'} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 1 1
3775 1 $self->schema->schema_url($self->{'_service'} = shift);
3776 1 my %services = %{$self->schema->parse(@_)->load->services};
3777  
3778 1 ▶ Carp::croak "More than one service in service description. Service and port names have to be specified\n"
Branch: 1 branch
BranchTrueFalseTotal
if keys %services > 1 0 1 1
3779 if keys %services > 1;
3780 1 my $service = (keys %services)[0]->new;
3781 1 return $service;
3782 }
3783  
3784 13 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=3 SCAR=11.9
3785 13 my $method = substr($AUTOLOAD, rindex($AUTOLOAD, '::') + 2);
3786 13 ▶ return if $method eq 'DESTROY';
Branch: 1 branch
BranchTrueFalseTotal
if $method eq "DESTROY" 0 13 13
3787  
3788 13 ▶ ref $_[0] or Carp::croak qq!Can\'t locate class method "$method" via package \"! . __PACKAGE__ .'\"';
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] or Carp::croak(qq[Can't locate class method "$method" via package "] . 'SOAP::Lite' . "\\\"") 13 0 13
3789  
3790 44 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
3791 13 ▶ *$AUTOLOAD = sub {
Subroutine __ANON__: called CC=4 SCAR=17.9
3792 13 my $self = shift;
3793 13 my $som = $self->call($method => @_);
3794 12 ▶ return $self->autoresult && UNIVERSAL::isa($som => 'SOAP::SOM')
Branch: 2 branches
BranchTrueFalseTotal
$self->autoresult && UNIVERSAL::isa($som, 'SOAP::SOM') ? : 0 12 12
wantarray ? : 0 0 0
Condition33%1/3
$self->autoresult and UNIVERSAL::isa($som, "SOAP::SOM")
!ll&&!rl&&r
1200
MC/DC0%0/2
$self->autoresult and UNIVERSAL::isa($som, "SOAP::SOM")
$self->autoresult UNIVERSAL::isa($som, "SOAP::SOM")
Truth table33%1/3
A and B
A= $self->autoresultB= UNIVERSAL::isa($som, "SOAP::SOM")
ABresult
0X0
100
111
3795 ? wantarray ? $som->paramsall : $som->result
3796 : $som;
3797 13 };
3798 13 goto &$AUTOLOAD;
3799 }
3800  
3801 17 ▶sub call {
Subroutine call: called CC=27 SCAR=51.8
Pod documented
3802 17 SOAP::Trace::trace('()');
3803 17 my $self = shift;
3804  
3805 17 ▶ die "A service address has not been specified either by using SOAP::Lite->proxy() or a service description)\n"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->proxy and UNIVERSAL::isa($self->proxy, "SOAP::Client") 1 16 17
Condition66%2/3
defined $self->proxy and UNIVERSAL::isa($self->proxy, "SOAP::Client")
!ll&&!rl&&r
1016
MC/DC50%1/2
defined $self->proxy and UNIVERSAL::isa($self->proxy, "SOAP::Client")
defined $self->proxy UNIVERSAL::isa($self->proxy, "SOAP::Client")
Truth table66%2/3
A and B
A= defined $self->proxyB= UNIVERSAL::isa($self->proxy, "SOAP::Client")
ABresult
0X0
100
111
3806 unless defined $self->proxy && UNIVERSAL::isa($self->proxy => 'SOAP::Client');
3807  
3808 16 $self->init_context();
3809  
3810 16 my $serializer = $self->serializer;
3811 16 $serializer->on_nonserialized($self->on_nonserialized);
3812  
3813 my $response = $self->transport->send_receive(
3814 context => $self, # this is provided for context
3815 endpoint => $self->endpoint,
3816 action => scalar($self->on_action->($serializer->uriformethod($_[0]))),
3817 # leave only parameters so we can later update them if required
3818 envelope => $serializer->envelope(method => shift, @_),
3819 encoding => $serializer->encoding,
3820 16 ▶ parts => @{$self->packager->parts} ? $self->packager->parts : undef,
Branch: 1 branch
BranchTrueFalseTotal
@{$self->packager->parts;} ? : 0 16 16
3821 );
3822  
3823 16 ▶ return $response if $self->outputxml;
Branch: 1 branch
BranchTrueFalseTotal
if $self->outputxml 0 16 16
3824  
3825 16 ▶ my $result = eval { $self->deserializer->deserialize($response) }
Branch: 1 branch
BranchTrueFalseTotal
if $response 16 0 16
3826 if $response;
3827  
3828 16 ▶ if (!$self->transport->is_success || # transport fault
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->transport->is_success or $@ or UNIVERSAL::isa($result, "SOAP::SOM") and $result->fault) 12 4 16
Condition55%5/9
not $self->transport->is_success or $@ or UNIVERSAL::isa($result, "SOAP::SOM") and $result->fault
l!l&&r!l&&!r
1204
not $self->transport->is_success or $@
l!l&&r!l&&!r
1204
UNIVERSAL::isa($result, "SOAP::SOM") and $result->fault
!ll&&!rl&&r
040
MC/DC25%1/4
not $self->transport->is_success or $@ or UNIVERSAL::isa($result, "SOAP::SOM") and $result->fault
not $self->transport->is_success $@ UNIVERSAL::isa($result, "SOAP::SOM") $result->fault
Truth table40%2/5
not(A) or B or C and D
A= not $self->transport->is_successB= $@C= UNIVERSAL::isa($result, "SOAP::SOM")D= $result->fault
ABCDresult
1XXX1
01XX1
00111
000X0
00100
3829 $@ || # not deserializible
3830 # fault message even if transport OK
3831 # or no transport error (for example, fo TCP, POP3, IO implementations)
3832 UNIVERSAL::isa($result => 'SOAP::SOM') && $result->fault) {
3833 12 ▶ return ($self->on_fault->($self, $@
Branch: 1 branch
BranchTrueFalseTotal
$@ ? : 11 1 12
Condition60%3/5
$self->on_fault->($self, $@ ? $@ . ($response || '') : $result) || $result
l!l&&r!l&&!r
1011
$response || ''
l!l
110
MC/DC50%1/2
$self->on_fault->($self, $@ ? $@ . ($response || '') : $result) || $result
$self->on_fault->($self, $@ ? $@ . ($response || '') : $result) $result
MC/DC0%0/1
$response || ''
$response
Truth table66%2/3
A || B
A= $self->on_fault->($self, $@ ? $@ . ($response || '') : $result)B= $result
ABresult
1X1
011
000
Truth table50%1/2
A
A= $response
Aresult
11
00
3834 ? $@ . ($response || '')
3835 : $result)
3836 || $result
3837 );
3838 # ? # trick editors
3839 }
3840 # this might be trouble for connection close...
3841 4 ▶ return unless $response; # nothing to do for one-ways
Branch: 1 branch
BranchTrueFalseTotal
unless $response 0 4 4
3842  
3843 # little bit tricky part that binds in/out parameters
3844 4 ▶ if (UNIVERSAL::isa($result => 'SOAP::SOM')
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($result, "SOAP::SOM") and $result->paramsout || $result->headers and $serializer->signature) 0 4 4
Condition33%3/9
UNIVERSAL::isa($result, "SOAP::SOM") and $result->paramsout || $result->headers and $serializer->signature
!ll&&!rl&&r
400
UNIVERSAL::isa($result, "SOAP::SOM") and $result->paramsout || $result->headers
!ll&&!rl&&r
040
$result->paramsout or $result->headers
l!l&&r!l&&!r
004
MC/DC0%0/4
UNIVERSAL::isa($result, "SOAP::SOM") and $result->paramsout || $result->headers and $serializer->signature
UNIVERSAL::isa($result, "SOAP::SOM") $result->paramsout $result->headers $serializer->signature
Truth table16%1/6
A and B or C and D
A= UNIVERSAL::isa($result, "SOAP::SOM")B= $result->paramsoutC= $result->headersD= $serializer->signature
ABCDresult
0XXX0
100X0
11X00
10100
11X11
10111
3845 && ($result->paramsout || $result->headers)
3846 && $serializer->signature) {
3847 0 my $num = 0;
3848 0 my %signatures = map {$_ => $num++} @{$serializer->signature};
3849 0 for ($result->dataof(SOAP::SOM::paramsout), $result->dataof(SOAP::SOM::headers)) {
3850 0 ▶ my $signature = join $;, $_->name, $_->type || '';
Condition0%0/2
$_->type || ''
l!l
00
MC/DC0%0/1
$_->type || ''
$_->type
Truth table0%0/2
A
A= $_->type
Aresult
11
00
3851 0 ▶ if (exists $signatures{$signature}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $signatures{$signature}) 0 0 0
3852 0 my $param = $signatures{$signature};
3853 0 my($value) = $_->value; # take first value
3854  
3855 # fillup parameters
3856 0 ▶ if ( reftype( $_[$param] ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::reftype($_[$param])) { } 0 0 0
3857 0 ▶ if ( reftype( $_[$param] ) eq 'SCALAR' ) {
Branch: 3 branches
BranchTrueFalseTotal
if (builtin::reftype($_[$param]) eq 'SCALAR') { } 0 0 0
elsif (builtin::reftype($_[$param]) eq 'ARRAY') { } 0 0 0
elsif (builtin::reftype($_[$param]) eq 'HASH') { } 0 0 0
3858 0 ${ $_[$param] } = $$value;
3859 }
3860 elsif ( reftype( $_[$param] ) eq 'ARRAY' ) {
3861 0 @{ $_[$param] } = @$value;
3862 }
3863 elsif ( reftype( $_[$param] ) eq 'HASH' ) {
3864 0 ▶ if ( eval { $_[$param]->isa('SOAP::Data') } ) {
Branch: 2 branches
BranchTrueFalseTotal
if (eval { do { $_[$param]->isa('SOAP::Data') } }) { } 0 0 0
elsif (builtin::reftype($value) eq 'REF') { } 0 0 0
3865 0 $_[$param]->SOAP::Data::value($value);
3866 }
3867 elsif ( reftype($value) eq 'REF' ) {
3868 0 %{ $_[$param] } = %$$value;
3869 }
3870 0 else { %{ $_[$param] } = %$value; }
3871 }
3872 0 else { $_[$param] = $value; }
3873 }
3874 else {
3875 0 $_[$param] = $value;
3876 }
3877 }
3878 }
3879 }
3880 4 return $result;
3881 } # end of call()
3882  
3883 # ======================================================================
3884  
3885 package SOAP::Lite::COM;
3886  
3887 44 require SOAP::Lite;
3888  
3889 0 ▶sub required {
Subroutine required: not called CC=2 SCAR=17.9
3890 0 foreach (qw(
3891 URI::_foreign URI::http URI::https
3892 LWP::Protocol::http LWP::Protocol::https LWP::Authen::Basic LWP::Authen::Digest
3893 HTTP::Daemon Compress::Zlib SOAP::Transport::HTTP
3894 XMLRPC::Lite XMLRPC::Transport::HTTP
3895 )) {
3896 0 eval join ';', 'local $SIG{__DIE__}', "require $_";
3897 }
3898 }
3899  
3900 0 ▶sub new { required; SOAP::Lite->new(@_) }
Subroutine new: not called CC=1 SCAR=6.9
3901  
3902 44 sub create; *create = \&new; # make alias. Somewhere 'new' is registered keyword
3903  
3904 44 sub soap; *soap = \&new; # also alias. Just to be consistent with .xmlrpc call
3905  
3906 0 ▶sub xmlrpc { required; XMLRPC::Lite->new(@_) }
Subroutine xmlrpc: not called CC=1 SCAR=6.9
3907  
3908 0 ▶sub server { required; shift->new(@_) }
Subroutine server: not called CC=1 SCAR=6.9
3909  
3910 0 ▶sub data { SOAP::Data->new(@_) }
Subroutine data: not called CC=1 SCAR=6.9
3911  
3912 0 ▶sub header { SOAP::Header->new(@_) }
Subroutine header: not called CC=1 SCAR=6.9
3913  
3914 0 ▶sub hash { +{@_} }
Subroutine hash: not called CC=1 SCAR=6.9
3915  
3916 0 ▶sub instanceof {
Subroutine instanceof: not called CC=2 SCAR=17.9
3917 0 my $class = shift;
3918 0 ▶ die "Incorrect class name" unless $class =~ /^(\w[\w:]*)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $class =~ /^(\w[\w:]*)$/ 0 0 0
3919 0 eval "require $class";
3920 0 $class->new(@_);
3921 }
3922  
3923 # ======================================================================
3924  
3925 44 1;
3926  
3927 __END__
« lib/SOAP/Lite/Packager.pm ↑ Summary lib/SOAP/Transport/TCP.pm »