File Coverage

blib/lib/SOAP/WSDL/XSD/Typelib/Builtin/string.pm
Criterion Covered Total %
statement 22 22 100.0
branch 2 2 100.0
condition 2 2 100.0
subroutine 7 7 100.0
pod 0 2 0.0
total 33 35 94.2


line stmt bran cond sub pod time code
1             package SOAP::WSDL::XSD::Typelib::Builtin::string;
2 50     50   1450 use strict;
  50         110  
  50         1731  
3 50     50   263 use warnings;
  50         171  
  50         1531  
4 50     50   2559 use Class::Std::Fast::Storable constructor => 'none', cache => 1;
  50         76971  
  50         490  
5 50     50   10940 use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
  50         244  
  50         28329  
6              
7             my %char2entity = (
8             q{&} => q{&},
9             q{<} => q{<},
10             q{>} => q{>},
11             q{"} => q{"},
12             q{'} => q{'},
13             );
14              
15             sub serialize {
16 9   100 9 0 1025 $_[1] ||= {};
17              
18 9         79 my $value = $_[0]->get_value();
19              
20 9 100       1460 return $_[0]->start_tag({ %{ $_[1] }, nil => 1})
  2         20  
21             if not defined $value;
22              
23             # HTML::Entities does the same - and more, thus it's around 1/3 slower...
24 7         91 $value =~ s{([&<>"'])}{$char2entity{$1}}xgmso;
25              
26 7         86 return join q{}, $_[0]->start_tag($_[1], $value)
27             #, encode_entities( $value, q{&<>"'} )
28             , $value
29             , $_[0]->end_tag($_[1]);
30             }
31              
32             sub as_bool :BOOLIFY {
33 15     15 0 3726 return $_[0]->get_value();
34 50     50   864 }
  50         101  
  50         493  
35              
36             Class::Std::initialize();
37             1;