PRANG/Graph/Element.pm

filter: Statementstmt 79.0% 128 / 162 Branchbran 70.0% 63 / 90 Conditioncond 60.6% 37 / 61 MC/DCmcdc 42.4% 14 / 33 Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 5 totaltotal 69.8% 253 / 362 CC 71 SCAR 38.7
CC
71
Cov
73%
output
90.9
accept
24.7
node_ok
18.0
CRAP 48.1
« PRANG/Graph/Meta/Element.pm ↑ Summary PRANG/Marshaller.pm »
1  
2 package PRANG::Graph::Element;
3 11 $PRANG::Graph::Element::VERSION = '0.21';
4 11 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 11 ▶use MooseX::Params::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 11 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 11 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
11 11 class_type "XML::LibXML::Node";
12 11 class_type "XML::LibXML::Element";
13 }
14  
15 11 has 'xmlns' =>
16 is => "ro",
17 isa => "Str",
18 predicate => "has_xmlns",
19 ;
20  
21 11 has 'nodeName' =>
22 is => "ro",
23 isa => "Str",
24 required => 1,
25 ;
26  
27 11 has 'nodeClass' =>
28 is => "ro",
29 isa => "Str",
30 predicate => "has_nodeClass",
31 ;
32  
33 11 has 'nodeName_attr' =>
34 is => "rw",
35 isa => "Str",
36 predicate => "has_nodeName_attr",
37 ;
38  
39 11 has 'xmlns_attr' =>
40 is => "rw",
41 isa => "Str",
42 predicate => "has_xmlns_attr",
43 ;
44  
45 11 has 'attrName' =>
46 is => "ro",
47 isa => "Str",
48 required => 1,
49 ;
50  
51 11 has 'contents' =>
52 is => "rw",
53 isa => "PRANG::Graph::Node",
54 predicate => "has_contents",
55 ;
56  
57 1230 ▶sub node_ok {
Subroutine node_ok: called CC=18 SCAR=28.9
Pod undocumented
58 1230 my $self = shift;
59 1230 my ( $node, $ctx ) = pos_validated_list(
60 \@_,
61 { isa => 'XML::LibXML::Node' },
62 { isa => 'PRANG::Graph::Context' },
63 );
64
65 1230 ▶ return unless $node->nodeType == XML_ELEMENT_NODE;
Branch: 1 branch
BranchTrueFalseTotal
unless $node->nodeType == 1 105 1125 1230
66 1125 my $got_xmlns;
67  
68 1125 ▶ if ($self->has_xmlns
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_xmlns or ($node->prefix || "") ne ($ctx->prefix || "")) 351 774 1125
Condition100%7/7
$self->has_xmlns or ($node->prefix || "") ne ($ctx->prefix || "")
l!l&&r!l&&!r
169182774
$node->prefix || ''
l!l
125831
$ctx->prefix || ''
l!l
213743
MC/DC100%2/2
$self->has_xmlns or ($node->prefix || "") ne ($ctx->prefix || "")
$self->has_xmlns $node->prefix
MC/DC100%1/1
$ctx->prefix || ''
$ctx->prefix
Truth table100%3/3
A or B
A= $self->has_xmlnsB= $node->prefix
ABresult
1X1
011
000
Truth table100%2/2
A
A= $ctx->prefix
Aresult
11
00
69 or
70 ($node->prefix||"") ne ($ctx->prefix||"")
71 )
72 351 ▶ { my $prefix = $node->prefix//"";
Condition100%2/2
$node->prefix // ""
l!l
172179
MC/DC100%1/1
$node->prefix // ""
$node->prefix
Truth table100%2/2
A
A= $node->prefix
Aresult
11
00
73 351 $got_xmlns = $ctx->xsi->{$prefix};
74 351 ▶ if ( !defined $got_xmlns ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $got_xmlns) 12 339 351
75 12 ▶ $got_xmlns = $node->getAttribute(
Branch: 1 branch
BranchTrueFalseTotal
length $prefix ? : 12 0 12
76 "xmlns".(length $prefix?":$prefix":"")
77 );
78 }
79 351 ▶ my $wanted_xmlns = ($self->xmlns||"");
Condition100%2/2
$self->xmlns || ''
l!l
169182
MC/DC100%1/1
$self->xmlns || ''
$self->xmlns
Truth table100%2/2
A
A= $self->xmlns
Aresult
11
00
80 351 ▶ if ($got_xmlns
Branch: 1 branch
BranchTrueFalseTotal
if ($got_xmlns and $wanted_xmlns ne "*" and $got_xmlns ne $wanted_xmlns) 77 274 351
Condition100%6/6
$got_xmlns and $wanted_xmlns ne "*" and $got_xmlns ne $wanted_xmlns
!ll&&!rl&&r
2066877
$got_xmlns and $wanted_xmlns ne "*"
!ll&&!rl&&r
17927145
MC/DC100%3/3
$got_xmlns and $wanted_xmlns ne "*" and $got_xmlns ne $wanted_xmlns
$got_xmlns $wanted_xmlns ne "*" $got_xmlns ne $wanted_xmlns
Truth table100%4/4
A and B and C
A= $got_xmlnsB= $wanted_xmlns ne "*"C= $got_xmlns ne $wanted_xmlns
ABCresult
0XX0
10X0
1100
1111
81 and $wanted_xmlns ne "*"
82 and
83 $got_xmlns ne $wanted_xmlns
84 )
85 77 { return;
86 }
87 }
88 1048 my ($ret_nodeName, $ret_xmlns) = ("", "");
89 1048 my $wanted_nodeName = $self->nodeName;
90 1048 ▶ if ($wanted_nodeName ne "*"
Branch: 1 branch
BranchTrueFalseTotal
if ($wanted_nodeName ne "*" and $wanted_nodeName ne $node->localname) 326 722 1048
Condition100%3/3
$wanted_nodeName ne "*" and $wanted_nodeName ne $node->localname
!ll&&!rl&&r
74648326
MC/DC100%2/2
$wanted_nodeName ne "*" and $wanted_nodeName ne $node->localname
$wanted_nodeName ne "*" $wanted_nodeName ne $node->localname
Truth table100%3/3
A and B
A= $wanted_nodeName ne "*"B= $wanted_nodeName ne $node->localname
ABresult
0X0
100
111
91 and $wanted_nodeName ne $node->localname
92 )
93 326 { return;
94 }
95 722 ▶ if ( $self->has_nodeName_attr ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_nodeName_attr) 86 636 722
96 86 $ret_nodeName = $node->localname;
97 }
98 722 ▶ if ( $self->has_xmlns_attr ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_xmlns_attr) 63 659 722
99 63 $ret_xmlns = $got_xmlns;
100 }
101 722 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 371 351 722
102 371 return ($ret_nodeName, $ret_xmlns);
103 }
104 else {
105 351 return $ret_nodeName;
106 }
107 }
108  
109 371 ▶sub accept {
Subroutine accept: called CC=16 SCAR=32.1
Pod undocumented
110 371 my $self = shift;
111 371 my ( $node, $ctx, $lax ) = pos_validated_list(
112 \@_,
113 { isa => 'XML::LibXML::Node' },
114 { isa => 'PRANG::Graph::Context' },
115 { isa => 'Bool', optional => 1 },
116 );
117
118 371 my ($ret_nodeName, $xmlns) = $self->node_ok($node, $ctx);
119 371 ▶ if ( !defined $ret_nodeName ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ret_nodeName) 0 371 371
120  
121 # ok, not right, so figure out what we did want, in
122 # the context of the incoming document.
123 0 ▶ my $wanted_xmlns = ($self->xmlns||"");
Condition0%0/2
$self->xmlns || ''
l!l
00
MC/DC0%0/1
$self->xmlns || ''
$self->xmlns
Truth table0%0/2
A
A= $self->xmlns
Aresult
11
00
124 0 my $wanted_prefix = $ctx->get_prefix($wanted_xmlns);
125  
126 0 my $nodeName = $self->nodeName;
127 0 ▶ if ( $wanted_prefix ne "" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wanted_prefix ne "") 0 0 0
128 0 $nodeName = "$wanted_prefix:$nodeName";
129 0 ▶ if ( $ctx->prefix_new($wanted_prefix) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ctx->prefix_new($wanted_prefix)) 0 0 0
130 0 $nodeName .= " xmlns:$wanted_prefix="
131 ."\"$wanted_xmlns\"";
132 }
133 }
134 $ctx->exception(
135 0 "invalid element; expected '$nodeName'",
136 $node, 1,
137 );
138 }
139 371 ▶ undef($ret_nodeName) if !length($ret_nodeName);
Branch: 1 branch
BranchTrueFalseTotal
unless length $ret_nodeName 338 33 371
140 371 ▶ if ( $self->has_nodeClass ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_nodeClass) { } 189 182 371
141  
142 # general nested XML support
143 189 my $marshaller = $ctx->base->get($self->nodeClass);
144 189 ▶ my $value = (
Branch: 1 branch
BranchTrueFalseTotal
$marshaller ? : 189 0 189
145 $marshaller
146 ? $marshaller->marshall_in_element(
147 $node,
148 $ctx,
149 $lax,
150 )
151 : $node
152 );
153 171 $ctx->element_ok(1);
154 171 return ($self->attrName => $value, $ret_nodeName, $xmlns);
155 }
156 else {
157  
158 # XML data types
159 182 ▶ my $type = $self->has_contents
Branch: 1 branch
BranchTrueFalseTotal
$self->has_contents ? : 174 8 182
160 ?
161 "XML data"
162 : "presence-only";
163 182 ▶ if ($node->hasAttributes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->hasAttributes) 2 180 182
164 2 $ctx->exception(
165 "Superfluous attributes on $type node",
166 $node
167 );
168 }
169 180 ▶ if ( $self->has_contents ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_contents) { } 173 7 180
170  
171 # simple types, eg Int, Str
172 my (@childNodes) = grep {
173 173 ▶ !( $_->isa("XML::LibXML::Comment")
Condition33%2/6
$_->isa('XML::LibXML::Comment') || $_->isa('XML::LibXML::Text') && $_->data =~ /\A\s+\Z/
l!l&&r!l&&!r
00107
$_->isa("XML::LibXML::Text") and $_->data =~ /\A\s+\Z/
!ll&&!rl&&r
01070
MC/DC0%0/3
$_->isa('XML::LibXML::Comment') || $_->isa('XML::LibXML::Text') && $_->data =~ /\A\s+\Z/
$_->isa('XML::LibXML::Comment') $_->isa("XML::LibXML::Text") $_->data =~ /\A\s+\Z/
Truth table25%1/4
A || B and C
A= $_->isa('XML::LibXML::Comment')B= $_->isa("XML::LibXML::Text")C= $_->data =~ /\A\s+\Z/
ABCresult
1XX1
0111
00X0
0100
174 or
175 $_->isa("XML::LibXML::Text")
176 and $_->data =~ /\A\s+\Z/
177 )
178 } $node->childNodes;
179  
180 173 ▶ if ( @childNodes > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@childNodes > 1) 0 173 173
181  
182 # we could maybe merge CDATA nodes...
183 0 $ctx->exception(
184 "Too many child nodes for $type node",
185 $node,
186 );
187 }
188 173 my $value;
189 173 ▶ if ( !@childNodes ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @childNodes) { } 66 107 173
190 66 $value = "";
191 }
192 else {
193 107 (undef, $value) = $self->contents->accept(
194 $childNodes[0],
195 $ctx,
196 $lax,
197 );
198 }
199 173 $ctx->element_ok(1);
200 173 return ($self->attrName => $value, $ret_nodeName, $xmlns);
201 }
202 else {
203  
204 # boolean
205 7 ▶ if ( $node->hasChildNodes ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->hasChildNodes) 1 6 7
206 1 $ctx->exception(
207 "Superfluous child nodes on $type node",
208 $node,
209 );
210 }
211 6 $ctx->element_ok(1);
212 6 return ($self->attrName => 1, $ret_nodeName, $xmlns);
213 }
214 }
215 }
216  
217 16 ▶sub complete {
Subroutine complete: called CC=1 SCAR=0.0
Pod undocumented
218 16 my $self = shift;
219 16 my ( $ctx ) = pos_validated_list(
220 \@_,
221 { isa => 'PRANG::Graph::Context' },
222 );
223
224 16 $ctx->element_ok;
225 }
226  
227 11 ▶sub expected {
Subroutine expected: called CC=6 SCAR=25.8
Pod undocumented
228 11 my $self = shift;
229 11 my ( $ctx ) = pos_validated_list(
230 \@_,
231 { isa => 'PRANG::Graph::Context' },
232 );
233
234 11 my $prefix = "";
235 11 my $nodename = $self->nodeName;
236 11 ▶ if ( $self->has_xmlns ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_xmlns) 0 11 11
237 0 ▶ my $xmlns = eval { $self->nodeClass->xmlns } ||
Condition0%0/3
eval { do { $self->nodeClass->xmlns } } || $self->xmlns
l!l&&r!l&&!r
000
MC/DC0%0/2
eval { do { $self->nodeClass->xmlns } } || $self->xmlns
eval { do { $self->nodeClass->xmlns } } $self->xmlns
Truth table0%0/3
A || B
A= eval { do { $self->nodeClass->xmlns } }B= $self->xmlns
ABresult
1X1
011
000
238 $self->xmlns;
239 0 ▶ if ( $prefix = $ctx->rxsi->{$xmlns} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prefix = $ctx->rxsi->{$xmlns}) { } 0 0 0
240 0 $prefix .= ":";
241 }
242 else {
243 0 $prefix = $ctx->get_prefix($xmlns);
244 0 $nodename .= " xmlns:$prefix='$xmlns'";
245 0 $prefix .= ":";
246 }
247 }
248 11 ▶ return "<$prefix$nodename".(
Branch: 2 branches
BranchTrueFalseTotal
$self->has_nodeClass ? : 4 7 11
$self->has_contents ? : 7 0 7
249 $self->has_nodeClass
250 ?"..."
251 :
252 $self->has_contents?"":"/"
253 )
254 .">";
255 }
256  
257 224 ▶sub output {
Subroutine output: called CC=34 SCAR=45.1
Pod undocumented
258 224 my $self = shift;
259
260 # First 3 args positional, rest are named
261 # Because we're making 2 validation calls, we have to use different cache keys
262 224 my ( $item, $node, $ctx ) = pos_validated_list(
263 [@_[0..2]],
264 { isa => 'Object' },
265 { isa => 'XML::LibXML::Element' },
266 { isa => 'PRANG::Graph::Context' },
267 MX_PARAMS_VALIDATE_CACHE_KEY => 'element-output-positional',
268 );
269
270 224 my ( $value, $slot, $name, $xmlns ) = validated_list(
271 [@_[3..$#_]],
272 value => { isa => 'Item', optional => 1 },
273 slot => { isa => 'Int', optional => 1 },
274 name => { isa => 'Str', optional => 1 },
275 xmlns => { isa => 'Str', optional => 1 },
276 MX_PARAMS_VALIDATE_CACHE_KEY => 'element-output-named',
277 );
278
279
280 224 ▶ $value //= do {
Condition100%3/3
$value //= do { my $accessor = $self->attrName; $item->$accessor }
l!l&&r!l&&!r
159641
MC/DC100%2/2
$value //= do { my $accessor = $self->attrName; $item->$accessor }
$value do { my $accessor = $self->attrName; $item->$accessor }
Truth table100%3/3
A //= B
A= $valueB= do { my $accessor = $self->attrName; $item->$accessor }
ABresult
1X1
011
000
281 65 my $accessor = $self->attrName;
282 65 $item->$accessor;
283 };
284 224 ▶ if ( ref $value and ref $value eq "ARRAY" and defined $slot ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value and ref $value eq "ARRAY" and defined $slot) 0 224 224
Condition50%3/6
ref $value and ref $value eq "ARRAY" and defined $slot
!ll&&!rl&&r
22400
ref $value and ref $value eq "ARRAY"
!ll&&!rl&&r
1211030
MC/DC0%0/3
ref $value and ref $value eq "ARRAY" and defined $slot
ref $value ref $value eq "ARRAY" defined $slot
Truth table50%2/4
A and B and C
A= ref $valueB= ref $value eq "ARRAY"C= defined $slot
ABCresult
0XX0
10X0
1100
1111
285 0 $value = $value->[$slot];
286 }
287 224 ▶ $name //= do {
Condition66%2/3
$name //= do { if ($self->has_nodeName_attr) { my $attr = $self->nodeName_attr; $item->$attr; } else { $self->nodeName; } }
l!l&&r!l&&!r
531710
MC/DC0%0/2
$name //= do { if ($self->has_nodeName_attr) { my $attr = $self->nodeName_attr; $item->$attr; } else { $self->nodeName; } }
$name do { if ($self->has_nodeName_attr) { my $attr = $self->nodeName_attr; $item->$attr; } else { $self->nodeName; } }
Truth table66%2/3
A //= B
A= $nameB= do { if ($self->has_nodeName_attr) { my $attr = $self->nodeName_attr; $item->$attr; } else { $self->nodeName; } }
ABresult
1X1
011
000
288 171 ▶ if ( $self->has_nodeName_attr ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_nodeName_attr) { } 4 167 171
289 4 my $attr = $self->nodeName_attr;
290 4 $item->$attr;
291 }
292 else {
293 167 $self->nodeName;
294 }
295 };
296 224 ▶ $xmlns //= do {
Condition66%2/3
$xmlns //= do { if ($self->has_xmlns_attr) { my $attr = $self->xmlns_attr; $item->$attr; } else { $self->xmlns // ""; } }
l!l&&r!l&&!r
182060
MC/DC0%0/2
$xmlns //= do { if ($self->has_xmlns_attr) { my $attr = $self->xmlns_attr; $item->$attr; } else { $self->xmlns // ""; } }
$xmlns do { if ($self->has_xmlns_attr) { my $attr = $self->xmlns_attr; $item->$attr; } else { $self->xmlns // ""; } }
Truth table66%2/3
A //= B
A= $xmlnsB= do { if ($self->has_xmlns_attr) { my $attr = $self->xmlns_attr; $item->$attr; } else { $self->xmlns // ""; } }
ABresult
1X1
011
000
297 206 ▶ if ( $self->has_xmlns_attr ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_xmlns_attr) { } 0 206 206
298 0 my $attr = $self->xmlns_attr;
299 0 $item->$attr;
300 }
301 else {
302 206 ▶ $self->xmlns // "";
Condition100%2/2
$self->xmlns // ""
l!l
6200
MC/DC100%1/1
$self->xmlns // ""
$self->xmlns
Truth table100%2/2
A
A= $self->xmlns
Aresult
11
00
303 }
304 };
305 224 ▶ if ( ref $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $name) 4 220 224
306 4 $name = $name->[$slot];
307 }
308 224 ▶ if ( ref $xmlns ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $xmlns) 0 224 224
309 0 $xmlns = $xmlns->[$slot];
310 }
311  
312 224 my $nn;
313 224 my $doc = $node->ownerDocument;
314 224 my $newctx;
315 224 ▶ if ( length $name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $name) { } 224 0 224
316 224 my ($prefix, $new_prefix);
317 224 $ctx = $ctx->next_ctx( $xmlns, $name, $value );
318 224 $prefix = $ctx->prefix;
319 224 ▶ my $new_nodeName = ($prefix ? "$prefix:" : "") . $name;
Branch: 1 branch
BranchTrueFalseTotal
$prefix ? : 41 183 224
320 224 $nn = $doc->createElement($new_nodeName);
321 224 ▶ if ( $ctx->prefix_new($prefix) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ctx->prefix_new($prefix)) 15 209 224
322 15 ▶ $nn->setAttribute(
Branch: 1 branch
BranchTrueFalseTotal
$prefix ? : 15 0 15
323 "xmlns".($prefix?":$prefix":""),
324 $xmlns,
325 );
326 }
327 224 $node->appendChild($nn);
328  
329 # now proceed with contents...
330 224 ▶ if ( my $class = $self->nodeClass ) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $class = $self->nodeClass) { } 104 120 224
elsif ($self->has_contents and defined $value) { } 115 10 125
331 104 my $m;
332 104 ▶ if ( !defined $value ) {
Branch: 4 branches
BranchTrueFalseTotal
if (not defined $value) { } 1 103 104
elsif (eval { do { $value->isa($class) } }) { } 101 2 103
elsif (eval { do { $value->isa('XML::LibXML::Element') } }) { } 0 2 2
elsif (builtin::blessed($value)) { } 2 0 2
333 1 $ctx->exception("required element not set");
334 }
335 103 elsif ( eval { $value->isa($class) }) {
336 101 $m = $ctx->base->get($class);
337 }
338 2 elsif ( eval{$value->isa("XML::LibXML::Element")} ) {
339 0 ▶ if ($value->localname eq $nn->localname
Branch: 1 branch
BranchTrueFalseTotal
if ($value->localname eq $nn->localname and ($value->namespaceURI || '') eq ($xmlns || '')) { } 0 0 0
Condition0%0/7
$value->localname eq $nn->localname and ($value->namespaceURI || "") eq ($xmlns || "")
!ll&&!rl&&r
000
$value->namespaceURI || ''
l!l
00
$xmlns || ''
l!l
00
MC/DC0%0/2
$value->localname eq $nn->localname and ($value->namespaceURI || "") eq ($xmlns || "")
$value->localname eq $nn->localname $value->namespaceURI
MC/DC0%0/1
$xmlns || ''
$xmlns
Truth table0%0/3
A and B
A= $value->localname eq $nn->localnameB= $value->namespaceURI
ABresult
0X0
100
111
Truth table0%0/2
A
A= $xmlns
Aresult
11
00
340 and
341 ($value->namespaceURI||"") eq
342 ($xmlns||"")
343 )
344 0 { my $nn2 = $value->cloneNode(1);
345 0 $node->appendChild($nn2);
346 0 $node->removeChild($nn);
347 }
348 else {
349  
350 # it's just not safe to set
351 # the nodeName after the fact,
352 # so copy the children across.
353 0 for my $att ( $value->attributes ) {
354 0 ▶ next if $att->isa("XML::LibXML::Namespace");
Branch: 1 branch
BranchTrueFalseTotal
if $att->isa("XML::LibXML::Namespace") 0 0 0
355 0 $nn->setAttribute(
356 $att->localname,
357 $att->value,
358 );
359 }
360 0 for my $child ( $value->childNodes ) {
361 0 my $nn2 = $child->cloneNode(1);
362 0 $nn->appendChild($nn2);
363 }
364 }
365 0 $m = "ok";
366 }
367 elsif ( blessed $value ) {
368  
369 # this actually indicates a type
370 # error. currently it is required for
371 # the Whatever mapping.
372 2 $m = PRANG::Marshaller->get(ref $value);
373 }
374  
375 103 ▶ if ( $m and blessed $m ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($m and builtin::blessed($m)) { } 103 0 103
elsif ($m) { } 0 0 0
Condition33%1/3
$m and builtin::blessed($m)
!ll&&!rl&&r
00103
MC/DC0%0/2
$m and builtin::blessed($m)
$m builtin::blessed($m)
Truth table33%1/3
A and B
A= $mB= builtin::blessed($m)
ABresult
0X0
100
111
376 103 ▶ $ctx->exception(
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) 0 103 103
377 "tried to serialize unblessed value $value"
378 )
379 if !blessed $value;
380 103 $m->to_libxml($value, $nn, $ctx);
381 }
382 elsif ($m) {
383  
384 # allow value-based code above to drop through
385 }
386 else {
387 0 $ctx->exception("no marshaller for '$value'");
388 }
389 }
390 ▶ elsif ( $self->has_contents and defined $value ) {
Condition66%2/3
$self->has_contents and defined $value
!ll&&!rl&&r
50115
MC/DC50%1/2
$self->has_contents and defined $value
$self->has_contents defined $value
Truth table66%2/3
A and B
A= $self->has_contentsB= defined $value
ABresult
0X0
100
111
391 115 my $tn = $self->createTextNode($doc, $value);
392 115 $nn->appendChild($tn);
393 }
394 }
395 else {
396 0 $nn = $self->createTextNode($doc, $value);
397 0 $node->appendChild($nn);
398 }
399 }
400  
401 11 with 'PRANG::Graph::Node';
402  
403 11 1;
404  
405 __END__
« PRANG/Graph/Meta/Element.pm ↑ Summary PRANG/Marshaller.pm »