| 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
Condition0%0/3
$self->container or exists $data->{"container"}
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"}
| |||||||||||||||||||||||||||||
| 36 | 0 | @xml = ("<arg0>"); | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | for my $key (keys %{ $data }) { | |||||||||||||||||||||||||||
| 40 | 0 | ▶ | next if ($key eq "container"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if(ref $data->{$key} eq "ARRAY") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
$self->container or exists $data->{"container"}
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"}
| |||||||||||||||||||||||||||||
| 54 | 0 | push(@xml, "</arg0>"); | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | return join("", @xml); | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 1 | 1; | |||||||||||||||||||||||||||