blib/lib/XML/Atom/Base.pm

filter: Statementstmt 92.9% 211 / 227 Branchbran 74.3% 58 / 78 Conditioncond 63.6% 21 / 33 MC/DCmcdc 27.2% 6 / 22 Subroutinesub 95.1% 39 / 41 Podpod 0.0% 0 / 23 totaltotal 79.0% 335 / 424 SCAR 42.5
CC
60
Cov
86%
set
11.6
mk_elem_accessors
10.1
__ANON__
8.8
CRAP 70.3
« blib/lib/XML/Atom/Feed.pm ↑ Summary blib/lib/XML/Atom/Thing.pm »
1 # $Id$
2  
3 package XML::Atom::Base;
4 21 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 21 ▶use base qw( XML::Atom::ErrorHandler Class::Data::Inheritable );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 21 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 21 ▶use XML::Atom;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 21 ▶use XML::Atom::Util qw( set_ns first nodelist childlist create_element );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 21 __PACKAGE__->mk_classdata('__attributes', []);
12  
13 sub new {
14 169 ▶ my $class = shift;
Subroutine new: called CC=2 SCAR=7.0
Pod undocumented
15 169 my $obj = bless {}, $class;
16 169 ▶ $obj->init(@_) or return $class->error($obj->errstr);
Branch: 1 branch
BranchTrueFalseTotal
$obj->init(@_) or return $class->error($obj->errstr) 0 169 169
17 169 $obj;
18 }
19  
20 sub init {
21 169 ▶ my $obj = shift;
Subroutine init: called CC=8 SCAR=20.8
Pod undocumented
22 169 my %param = @_;
23 169 ▶ if (!exists $param{Namespace} and my $ns = $obj->element_ns) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $param{"Namespace"} and my $ns = $obj->element_ns) 3 166 169
Condition100%3/3
not exists $param{"Namespace"} and my $ns = $obj->element_ns
!ll&&!rl&&r
521143
MC/DC100%2/2
not exists $param{"Namespace"} and my $ns = $obj->element_ns
not exists $param{"Namespace"} my $ns = $obj->element_ns
Truth table100%3/3
not(A) and B
A= not exists $param{"Namespace"}B= my $ns = $obj->element_ns
ABresult
0X0
100
111
24 3 $param{Namespace} = $ns;
25 }
26 169 $obj->set_ns(\%param);
27 169 my $elem;
28 169 ▶ unless ($elem = $param{Elem}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($elem = $param{"Elem"}) 45 124 169
29 45 if (LIBXML) {
30 45 my $doc = XML::LibXML::Document->createDocument('1.0', 'UTF-8');
31 45 my $ns = $obj->ns;
32 45 my ($ns_uri, $ns_prefix);
33 45 ▶ if ( ref $ns and $ns->isa('XML::Atom::Namespace') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ns and $ns->isa('XML::Atom::Namespace')) { } 2 43 45
Condition66%2/3
ref $ns and $ns->isa("XML::Atom::Namespace")
!ll&&!rl&&r
4302
MC/DC50%1/2
ref $ns and $ns->isa("XML::Atom::Namespace")
ref $ns $ns->isa("XML::Atom::Namespace")
Truth table66%2/3
A and B
A= ref $nsB= $ns->isa("XML::Atom::Namespace")
ABresult
0X0
100
111
34 2 $ns_uri = $ns->{uri};
35 2 $ns_prefix = $ns->{prefix};
36 } else {
37 43 $ns_uri = $ns;
38 }
39 45 ▶ if ( $ns_uri and $ns_prefix ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ns_uri and $ns_prefix) { } 2 43 45
Condition66%2/3
$ns_uri and $ns_prefix
!ll&&!rl&&r
0432
MC/DC50%1/2
$ns_uri and $ns_prefix
$ns_uri $ns_prefix
Truth table66%2/3
A and B
A= $ns_uriB= $ns_prefix
ABresult
0X0
100
111
40 2 $elem = $doc->createElement($obj->element_name);
41 2 $elem->setNamespace( $ns_uri, $ns_prefix, 1 );
42 } else {
43 43 $elem = $doc->createElementNS($obj->ns, $obj->element_name);
44 }
45 45 $doc->setDocumentElement($elem);
46 } else {
47 $elem = XML::XPath::Node::Element->new($obj->element_name);
48 my $ns = XML::XPath::Node::Namespace->new('#default' => $obj->ns);
49 $elem->appendNamespace($ns);
50 }
51 }
52 169 $obj->{elem} = $elem;
53 169 $obj;
54 }
55  
56 ▶sub element_name { }
Subroutine element_name: not called CC=1 SCAR=0.0
Pod undocumented
57 ▶sub element_ns { }
Subroutine element_ns: called CC=1 SCAR=0.0
Pod undocumented
58  
59 281 ▶sub ns { $_[0]->{ns} }
Subroutine ns: called CC=1 SCAR=0.0
Pod undocumented
60 514 ▶sub elem { $_[0]->{elem} }
Subroutine elem: called CC=1 SCAR=0.0
Pod undocumented
61  
62 sub version {
63 68 ▶ my $atom = shift;
Subroutine version: called CC=1 SCAR=0.0
Pod undocumented
64 68 XML::Atom::Util::ns_to_version($atom->ns);
65 }
66  
67 sub content_type {
68 2 ▶ my $atom = shift;
Subroutine content_type: called CC=2 SCAR=6.9
Pod undocumented
69 2 ▶ if ($atom->version >= 1.0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($atom->version >= 1.0) { } 1 1 2
70 1 return "application/atom+xml";
71 } else {
72 1 return "application/x.atom+xml";
73 }
74 }
75  
76 sub get {
77 53 ▶ my $obj = shift;
Subroutine get: called CC=1 SCAR=0.0
Pod undocumented
78 53 my($ns, $name) = @_;
79 53 my @list = $obj->getlist($ns, $name);
80 53 return $list[0];
81 }
82  
83 sub getlist {
84 53 ▶ my $obj = shift;
Subroutine getlist: called CC=4 SCAR=13.9
Pod undocumented
85 53 my($ns, $name) = @_;
86 53 ▶ my $ns_uri = ref($ns) eq 'XML::Atom::Namespace' ? $ns->{uri} : $ns;
Branch: 1 branch
BranchTrueFalseTotal
ref $ns eq 'XML::Atom::Namespace' ? : 3 50 53
87 53 my @node = childlist($obj->elem, $ns_uri, $name);
88 return map {
89 53 my $val = LIBXML ? $_->textContent : $_->string_value;
90 53 ▶ if ($] >= 5.008) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] >= "5.008") 53 0 53
91 53 require Encode;
92 53 ▶ Encode::_utf8_off($val) unless $XML::Atom::ForceUnicode;
Branch: 1 branch
BranchTrueFalseTotal
unless $XML::Atom::ForceUnicode 53 0 53
93 }
94 53 $val;
95 } @node;
96 }
97  
98 sub add {
99 0 ▶ my $obj = shift;
Subroutine add: not called CC=1 SCAR=6.9
Pod undocumented
100 0 my($ns, $name, $val, $attr) = @_;
101 0 return $obj->set($ns, $name, $val, $attr, 1);
102 }
103  
104 sub set {
105 29 ▶ my $obj = shift;
Subroutine set: called CC=11 SCAR=24.5
Pod undocumented
106 29 my($ns, $name, $val, $attr, $add) = @_;
107 29 ▶ my $ns_uri = ref $ns eq 'XML::Atom::Namespace' ? $ns->{uri} : $ns;
Branch: 1 branch
BranchTrueFalseTotal
ref $ns eq 'XML::Atom::Namespace' ? : 3 26 29
108 29 my @elem = childlist($obj->elem, $ns_uri, $name);
109 29 ▶ if (!$add && @elem) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $add and @elem) 3 26 29
Condition66%2/3
not $add and @elem
!ll&&!rl&&r
0263
MC/DC50%1/2
not $add and @elem
not $add @elem
Truth table66%2/3
not(A) and B
A= not $addB= @elem
ABresult
0X0
100
111
110 3 $obj->elem->removeChild($_) for @elem;
111 }
112 29 my $elem = create_element($ns, $name);
113 29 ▶ if (UNIVERSAL::isa($val, 'XML::Atom::Base')) {
Branch: 1 branch
BranchTrueFalseTotal
if (UNIVERSAL::isa($val, 'XML::Atom::Base')) { } 10 19 29
114 10 if (LIBXML) {
115 10 for my $child ($val->elem->childNodes) {
116 10 $elem->appendChild($child->cloneNode(1));
117 }
118 10 for my $attr ($val->elem->attributes) {
119 17 ▶ next unless ref($attr) eq 'XML::LibXML::Attr';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $attr eq "XML::LibXML::Attr" 10 7 17
120 7 $elem->setAttribute($attr->getName, $attr->getValue);
121 }
122 } else {
123 for my $child ($val->elem->getChildNodes) {
124 $elem->appendChild($child);
125 }
126 for my $attr ($val->elem->getAttributes) {
127 $elem->appendAttribute($attr);
128 }
129 }
130 } elsif (DATETIME && UNIVERSAL::isa($val, "DateTime")) {
131 return $obj->set($ns, $name, DateTime::Format::Atom->format_datetime($val), $attr, $add);
132 } else {
133 19 if (LIBXML) {
134 19 $elem->appendChild(XML::LibXML::Text->new($val));
135 } else {
136 $elem->appendChild(XML::XPath::Node::Text->new($val));
137 }
138 }
139 29 $obj->elem->appendChild($elem);
140 29 ▶ if ($attr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($attr) 0 29 29
141 0 ▶ while (my($k, $v) = each %$attr) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$attr) 0 0 0
142 0 $elem->setAttribute($k, $v);
143 }
144 }
145 29 return $val;
146 }
147  
148 sub get_attr {
149 93 ▶ my $obj = shift;
Subroutine get_attr: called CC=3 SCAR=11.2
Pod undocumented
150 93 my($attr) = @_;
151 93 my $val = $obj->elem->getAttribute($attr);
152 93 ▶ if ($] >= 5.008) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] >= "5.008") 93 0 93
153 93 require Encode;
154 93 ▶ Encode::_utf8_off($val) unless $XML::Atom::ForceUnicode;
Branch: 1 branch
BranchTrueFalseTotal
unless $XML::Atom::ForceUnicode 93 0 93
155 }
156 93 $val;
157 }
158  
159 sub set_attr {
160 39 ▶ my $obj = shift;
Subroutine set_attr: called CC=3 SCAR=11.0
Pod undocumented
161 39 ▶ if (@_ == 2) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_ == 2) { } 38 1 39
elsif (@_ == 3) { } 1 0 1
162 38 my($attr, $val) = @_;
163 38 $obj->elem->setAttribute($attr => $val);
164 } elsif (@_ == 3) {
165 1 my($ns, $attr, $val) = @_;
166 1 my $attribute = "$ns->{prefix}:$attr";
167 1 if (LIBXML) {
168 1 $obj->elem->setAttributeNS($ns->{uri}, $attribute, $val);
169 } else {
170 my $ns = XML::XPath::Node::Namespace->new(
171 $ns->{prefix} => $ns->{uri}
172 );
173 $obj->elem->appendNamespace($ns);
174 $obj->elem->setAttribute($attribute => $val);
175 }
176 }
177 }
178  
179 sub get_object {
180 36 ▶ my $obj = shift;
Subroutine get_object: called CC=4 SCAR=13.9
Pod undocumented
181 36 my($ns, $name, $class) = @_;
182 36 ▶ my $ns_uri = ref($ns) eq 'XML::Atom::Namespace' ? $ns->{uri} : $ns;
Branch: 1 branch
BranchTrueFalseTotal
ref $ns eq 'XML::Atom::Namespace' ? : 1 35 36
183 36 ▶ my @elem = childlist($obj->elem, $ns_uri, $name) or return;
Branch: 1 branch
BranchTrueFalseTotal
my(@elem) = childlist($obj->elem, $ns_uri, $name) or return 0 36 36
184 36 my @obj = map { $class->new( Elem => $_, Namespace => $ns ) } @elem;
185 36 ▶ return wantarray ? @obj : $obj[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 11 25 36
186 }
187  
188 sub mk_elem_accessors {
189 92 ▶ my $class = shift;
Subroutine mk_elem_accessors: called CC=8 SCAR=23.1
Pod undocumented
190 92 my (@list) = @_;
191 92 my $override_ns;
192  
193 92 ▶ if ( ref $list[-1] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $list[-1]) 1 91 92
194 1 my $ns_list = pop @list;
195 1 ▶ if ( ref $ns_list eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ns_list eq "ARRAY") 1 0 1
196 1 $ns_list = $ns_list->[0];
197 }
198 1 ▶ if ( ref($ns_list) =~ /Namespace/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref($ns_list) =~ /Namespace/) { } 1 0 1
199 1 $override_ns = $ns_list;
200 } else {
201 0 ▶ if ( ref $ns_list eq 'HASH' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $ns_list eq 'HASH') { } 0 0 0
elsif (not ref $ns_list and $ns_list) { } 0 0 0
202 0 $override_ns = XML::Atom::Namespace->new(%$ns_list);
203 }
204 ▶ elsif ( not ref $ns_list and $ns_list ) {
Condition0%0/3
not ref $ns_list and $ns_list
!ll&&!rl&&r
000
MC/DC0%0/2
not ref $ns_list and $ns_list
not ref $ns_list $ns_list
Truth table0%0/3
not(A) and B
A= not ref $ns_listB= $ns_list
ABresult
0X0
100
111
205 0 $override_ns = $ns_list;
206 }
207 }
208 }
209  
210 21 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
211 92 for my $elem ( @list ) {
212 220 (my $meth = $elem) =~ tr/\-/_/;
213 220 *{"${class}::$meth"} = sub {
214 57 ▶ my $obj = shift;
Subroutine __ANON__: called CC=4 SCAR=14.0
215 57 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 18 39 57
216 18 ▶ return $obj->set( $override_ns || $obj->ns, $elem, $_[0]);
Condition66%2/3
$override_ns || $obj->ns
l!l&&r!l&&!r
3150
MC/DC0%0/2
$override_ns || $obj->ns
$override_ns $obj->ns
Truth table66%2/3
A || B
A= $override_nsB= $obj->ns
ABresult
1X1
011
000
217 } else {
218 39 ▶ return $obj->get( $override_ns || $obj->ns, $elem);
Condition66%2/3
$override_ns || $obj->ns
l!l&&r!l&&!r
3360
MC/DC0%0/2
$override_ns || $obj->ns
$override_ns $obj->ns
Truth table66%2/3
A || B
A= $override_nsB= $obj->ns
ABresult
1X1
011
000
219 }
220 220 };
221 }
222 }
223  
224 sub mk_attr_accessors {
225 59 ▶ my $class = shift;
Subroutine mk_attr_accessors: called CC=2 SCAR=6.9
Pod undocumented
226 59 my(@list) = @_;
227 21 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
228 59 for my $attr (@list) {
229 213 (my $meth = $attr) =~ tr/\-/_/;
230 213 *{"${class}::$meth"} = sub {
231 131 ▶ my $obj = shift;
Subroutine __ANON__: called CC=2 SCAR=6.9
232 131 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 38 93 131
233 38 return $obj->set_attr($attr => $_[0]);
234 } else {
235 93 return $obj->get_attr($attr);
236 }
237 213 };
238 213 $class->_add_attribute($attr);
239 }
240 }
241  
242 sub _add_attribute {
243 213 ▶ my($class, $attr) = @_;
Subroutine _add_attribute: called CC=1 SCAR=0.0
244 213 push @{$class->__attributes}, $attr;
245 }
246  
247 sub attributes {
248 4 ▶ my $class = shift;
Subroutine attributes: called CC=1 SCAR=0.0
Pod undocumented
249 4 @{ $class->__attributes };
250 }
251  
252 sub mk_xml_attr_accessors {
253 56 ▶ my($class, @list) = @_;
Subroutine mk_xml_attr_accessors: called CC=2 SCAR=6.9
Pod undocumented
254 21 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
255 56 for my $attr (@list) {
256 112 (my $meth = $attr) =~ tr/\-/_/;
257 112 *{"${class}::$meth"} = sub {
258 5 ▶ my $obj = shift;
Subroutine __ANON__: called CC=2 SCAR=6.9
259 5 if (LIBXML) {
260 5 my $elem = $obj->elem;
261 5 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 4 5
262 1 $elem->setAttributeNS('http://www.w3.org/XML/1998/namespace',
263 $attr, $_[0]);
264 }
265 5 return $elem->getAttribute("xml:$attr");
266 } else {
267 if (@_) {
268 $obj->elem->setAttribute("xml:$attr", $_[0]);
269 }
270 return $obj->elem->getAttribute("xml:$attr");
271 }
272 112 };
273 }
274 }
275  
276 sub mk_object_accessor {
277 92 ▶ my $class = shift;
Subroutine mk_object_accessor: called CC=1 SCAR=0.0
Pod undocumented
278 92 my($name, $ext_class) = @_;
279 21 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
280 92 (my $meth = $name) =~ tr/\-/_/;
281 92 *{"${class}::$meth"} = sub {
282 19 ▶ my $obj = shift;
Subroutine __ANON__: called CC=3 SCAR=11.0
283 19 ▶ my $ns_uri = $ext_class->element_ns || $obj->ns;
Condition66%2/3
$ext_class->element_ns || $obj->ns
l!l&&r!l&&!r
4150
MC/DC0%0/2
$ext_class->element_ns || $obj->ns
$ext_class->element_ns $obj->ns
Truth table66%2/3
A || B
A= $ext_class->element_nsB= $obj->ns
ABresult
1X1
011
000
284 19 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 3 16 19
285 3 return $obj->set($ns_uri, $name, $_[0]);
286 } else {
287 16 return $obj->get_object($ns_uri, $name, $ext_class);
288 }
289 92 };
290 }
291  
292  
293 sub mk_object_list_accessor {
294 74 ▶ my $class = shift;
Subroutine mk_object_list_accessor: called CC=2 SCAR=7.1
Pod undocumented
295 74 my($name, $ext_class, $moniker) = @_;
296  
297 21 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
298  
299 74 *{"$class\::$name"} = sub {
300 13 ▶ my $obj = shift;
Subroutine __ANON__: called CC=5 SCAR=21.7
301  
302 13 ▶ my $ns_uri = $ext_class->element_ns || $obj->ns;
Condition66%2/3
$ext_class->element_ns || $obj->ns
l!l&&r!l&&!r
1120
MC/DC0%0/2
$ext_class->element_ns || $obj->ns
$ext_class->element_ns $obj->ns
Truth table66%2/3
A || B
A= $ext_class->element_nsB= $obj->ns
ABresult
1X1
011
000
303 13 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 13 13
304 # setter: clear existent elements first
305 0 my @elem = childlist($obj->elem, $ns_uri, $name);
306 0 for my $el (@elem) {
307 0 $obj->elem->removeChild($el);
308 }
309  
310 # add the new elements for each
311 0 my $adder = "add_$name";
312 0 for my $add_elem (@_) {
313 0 $obj->$adder($add_elem);
314 }
315 } else {
316 # getter: just call get_object which is a context aware
317 13 return $obj->get_object($ns_uri, $name, $ext_class);
318 }
319 74 };
320  
321 # moniker returns always list: array ref in a scalar context
322 74 ▶ if ($moniker) {
Branch: 1 branch
BranchTrueFalseTotal
if ($moniker) 72 2 74
323 72 *{"$class\::$moniker"} = sub {
324 4 ▶ my $obj = shift;
Subroutine __ANON__: called CC=3 SCAR=12.0
325 4 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 4 4
326 0 return $obj->$name(@_);
327 } else {
328 4 my @obj = $obj->$name;
329 4 ▶ return wantarray ? @obj : \@obj;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 4 0 4
330 }
331 72 };
332 }
333  
334 # add_$name
335 74 *{"$class\::add_$name"} = sub {
336 8 ▶ my $obj = shift;
Subroutine __ANON__: called CC=7 SCAR=19.5
337 8 my($stuff) = @_;
338  
339 8 ▶ my $ns_uri = $ext_class->element_ns || $obj->ns;
Condition66%2/3
$ext_class->element_ns || $obj->ns
l!l&&r!l&&!r
260
MC/DC0%0/2
$ext_class->element_ns || $obj->ns
$ext_class->element_ns $obj->ns
Truth table66%2/3
A || B
A= $ext_class->element_nsB= $obj->ns
ABresult
1X1
011
000
340 8 ▶ my $elem = (ref $stuff && UNIVERSAL::isa($stuff, $ext_class)) ?
Branch: 1 branch
BranchTrueFalseTotal
ref $stuff && UNIVERSAL::isa($stuff, $ext_class) ? : 4 4 8
Condition66%2/3
ref $stuff and UNIVERSAL::isa($stuff, $ext_class)
!ll&&!rl&&r
044
MC/DC50%1/2
ref $stuff and UNIVERSAL::isa($stuff, $ext_class)
ref $stuff UNIVERSAL::isa($stuff, $ext_class)
Truth table66%2/3
A and B
A= ref $stuffB= UNIVERSAL::isa($stuff, $ext_class)
ABresult
0X0
100
111
341 $stuff->elem : create_element($ns_uri, $name);
342 8 $obj->elem->appendChild($elem);
343  
344 8 ▶ if (ref($stuff) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $stuff eq "HASH") 4 4 8
345 4 for my $k ( $ext_class->attributes ) {
346 44 ▶ defined $stuff->{$k} or next;
Branch: 1 branch
BranchTrueFalseTotal
defined $stuff->{$k} or next 33 11 44
347 11 $elem->setAttribute($k, $stuff->{$k});
348 }
349 }
350 74 };
351 }
352  
353 sub as_xml {
354 20 ▶ my $obj = shift;
Subroutine as_xml: called CC=1 SCAR=0.0
Pod undocumented
355 20 if (LIBXML) {
356 20 my $doc = XML::LibXML::Document->new('1.0', 'UTF-8');
357 20 $doc->setDocumentElement($obj->elem->cloneNode(1));
358 20 return $doc->toString(1);
359 } else {
360 return '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
361 $obj->elem->toString;
362 }
363 }
364  
365 sub as_xml_utf8 {
366 1 ▶ my $obj = shift;
Subroutine as_xml_utf8: called CC=2 SCAR=7.4
Pod undocumented
367 1 my $xml = $obj->as_xml;
368 1 ▶ if (utf8::is_utf8($xml)) {
Branch: 1 branch
BranchTrueFalseTotal
if (utf8::is_utf8($xml)) 0 1 1
369 0 return Encode::encode_utf8($xml);
370 }
371 1 return $xml;
372 }
373  
374 21 1;
« blib/lib/XML/Atom/Feed.pm ↑ Summary blib/lib/XML/Atom/Thing.pm »