VMOMI/PrimitiveType.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 38 CC 2 SCAR 11.0
CC
2
Cov
0%
val
6.0
new
2.0
serialize
2.0
CRAP 3.0
1 package VMOMI::PrimitiveType;
2  
3 use strict;
4 use warnings;
5  
6 use Encode qw(decode_utf8 encode_utf8);
7  
8 use constant P5NS => 'VMOMI';
9  
10 sub new {
11 my ($class, $val, $type) = @_;
12 my $self = { val => $val, type => $type };
13 return bless $self, $class;
14 }
15  
16 sub serialize {
17 my ($self, $tag) = @_;
18 my ($node, $value, $xsd_type);
19
20 $xsd_type = "xsd:" . $self->{'type'};
21 $node = new XML::LibXML::Element($tag);
22 $node->setAttribute('xsi:type', $xsd_type);
23
24 $value = encode_utf8($self->{'val'});
25 $node->appendText($value);
26
27 return $node;
28 }
29  
30 sub val {
31 my $self = shift;
32 $self->{'val'} = shift if @_;
33 return $self->{'val'};
34 }
35  
36 1;