ProfitBricks/Serializer/xml.pm

filter: Statementstmt 54.0% 20 / 37 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 1 totaltotal 41.2% 26 / 63 CC 9 SCAR 40.0
CC
9
Cov
39%
serialize
90.0
BEGIN
1.0
BEGIN
1.0
CRAP 54.4
↑ Summary ProfitBricks/Connection.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4 # vim: set ts=3 sw=3 tw=0:
5 # vim: set expandtab:
6  
7 =head1 NAME
8  
9 WebService::ProfitBricks::Serializer::xml - Special Serializer
10  
11 =head1 DESCRIPTION
12  
13 Special serializer for some call to the ProfitBricks API.
14  
15 =cut
16  
17 package WebService::ProfitBricks::Serializer::xml;
18  
19 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use WebService::ProfitBricks::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 1 ▶use WebService::ProfitBricks::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶use base qw(WebService::ProfitBricks);
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 1 attr qw/container/;
29  
30 0 ▶sub serialize {
Subroutine serialize: not called CC=9 SCAR=45.0
Pod undocumented
31 0 my ($self, $data) = @_;
32  
33 0 my @xml;
34
35 0 ▶ if($self->container || exists $data->{container}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->container or exists $data->{"container"}) 0 0 0
Condition0%0/3
$self->container or exists $data->{"container"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->container or exists $data->{"container"}
$self->container exists $data->{"container"}
Truth table0%0/3
A or B
A= $self->containerB= exists $data->{"container"}
ABresult
1X1
011
000
36 0 @xml = ("<arg0>");
37 }
38  
39 0 for my $key (keys %{ $data }) {
40 0 ▶ next if ($key eq "container");
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "container" 0 0 0
41 0 ▶ if(ref $data->{$key} eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $data->{$key} eq 'ARRAY') { } 0 0 0
42 0 for my $a (@{ $data->{$key} }) {
43 0 push(@xml, "<${key}>");
44 0 push(@xml, $a);
45 0 push(@xml, "</${key}>");
46 }
47 }
48 else {
49 0 push(@xml, "<$key>" . $data->{$key} . "</$key>");
50 }
51 }
52  
53 0 ▶ if($self->container || exists $data->{container}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->container or exists $data->{"container"}) 0 0 0
Condition0%0/3
$self->container or exists $data->{"container"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->container or exists $data->{"container"}
$self->container exists $data->{"container"}
Truth table0%0/3
A or B
A= $self->containerB= exists $data->{"container"}
ABresult
1X1
011
000
54 0 push(@xml, "</arg0>");
55 }
56  
57 0 return join("", @xml);
58 }
59  
60 1 1;
↑ Summary ProfitBricks/Connection.pm »