API/Botocore/Shape/Serializer.pm

filter: Statementstmt 28.0% 76 / 271 Branchbran 6.9% 10 / 144 Conditioncond 4.3% 8 / 183 MC/DCmcdc 1.0% 1 / 100 Subroutinesub 34.6% 17 / 49 Podpod 50.0% 1 / 2 totaltotal 15.0% 113 / 749 CC 142 SCAR 63.8
CC
142
Cov
16%
__ANON__
1482.0
_serialize_structure
870.0
_serialize_list
870.0
CRAP 592.9
« API/XML/Simple.pm ↑ Summary API/Botocore/Shape.pm »
1 package Amazon::API::Botocore::Shape::Serializer;
2  
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 11 ▶use parent qw(Class::Accessor::Fast);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 11 ▶use Amazon::API::Constants qw(:chars :booleans);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 11 ▶use Amazon::API::Botocore::Shape::Utils qw(require_shape is_hash is_array parse_timestamp);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 11 ▶use Amazon::API::Botocore::Shape;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 11 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 11 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 11 ▶use English qw(-no_match_vars);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 11 ▶use JSON qw(decode_json encode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 11 ▶use Scalar::Util qw(reftype blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 11 ▶use List::Util qw(any none);
Subroutine BEGIN: called CC=1 SCAR=0.0
18 11 ▶use URL::Encode qw(url_decode_utf8);
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 11 our $VERSION = '2.8.2'; ## no critic (RequireInterpolationOfMetachars)
21  
22 11 __PACKAGE__->follow_best_practice;
23  
24 11 __PACKAGE__->mk_accessors(qw( service delete_empty_members protocol debug logger ));
25  
26 ########################################################################
27 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod documented
28 ########################################################################
29 1 my ( $class, @args ) = @_;
30  
31 1 ▶ my %options = ref $args[0] ? %{ $args[0] } : @args;
Branch: 1 branch
BranchTrueFalseTotal
ref $args[0] ? : 1 0 1
32  
33 1 my $self = $class->SUPER::new( \%options );
34  
35 1 return $self;
36 }
37  
38 ########################################################################
39 0 ▶sub _serialize_structure {
Subroutine _serialize_structure: not called CC=29 SCAR=67.7
40 ########################################################################
41 0 my ( $self, $this, $data, $service, $exists ) = @_;
42  
43 0 ▶ $service ||= $self->get_service;
Condition0%0/3
$service ||= $self->get_service
l!l&&r!l&&!r
000
MC/DC0%0/2
$service ||= $self->get_service
$service $self->get_service
Truth table0%0/3
A ||= B
A= $serviceB= $self->get_service
ABresult
1X1
011
000
44  
45 0 my $members = $this->get_members;
46  
47 0 $self->get_logger->trace(
48 Dumper [
49 class => ref $this,
50 serialize_structure => $this,
51 data => $data,
52 exists => $exists,
53 members => $members,
54 ]
55 );
56  
57 0 ▶ return if !defined $data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data 0 0 0
58  
59 # my $result = {};
60 0 ▶ my $result = $exists ? {} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$exists ? : 0 0 0
61  
62 0 foreach my $m ( keys %{$members} ) {
63 0 my $member = $members->{$m};
64  
65 0 ▶ my $is_payload = $this->{payload} && $m eq $this->{payload};
Condition0%0/3
$this->{'payload'} && $m eq $this->{'payload'}
!ll&&!rl&&r
000
MC/DC0%0/2
$this->{'payload'} && $m eq $this->{'payload'}
$this->{'payload'} $m eq $this->{'payload'}
Truth table0%0/3
A && B
A= $this->{'payload'}B= $m eq $this->{'payload'}
ABresult
0X0
100
111
66  
67 0 my $is_jsonvalue = $member->{jsonvalue};
68  
69 0 ▶ my $location_name = $member->{locationName} || $member->{location} || $m;
Condition0%0/6
$member->{'locationName'} || $member->{'location'} || $m
l!l&&r!l&&!r
000
$member->{"locationName"} or $member->{"location"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$member->{'locationName'} || $member->{'location'} || $m
$member->{"locationName"} $member->{"location"} $m
Truth table0%0/4
A or B || C
A= $member->{"locationName"}B= $member->{"location"}C= $m
ABCresult
1XX1
01X1
0011
0000
70 0 ▶ next if !exists $data->{$location_name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $data->{$location_name} 0 0 0
71  
72 my $has_location
73 0 ▶ = ( exists $member->{locationName} ) || ( exists $member->{location} );
Condition0%0/3
exists $member->{'locationName'} || exists $member->{'location'}
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $member->{'locationName'} || exists $member->{'location'}
exists $member->{'locationName'} exists $member->{'location'}
Truth table0%0/3
A || B
A= exists $member->{'locationName'}B= exists $member->{'location'}
ABresult
1X1
011
000
74  
75 0 my $shape = $member->{shape};
76 0 my $serialized_data;
77  
78 $self->get_logger->trace(
79 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
80 0 return Dumper(
81 [ member_name => $m,
82 member => $member,
83 shape => $shape,
84 location => $location_name,
85 has_location => $has_location,
86 exists => $exists,
87 ]
88 );
89 }
90 0 );
91  
92 0 my $member_data = $data->{$location_name};
93  
94 next
95 0 ▶ if $self->get_protocol =~ /^(?:json|rest-json)$/xsm
Branch: 1 branch
BranchTrueFalseTotal
if $self->get_protocol =~ /^(?:json|rest-json)$/msx and not defined $member_data 0 0 0
Condition0%0/3
$self->get_protocol =~ /^(?:json|rest-json)$/msx and not defined $member_data
!ll&&!rl&&r
000
MC/DC0%0/2
$self->get_protocol =~ /^(?:json|rest-json)$/msx and not defined $member_data
$self->get_protocol =~ /^(?:json|rest-json)$/msx not defined $member_data
Truth table0%0/3
A and not(B)
A= $self->get_protocol =~ /^(?:json|rest-json)$/msxB= not defined $member_data
ABresult
0X0
100
111
96 && !defined $member_data;
97  
98 $self->get_logger->trace(
99 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
100 0 return Dumper(
101 [ member => $m,
102 shape => $shape,
103 data => $data,
104 location => $location_name,
105 member_data => $member_data,
106 has_location => $has_location,
107 exists => $exists,
108 ]
109 );
110 }
111 0 );
112  
113 # because we may have serialized an XML object...this is a result
114 # of how XMLin deserializes XML objects
115 0 ▶ if ( $member_data && ref($member_data) && $shape eq 'String' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($member_data and ref $member_data and $shape eq "String") 0 0 0
Condition0%0/6
$member_data and ref $member_data and $shape eq "String"
!ll&&!rl&&r
000
$member_data and ref $member_data
!ll&&!rl&&r
000
MC/DC0%0/3
$member_data and ref $member_data and $shape eq "String"
$member_data ref $member_data $shape eq "String"
Truth table0%0/4
A and B and C
A= $member_dataB= ref $member_dataC= $shape eq "String"
ABCresult
0XX0
10X0
1100
1111
116 0 ▶ $member_data = $member_data->{content} // $EMPTY;
Condition0%0/3
$member_data->{"content"} // $Amazon::API::Botocore::Shape::Serializer::EMPTY
l!l&&r!l&&!r
000
MC/DC0%0/2
$member_data->{"content"} // $Amazon::API::Botocore::Shape::Serializer::EMPTY
$member_data->{"content"} $Amazon::API::Botocore::Shape::Serializer::EMPTY
Truth table0%0/3
A // B
A= $member_data->{"content"}B= $Amazon::API::Botocore::Shape::Serializer::EMPTY
ABresult
1X1
011
000
117 }
118  
119 $self->get_logger->trace(
120 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
121 return Dumper(
122 [ member_data => $member_data,
123 member => $member,
124 location_name => $location_name,
125 has_location => $has_location,
126 caller_exists => $exists,
127 0 exists => exists $data->{$location_name},
128 ]
129 );
130 }
131 0 );
132  
133 # has location means this structure member should be inserted into
134 # a hash at that location - when it doesn't exist the data is
135 # inserted directly into the member name
136  
137 # if member data does not exist, then entire data structure is
138 # passed to the serializer
139  
140 0 ▶ if ( !$has_location || exists $data->{$location_name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $has_location or exists $data->{$location_name}) 0 0 0
Condition0%0/3
not $has_location or exists $data->{$location_name}
l!l&&r!l&&!r
000
MC/DC0%0/2
not $has_location or exists $data->{$location_name}
not $has_location exists $data->{$location_name}
Truth table0%0/3
not(A) or B
A= not $has_locationB= exists $data->{$location_name}
ABresult
1X1
011
000
141 $serialized_data = $self->serialize(
142 shape => $shape,
143 data => exists $data->{$location_name} ? $member_data : $data,
144 service => $service,
145 exists => exists $data->{$location_name},
146 0 ▶ ( $member->{flattened} ? ( flattened => $TRUE )
Branch: 3 branches
BranchTrueFalseTotal
exists $data->{$location_name} ? : 0 0 0
$member->{'flattened'} ? : 0 0 0
$is_payload ? : 0 0 0
147 : ()
148 ),
149 ( $is_payload ? ( payload => $TRUE )
150 : ()
151 ),
152 );
153  
154 $self->get_logger->trace(
155 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
156 return Dumper(
157 [ "back from serializing $shape",
158 data => $serialized_data,
159 location_name => $location_name,
160 member => $m,
161 flattened => $this->{flattened},
162 0 ]
163 );
164 }
165 0 );
166 }
167  
168 # skip empty members
169 0 ▶ next if ( !exists $data->{$location_name} ) && !defined $serialized_data;
Branch: 1 branch
BranchTrueFalseTotal
unless exists $data->{$location_name} or defined $serialized_data 0 0 0
Condition0%0/3
exists $data->{$location_name} or defined $serialized_data
l!l&&r!l&&!r
000
MC/DC0%0/2
exists $data->{$location_name} or defined $serialized_data
exists $data->{$location_name} defined $serialized_data
Truth table0%0/3
A or B
A= exists $data->{$location_name}B= defined $serialized_data
ABresult
1X1
011
000
170  
171 0 ▶ $result //= {};
Condition0%0/2
$result //= {}
l!l
00
MC/DC0%0/1
$result //= {}
$result
Truth table0%0/2
A
A= $result
Aresult
11
00
172  
173 0 ▶ if ( $this->{flattened} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{'flattened'}) { } 0 0 0
174 0 $result->{$m} = $serialized_data;
175 }
176 else {
177 0 ▶ if ( $self->get_protocol !~ /^(?:json|rest-json)$/xsm
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->get_protocol =~ /^(?:json|rest-json)$/msx and $has_location and is_hash($serialized_data) and exists $serialized_data->{$location_name}) { } 0 0 0
Condition0%0/9
not $self->get_protocol =~ /^(?:json|rest-json)$/msx and $has_location and is_hash($serialized_data) and exists $serialized_data->{$location_name}
!ll&&!rl&&r
000
not $self->get_protocol =~ /^(?:json|rest-json)$/msx and $has_location and is_hash($serialized_data)
!ll&&!rl&&r
000
not $self->get_protocol =~ /^(?:json|rest-json)$/msx and $has_location
!ll&&!rl&&r
000
MC/DC0%0/4
not $self->get_protocol =~ /^(?:json|rest-json)$/msx and $has_location and is_hash($serialized_data) and exists $serialized_data->{$location_name}
not $self->get_protocol =~ /^(?:json|rest-json)$/msx $has_location is_hash($serialized_data) exists $serialized_data->{$location_name}
Truth table0%0/5
not(A) and B and C and D
A= not $self->get_protocol =~ /^(?:json|rest-json)$/msxB= $has_locationC= is_hash($serialized_data)D= exists $serialized_data->{$location_name}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
178 && $has_location
179 && is_hash($serialized_data)
180 && exists $serialized_data->{$location_name} ) {
181 0 $result->{$m} = $serialized_data->{$location_name};
182 }
183 else {
184 0 $result->{$m} = $serialized_data;
185 }
186 }
187  
188 $self->get_logger->trace(
189 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
190 0 return Dumper(
191 [ result => $result,
192 member => $m,
193 serialized_data => $serialized_data,
194 location_name => $location_name,
195 exists => $exists,
196 ]
197 );
198 }
199 0 );
200 }
201  
202 0 return $result;
203 }
204  
205 ########################################################################
206 0 ▶sub _serialize_list {
Subroutine _serialize_list: not called CC=29 SCAR=67.7
207 ########################################################################
208 0 my ( $self, $this, $data, $service, $exists ) = @_;
209  
210 0 ▶ $service ||= $self->get_service;
Condition0%0/3
$service ||= $self->get_service
l!l&&r!l&&!r
000
MC/DC0%0/2
$service ||= $self->get_service
$service $self->get_service
Truth table0%0/3
A ||= B
A= $serviceB= $self->get_service
ABresult
1X1
011
000
211  
212 0 $self->get_logger->trace( Dumper( [ 'serialize_list', $this, $data, $service ] ) );
213  
214 0 my $member = $this->get_member;
215 0 my $location_name = $member->{locationName};
216  
217 0 ▶ if ( !$location_name ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($location_name) 0 0 0
218 0 ▶ if ( ref $data && reftype($data) eq 'HASH' && exists $data->{member} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $data and builtin::reftype($data) eq "HASH" and exists $data->{"member"}) 0 0 0
Condition0%0/6
ref $data and builtin::reftype($data) eq "HASH" and exists $data->{"member"}
!ll&&!rl&&r
000
ref $data and builtin::reftype($data) eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/3
ref $data and builtin::reftype($data) eq "HASH" and exists $data->{"member"}
ref $data builtin::reftype($data) eq "HASH" exists $data->{"member"}
Truth table0%0/4
A and B and C
A= ref $dataB= builtin::reftype($data) eq "HASH"C= exists $data->{"member"}
ABCresult
0XX0
10X0
1100
1111
219 0 $location_name = 'member';
220 }
221 }
222  
223 0 ▶ my $list = $location_name && ref $data && reftype($data) eq 'HASH' ? $data->{$location_name} : $data;
Branch: 1 branch
BranchTrueFalseTotal
$location_name && ref $data && builtin::reftype($data) eq 'HASH' ? : 0 0 0
Condition0%0/6
$location_name and ref $data and builtin::reftype($data) eq "HASH"
!ll&&!rl&&r
000
$location_name and ref $data
!ll&&!rl&&r
000
MC/DC0%0/3
$location_name and ref $data and builtin::reftype($data) eq "HASH"
$location_name ref $data builtin::reftype($data) eq "HASH"
Truth table0%0/4
A and B and C
A= $location_nameB= ref $dataC= builtin::reftype($data) eq "HASH"
ABCresult
0XX0
10X0
1100
1111
224  
225 0 ▶ return [] if defined $list && !ref $list && $list eq $EMPTY;
Branch: 1 branch
BranchTrueFalseTotal
if defined $list and not ref $list and $list eq $Amazon::API::Botocore::Shape::Serializer::EMPTY 0 0 0
Condition0%0/6
defined $list and not ref $list and $list eq $Amazon::API::Botocore::Shape::Serializer::EMPTY
!ll&&!rl&&r
000
defined $list and not ref $list
!ll&&!rl&&r
000
MC/DC0%0/3
defined $list and not ref $list and $list eq $Amazon::API::Botocore::Shape::Serializer::EMPTY
defined $list not ref $list $list eq $Amazon::API::Botocore::Shape::Serializer::EMPTY
Truth table0%0/4
A and not(B) and C
A= defined $listB= not ref $listC= $list eq $Amazon::API::Botocore::Shape::Serializer::EMPTY
ABCresult
0XX0
10X0
1100
1111
226  
227 0 my $member_shape = $member->{shape};
228  
229 0 $self->get_logger->trace(
230 Dumper(
231 [ 'serialize_list',
232 member => $member,
233 location_name => $location_name,
234 list => $list,
235 member_shape => $member_shape,
236 ]
237 )
238 );
239  
240 0 my $result = [];
241  
242 0 ▶ if ( $list && !ref $list ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($list and not ref $list) { } 0 0 0
elsif ($list and builtin::reftype($list) eq 'HASH') { } 0 0 0
Condition0%0/3
$list and not ref $list
!ll&&!rl&&r
000
MC/DC0%0/2
$list and not ref $list
$list not ref $list
Truth table0%0/3
A and not(B)
A= $listB= not ref $list
ABresult
0X0
100
111
243 0 $list = [$list];
244 }
245 ▶ elsif ( $list && reftype($list) eq 'HASH' ) {
Condition0%0/3
$list and builtin::reftype($list) eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
$list and builtin::reftype($list) eq "HASH"
$list builtin::reftype($list) eq "HASH"
Truth table0%0/3
A and B
A= $listB= builtin::reftype($list) eq "HASH"
ABresult
0X0
100
111
246  
247 0 my @key_values;
248  
249 0 ▶ if ( $this->{flattened} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{'flattened'}) { } 0 0 0
250 $self->get_logger->trace(
251 Dumper(
252 [ list => $list,
253 flattened => $this->{flattened}
254 0 ]
255 )
256 );
257  
258 0 my @flattened_list;
259  
260 0 foreach ( keys %{$list} ) {
261 0 ▶ if ( $list->{$_} && ref $list->{$_} && reftype( $list->{$_} ) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($list->{$_} and ref $list->{$_} and builtin::reftype($list->{$_}) eq "ARRAY") 0 0 0
Condition0%0/6
$list->{$_} and ref $list->{$_} and builtin::reftype($list->{$_}) eq "ARRAY"
!ll&&!rl&&r
000
$list->{$_} and ref $list->{$_}
!ll&&!rl&&r
000
MC/DC0%0/3
$list->{$_} and ref $list->{$_} and builtin::reftype($list->{$_}) eq "ARRAY"
$list->{$_} ref $list->{$_} builtin::reftype($list->{$_}) eq "ARRAY"
Truth table0%0/4
A and B and C
A= $list->{$_}B= ref $list->{$_}C= builtin::reftype($list->{$_}) eq "ARRAY"
ABCresult
0XX0
10X0
1100
1111
262 0 push @flattened_list, @{ $list->{$_} };
263 }
264 }
265  
266 0 ▶ $list = @flattened_list ? \@flattened_list : [ values %{$list} ];
Branch: 1 branch
BranchTrueFalseTotal
@flattened_list ? : 0 0 0
267 }
268 else {
269 0 $self->get_logger->trace(
270 Dumper(
271 [ message => 'unreliable deserialization?',
272 this => $this,
273 list => $list,
274 data => $data,
275 ]
276 )
277 );
278  
279 0 $list = [$list];
280 }
281  
282 0 $self->get_logger->trace( Dumper( [ key_values => $member_shape, \@key_values ] ) );
283  
284 0 my %result;
285  
286 0 foreach my $p ( @{$list} ) {
287  
288 0 $self->get_logger->trace( Dumper( [ p => $p, member_shape => $member_shape ] ) );
289  
290 my $serialized_data = $self->serialize(
291 shape => $member_shape,
292 data => $p,
293 service => $service,
294 0 ▶ exists => $location_name && exists $data->{$location_name},
Condition0%0/3
$location_name && exists $data->{$location_name}
!ll&&!rl&&r
000
MC/DC0%0/2
$location_name && exists $data->{$location_name}
$location_name exists $data->{$location_name}
Truth table0%0/3
A && B
A= $location_nameB= exists $data->{$location_name}
ABresult
0X0
100
111
295 );
296  
297 0 ▶ next if !defined $serialized_data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $serialized_data 0 0 0
298  
299 0 push @{$result}, $serialized_data;
300 }
301  
302 0 local $LIST_SEPARATOR = q{,};
303  
304 $self->get_logger->trace(
305 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
306 0 return Dumper(
307 [ 'ref(self)' => ref($self),
308 'ref(this)' => ref($this),
309 result => $result,
310 list => $list
311 ]
312 );
313 }
314 0 );
315 }
316 else {
317 0 foreach my $elem ( @{$list} ) {
318  
319 $self->get_logger->trace(
320 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
321 return Dumper(
322 [ shape => $member->{shape},
323 0 elem => $elem
324 ]
325 );
326 }
327 0 );
328  
329 my $serialized_data = $self->serialize(
330 shape => $member->{shape},
331 0 data => $elem,
332 service => $service,
333 exists => $exists,
334 );
335  
336 0 ▶ next if !defined $serialized_data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $serialized_data 0 0 0
337  
338 0 push @{$result}, $serialized_data;
339  
340 }
341 }
342  
343 0 ▶ return if !$exists && !@{$result};
Branch: 1 branch
BranchTrueFalseTotal
unless $exists or @{$result;} 0 0 0
Condition0%0/3
$exists or @{$result;}
l!l&&r!l&&!r
000
MC/DC0%0/2
$exists or @{$result;}
$exists @{$result;}
Truth table0%0/3
A or B
A= $existsB= @{$result;}
ABresult
1X1
011
000
344  
345 0 return $result;
346 }
347  
348 ########################################################################
349 2 ▶sub serialize {
Subroutine serialize: called CC=19 SCAR=55.2
Pod undocumented
350 ########################################################################
351 2 my ( $self, %args ) = @_;
352  
353 2 my ( $shape, $service, $data, $exists, $payload, $flattened ) = @args{qw(shape service data exists payload flattened)};
354  
355 2 ▶ $service ||= $self->get_service;
Condition33%1/3
$service ||= $self->get_service
l!l&&r!l&&!r
200
MC/DC0%0/2
$service ||= $self->get_service
$service $self->get_service
Truth table33%1/3
A ||= B
A= $serviceB= $self->get_service
ABresult
1X1
011
000
356  
357 2 my $protocol = $self->get_protocol;
358  
359 $self->get_logger->trace(
360 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
361 0 return Dumper(
362 [ shape => $shape,
363 data => $data,
364 service => $service,
365 exists => $exists,
366 protocol => $protocol,
367 ]
368 );
369 }
370 2 );
371  
372 2 my $class = require_shape( $shape, $service );
373  
374 2 ▶ croak "unable to require class for $shape: $EVAL_ERROR\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $class 0 2 2
375 if !$class;
376  
377 2 ▶ local $Amazon::API::Botocore::Shape::LOGGER_SOURCE = sub { $self->get_logger };
Subroutine __ANON__: called CC=1 SCAR=0.0
378  
379 2 my $this = $class->new();
380 2 $this->set_logger( $self->get_logger );
381  
382 2 ▶ $this->{flattened} = $flattened
Branch: 1 branch
BranchTrueFalseTotal
if defined $flattened 0 2 2
383 if defined $flattened;
384  
385 return $data
386 2 ▶ if $this->{document};
Branch: 1 branch
BranchTrueFalseTotal
if $this->{"document"} 0 2 2
387  
388 2 ▶ if ( !$exists && ref $data && reftype($data) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $exists and ref $data and builtin::reftype($data) eq "HASH") 0 2 2
Condition33%2/6
not $exists and ref $data and builtin::reftype($data) eq "HASH"
!ll&&!rl&&r
200
not $exists and ref $data
!ll&&!rl&&r
020
MC/DC0%0/3
not $exists and ref $data and builtin::reftype($data) eq "HASH"
not $exists ref $data builtin::reftype($data) eq "HASH"
Truth table25%1/4
not(A) and B and C
A= not $existsB= ref $dataC= builtin::reftype($data) eq "HASH"
ABCresult
0XX0
10X0
1100
1111
389  
390 0 ▶ if ( $self->get_protocol eq 'rest-xml' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->get_protocol eq 'rest-xml') { } 0 0 0
elsif ($self->get_protocol =~ /^(?:query|ec2)$/) { } 0 0 0
391  
392 0 ▶ if ( exists $data->{$shape} ) {
Branch: 3 branches
BranchTrueFalseTotal
if (exists $data->{$shape}) { } 0 0 0
elsif ($this->{'locationName'} and exists $$data{$this->{'locationName'}}) { } 0 0 0
elsif (keys %{$data;} == 1) { } 0 0 0
393 0 $data = $data->{$shape};
394 }
395 ▶ elsif ( $this->{locationName} && exists $data->{ $this->{locationName} } ) {
Condition0%0/3
$this->{"locationName"} and exists $$data{$this->{"locationName"}}
!ll&&!rl&&r
000
MC/DC0%0/2
$this->{"locationName"} and exists $$data{$this->{"locationName"}}
$this->{"locationName"} exists $$data{$this->{"locationName"}}
Truth table0%0/3
A and B
A= $this->{"locationName"}B= exists $$data{$this->{"locationName"}}
ABresult
0X0
100
111
396 0 $data = $data->{ $this->{locationName} };
397 }
398 0 elsif ( keys %{$data} == 1 ) {
399 0 my ($root) = keys %{$data};
400  
401 0 ▶ my $members = $this->get_members // {};
Condition0%0/2
$this->get_members // {}
l!l
00
MC/DC0%0/1
$this->get_members // {}
$this->get_members
Truth table0%0/2
A
A= $this->get_members
Aresult
11
00
402  
403 0 ▶ my $is_modeled_member = any {
Subroutine __ANON__: not called CC=2 SCAR=17.9
404 0 my $member = $members->{$_};
405  
406 0 ▶ my $location_name = $member->{locationName} // $_;
Condition0%0/3
$member->{"locationName"} // $_
l!l&&r!l&&!r
000
MC/DC0%0/2
$member->{"locationName"} // $_
$member->{"locationName"} $_
Truth table0%0/3
A // B
A= $member->{"locationName"}B= $_
ABresult
1X1
011
000
407  
408 0 $root eq $location_name;
409 }
410 0 keys %{$members};
411  
412 0 ▶ if ( !$is_modeled_member ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($is_modeled_member) 0 0 0
413 0 $data = $data->{$root};
414 }
415 }
416 }
417 elsif ( $self->get_protocol =~ /^(?:query|ec2)$/ ) {
418 0 my ($response_wrapper) = grep {/response$/i} keys %{$data};
419  
420 0 ▶ if ($response_wrapper) {
Branch: 1 branch
BranchTrueFalseTotal
if ($response_wrapper) 0 0 0
421 0 $data = $data->{$response_wrapper};
422 0 $exists = $TRUE;
423  
424 0 ▶ if ( exists $data->{$shape} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $data->{$shape}) 0 0 0
425 0 $data = $data->{$shape};
426 }
427 }
428 }
429 }
430  
431 2 my $type = $this->get_type;
432  
433 $self->get_logger->trace(
434 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
435 0 return Dumper(
436 [ class => $class,
437 type => $type,
438 exists => $exists,
439 data => $data,
440 service => $service,
441 this => $this,
442 ]
443 );
444 }
445 2 );
446  
447 my %serializers = (
448 0 ▶ structure => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
449 0 return $self->_serialize_structure( $this, $data, $service, $exists );
450 },
451  
452 0 ▶ list => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
453 0 return $self->_serialize_list( $this, $data, $service, $exists );
454 },
455  
456 0 ▶ string => sub {
Subroutine __ANON__: not called CC=6 SCAR=37.4
457  
458 0 ▶ if ( defined $data ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $data) 0 0 0
459 0 ▶ $data = ref $data && defined $data->{content} ? $data->{content} : $data;
Branch: 1 branch
BranchTrueFalseTotal
ref $data && defined $data->{'content'} ? : 0 0 0
Condition0%0/3
ref $data and defined $data->{"content"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $data and defined $data->{"content"}
ref $data defined $data->{"content"}
Truth table0%0/3
A and B
A= ref $dataB= defined $data->{"content"}
ABresult
0X0
100
111
460 }
461  
462 0 ▶ return $data
Branch: 1 branch
BranchTrueFalseTotal
if defined $data 0 0 0
463 if defined $data;
464  
465 0 ▶ return $exists ? $EMPTY : $data;
Branch: 1 branch
BranchTrueFalseTotal
$exists ? : 0 0 0
466 },
467  
468 0 ▶ boolean => sub {
Subroutine __ANON__: not called CC=7 SCAR=40.3
469  
470 0 ▶ if ( ref $data ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $data) 0 0 0
471 0 ▶ if ( !blessed $data ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($data)) 0 0 0
472 0 $data = $data->{content};
473 }
474 }
475  
476 return
477 0 ▶ if !defined $data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data 0 0 0
478  
479 0 ▶ $data //= 0;
Condition0%0/2
$data //= 0
l!l
00
MC/DC0%0/1
$data //= 0
$data
Truth table0%0/2
A
A= $data
Aresult
11
00
480 0 ▶ if ( any { $data eq $_ } qw( 0 1 true false) ) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if (&any(sub { $data eq $_; } , 0, 1, "true", "false")) 0 0 0
481 my $bool_value = {
482 '0' => 0,
483 '1' => 1,
484 'true' => 1,
485 'false' => 0,
486 0 }->{$data};
487  
488 # Response deserialization always returns modeled boolean values.
489 # Query/EC2 request serialization uses plain 0/1 in Shape.pm because
490 # query-string generation cannot consume blessed JSON booleans.
491 0 ▶ return $bool_value ? JSON::true : JSON::false;
Branch: 1 branch
BranchTrueFalseTotal
$bool_value ? : 0 0 0
492 }
493  
494 0 return $data;
495 },
496  
497 0 ▶ integer => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
498 0 ▶ return ref $data ? $data->{content} : $data;
Branch: 1 branch
BranchTrueFalseTotal
ref $data ? : 0 0 0
499 },
500  
501 0 ▶ long => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
502 0 ▶ return ref $data ? $data->{content} : $data;
Branch: 1 branch
BranchTrueFalseTotal
ref $data ? : 0 0 0
503 },
504  
505 0 ▶ float => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
506 0 ▶ $data = ref $data ? $data->{content} : $data;
Branch: 1 branch
BranchTrueFalseTotal
ref $data ? : 0 0 0
507  
508 return $data
509 0 ▶ if defined $data && any { $data eq $_ } qw(NaN Infinity -Infinity);
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if defined $data and &any(sub { $data eq $_; } , "NaN", "Infinity", "-Infinity") 0 0 0
Condition0%0/3
defined $data and &any(sub { $data eq $_; } , "NaN", "Infinity", "-Infinity")
!ll&&!rl&&r
000
MC/DC0%0/2
defined $data and &any(sub { $data eq $_; } , "NaN", "Infinity", "-Infinity")
defined $data &any(sub { $data eq $_; } , "NaN", "Infinity", "-Infinity")
Truth table0%0/3
A and B
A= defined $dataB= &any(sub { $data eq $_; } , "NaN", "Infinity", "-Infinity")
ABresult
0X0
100
111
510  
511 0 ▶ return defined $data ? $data * 1.0 : $data;
Branch: 1 branch
BranchTrueFalseTotal
defined $data ? : 0 0 0
512 },
513  
514 0 ▶ double => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
515 0 ▶ $data = ref $data ? $data->{content} : $data;
Branch: 1 branch
BranchTrueFalseTotal
ref $data ? : 0 0 0
516  
517 return $data
518 0 ▶ if defined $data && any { $data eq $_ } qw(NaN Infinity -Infinity);
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if defined $data and &any(sub { $data eq $_; } , "NaN", "Infinity", "-Infinity") 0 0 0
Condition0%0/3
defined $data and &any(sub { $data eq $_; } , "NaN", "Infinity", "-Infinity")
!ll&&!rl&&r
000
MC/DC0%0/2
defined $data and &any(sub { $data eq $_; } , "NaN", "Infinity", "-Infinity")
defined $data &any(sub { $data eq $_; } , "NaN", "Infinity", "-Infinity")
Truth table0%0/3
A and B
A= defined $dataB= &any(sub { $data eq $_; } , "NaN", "Infinity", "-Infinity")
ABresult
0X0
100
111
519  
520 0 ▶ return defined $data ? $data * 1.0 : $data;
Branch: 1 branch
BranchTrueFalseTotal
defined $data ? : 0 0 0
521 },
522 0 ▶ map => sub {
Subroutine __ANON__: not called CC=38 SCAR=73.0
523  
524 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (&any(sub { $protocol eq $_; } , "query", "ec2", "rest-xml") and $exists and !defined($data) || ref $data && builtin::reftype($data) eq "HASH" && !keys(%{$data;}) || ref $data && builtin::reftype($data) eq "HASH" && keys %{$data;} == 1 && exists $data->{"content"}) 0 0 0
Condition0%0/18
&any(sub { $protocol eq $_; } , "query", "ec2", "rest-xml") and $exists and !defined($data) || ref $data && builtin::reftype($data) eq "HASH" && !keys(%{$data;}) || ref $data && builtin::reftype($data) eq "HASH" && keys %{$data;} == 1 && exists $data->{"content"}
!ll&&!rl&&r
000
&any(sub { $protocol eq $_; } , "query", "ec2", "rest-xml") and $exists
!ll&&!rl&&r
000
not defined $data or ref $data and builtin::reftype($data) eq "HASH" and not keys %{$data;} or ref $data and builtin::reftype($data) eq "HASH" and keys %{$data;} == 1 and exists $data->{"content"}
l!l&&r!l&&!r
000
not defined $data or ref $data and builtin::reftype($data) eq "HASH" and not keys %{$data;}
l!l&&r!l&&!r
000
ref $data and builtin::reftype($data) eq "HASH" and not keys %{$data;}
!ll&&!rl&&r
000
ref $data and builtin::reftype($data) eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/7
&any(sub { $protocol eq $_; } , "query", "ec2", "rest-xml") and $exists and !defined($data) || ref $data && builtin::reftype($data) eq "HASH" && !keys(%{$data;}) || ref $data && builtin::reftype($data) eq "HASH" && keys %{$data;} == 1 && exists $data->{"content"}
&any(sub { $protocol eq $_; } , "query", "ec2", "rest-xml") $exists not defined $data ref $data builtin::reftype($data) eq "HASH" not keys %{$data;} ref $data and builtin::reftype($data) eq "HASH" and keys %{$data;} == 1 and exists $data->{"content"}
Truth table0%0/10
A and B and not(C) or D and E and not(F) or G
A= &any(sub { $protocol eq $_; } , "query", "ec2", "rest-xml")B= $existsC= not defined $dataD= ref $dataE= builtin::reftype($data) eq "HASH"F= not keys %{$data;}G= ref $data and builtin::reftype($data) eq "HASH" and keys %{$data;} == 1 and exists $data->{"content"}
ABCDEFGresult
0XXXXXX0
10XXXXX0
1100XX00
11010X00
11011000
111XXXX1
110111X1
1100XX11
11010X11
11011011
525 0 ▶ ( any { $protocol eq $_ } qw(query ec2 rest-xml) )
Subroutine __ANON__: not called CC=1 SCAR=6.9
526 && $exists
527 && (
528 !defined $data
529 0 ▶ || ( ref $data && reftype($data) eq 'HASH' && !keys %{$data} )
Condition0%0/9
ref $data and builtin::reftype($data) eq "HASH" and keys %{$data;} == 1 and exists $data->{"content"}
!ll&&!rl&&r
000
ref $data and builtin::reftype($data) eq "HASH" and keys %{$data;} == 1
!ll&&!rl&&r
000
ref $data and builtin::reftype($data) eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/4
ref $data and builtin::reftype($data) eq "HASH" and keys %{$data;} == 1 and exists $data->{"content"}
ref $data builtin::reftype($data) eq "HASH" keys %{$data;} == 1 exists $data->{"content"}
Truth table0%0/5
A and B and C and D
A= ref $dataB= builtin::reftype($data) eq "HASH"C= keys %{$data;} == 1D= exists $data->{"content"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
530 || ( ref $data
531 && reftype($data) eq 'HASH'
532 0 && keys %{$data} == 1
533 && exists $data->{content} )
534 )
535 ) {
536 0 return {};
537 }
538  
539 0 ▶ if ( !$this->{flattened} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($this->{"flattened"}) 0 0 0
540 0 ▶ if ( $protocol =~ /^(?:json|rest-json)$/xsm
Branch: 1 branch
BranchTrueFalseTotal
if ($protocol =~ /^(?:json|rest-json)$/msx and ref $data and builtin::reftype($data) eq "HASH") 0 0 0
Condition0%0/6
$protocol =~ /^(?:json|rest-json)$/msx and ref $data and builtin::reftype($data) eq "HASH"
!ll&&!rl&&r
000
$protocol =~ /^(?:json|rest-json)$/msx and ref $data
!ll&&!rl&&r
000
MC/DC0%0/3
$protocol =~ /^(?:json|rest-json)$/msx and ref $data and builtin::reftype($data) eq "HASH"
$protocol =~ /^(?:json|rest-json)$/msx ref $data builtin::reftype($data) eq "HASH"
Truth table0%0/4
A and B and C
A= $protocol =~ /^(?:json|rest-json)$/msxB= ref $dataC= builtin::reftype($data) eq "HASH"
ABCresult
0XX0
10X0
1100
1111
541 && ref $data
542 && reftype($data) eq 'HASH' ) {
543 0 my %result;
544  
545 0 foreach my $key ( keys %{$data} ) {
546 next
547 0 ▶ if !defined $data->{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data->{$key} 0 0 0
548  
549 0 $result{$key} = $data->{$key};
550 }
551  
552 0 return \%result;
553 }
554  
555 0 ▶ if ( ( any { $protocol eq $_ } qw{query ec2 rest-xml} )
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if (&any(sub { $protocol eq $_; } , 'query', 'ec2', 'rest-xml') and ref $data and builtin::reftype($data) eq 'HASH' and exists $data->{'entry'}) { } 0 0 0
Condition0%0/9
&any(sub { $protocol eq $_; } , "query", "ec2", "rest-xml") and ref $data and builtin::reftype($data) eq "HASH" and exists $data->{"entry"}
!ll&&!rl&&r
000
&any(sub { $protocol eq $_; } , "query", "ec2", "rest-xml") and ref $data and builtin::reftype($data) eq "HASH"
!ll&&!rl&&r
000
&any(sub { $protocol eq $_; } , "query", "ec2", "rest-xml") and ref $data
!ll&&!rl&&r
000
MC/DC0%0/4
&any(sub { $protocol eq $_; } , "query", "ec2", "rest-xml") and ref $data and builtin::reftype($data) eq "HASH" and exists $data->{"entry"}
&any(sub { $protocol eq $_; } , "query", "ec2", "rest-xml") ref $data builtin::reftype($data) eq "HASH" exists $data->{"entry"}
Truth table0%0/5
A and B and C and D
A= &any(sub { $protocol eq $_; } , "query", "ec2", "rest-xml")B= ref $dataC= builtin::reftype($data) eq "HASH"D= exists $data->{"entry"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
556 && ref $data
557 && reftype($data) eq 'HASH'
558 && exists $data->{entry} ) {
559 0 $data = $data->{entry};
560 }
561 else {
562 0 return $data;
563 }
564 }
565  
566 0 my $serialize = {};
567 0 my $key_location_name = $this->{key}->{locationName};
568 0 my $value_location_name = $this->{value}->{locationName};
569  
570 0 ▶ if ( any { $protocol eq $_ } qw(query ec2 rest-xml) ) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if (&any(sub { $protocol eq $_; } , "query", "ec2", "rest-xml")) 0 0 0
571 0 ▶ $key_location_name //= 'key';
Condition0%0/2
$key_location_name //= "key"
l!l
00
MC/DC0%0/1
$key_location_name //= "key"
$key_location_name
Truth table0%0/2
A
A= $key_location_name
Aresult
11
00
572 0 ▶ $value_location_name //= 'value';
Condition0%0/2
$value_location_name //= "value"
l!l
00
MC/DC0%0/1
$value_location_name //= "value"
$value_location_name
Truth table0%0/2
A
A= $value_location_name
Aresult
11
00
573 }
574  
575 0 my $key_shape_name = $this->{key}->{shape};
576 0 my $value_shape_name = $this->{value}->{shape};
577  
578 $self->get_logger->trace(
579 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
580 return Dumper(
581 [ type => $type,
582 data => $data,
583 locationName => $this->{locationName},
584 0 key_location_name => $key_location_name,
585 key_shape_name => $key_shape_name,
586 value_location_name => $value_location_name,
587 value_shape_name => $value_shape_name,
588 ]
589 );
590 }
591 0 );
592  
593 0 ▶ $data ||= [];
Condition0%0/2
$data ||= []
l!l
00
MC/DC0%0/1
$data ||= []
$data
Truth table0%0/2
A
A= $data
Aresult
11
00
594  
595 0 ▶ if ( !$key_location_name && !$value_location_name ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($key_location_name or $value_location_name) 0 0 0
Condition0%0/3
$key_location_name or $value_location_name
l!l&&r!l&&!r
000
MC/DC0%0/2
$key_location_name or $value_location_name
$key_location_name $value_location_name
Truth table0%0/3
A or B
A= $key_location_nameB= $value_location_name
ABresult
1X1
011
000
596 0 $self->get_logger->trace(
597 Dumper(
598 [ value_shape_name => $value_shape_name,
599 data => $data,
600 this => $this
601 ]
602 )
603 );
604  
605 # we might have to serialize this data too, however since it
606 # is specified as a structure as a map and we have not
607 # information regarding how to actual map it...we return the
608 # data itself.
609 0 return $data;
610 }
611  
612 0 ▶ if ( ref $data && reftype($data) ne 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $data and builtin::reftype($data) ne "ARRAY") 0 0 0
Condition0%0/3
ref $data and builtin::reftype($data) ne "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $data and builtin::reftype($data) ne "ARRAY"
ref $data builtin::reftype($data) ne "ARRAY"
Truth table0%0/3
A and B
A= ref $dataB= builtin::reftype($data) ne "ARRAY"
ABresult
0X0
100
111
613 0 $data = [$data];
614 }
615  
616 0 foreach my $item ( @{$data} ) {
617 $self->get_logger->trace(
618 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
619 0 return Dumper( [ item => $item ] );
620 }
621 0 );
622  
623 0 my ( $key, $value );
624  
625 0 ▶ if ( $key_location_name || $key_shape_name ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key_location_name or $key_shape_name) 0 0 0
Condition0%0/3
$key_location_name or $key_shape_name
l!l&&r!l&&!r
000
MC/DC0%0/2
$key_location_name or $key_shape_name
$key_location_name $key_shape_name
Truth table0%0/3
A or B
A= $key_location_nameB= $key_shape_name
ABresult
1X1
011
000
626 $key = $self->serialize(
627 service => $service,
628 0 ▶ data => $key_location_name ? $item->{$key_location_name} : $item,
Branch: 1 branch
BranchTrueFalseTotal
$key_location_name ? : 0 0 0
629 shape => $key_shape_name,
630  
631 );
632 }
633  
634 0 ▶ if ( $value_location_name || $value_shape_name ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value_location_name or $value_shape_name) 0 0 0
Condition0%0/3
$value_location_name or $value_shape_name
l!l&&r!l&&!r
000
MC/DC0%0/2
$value_location_name or $value_shape_name
$value_location_name $value_shape_name
Truth table0%0/3
A or B
A= $value_location_nameB= $value_shape_name
ABresult
1X1
011
000
635  
636 $value = $self->serialize(
637 service => $service,
638 0 ▶ data => $value_location_name ? $item->{$value_location_name} : $item,
Branch: 1 branch
BranchTrueFalseTotal
$value_location_name ? : 0 0 0
639 shape => $value_shape_name,
640 exists => $TRUE,
641 );
642 }
643  
644 # This is almost certainly an unnecessary test as we have
645 # handled the situation where location names are not provided
646 # above by using the hash keys of the payload as the keys
647 # themselves. This occurs in an API like SQS where the
648 # attribute names become the keys but are not specifically
649 # called out in the shape.
650 0 ▶ if ( defined $key && defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $key and defined $value) { } 0 0 0
Condition0%0/3
defined $key and defined $value
!ll&&!rl&&r
000
MC/DC0%0/2
defined $key and defined $value
defined $key defined $value
Truth table0%0/3
A and B
A= defined $keyB= defined $value
ABresult
0X0
100
111
651 0 $serialize->{$key} = $value;
652 }
653 else {
654 0 return $value;
655 }
656 }
657  
658 0 return $serialize;
659 },
660 2 ▶ blob => sub {
Subroutine __ANON__: called CC=7 SCAR=21.8
661 2 ▶ if ( ref $data ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $data) 0 2 2
662 0 $data = $data->{content};
663 }
664  
665 2 ▶ return $EMPTY
Branch: 1 branch
BranchTrueFalseTotal
if not defined $data and $exists 0 2 2
Condition33%1/3
not defined $data and $exists
!ll&&!rl&&r
200
MC/DC0%0/2
not defined $data and $exists
not defined $data $exists
Truth table33%1/3
not(A) and B
A= not defined $dataB= $exists
ABresult
0X0
100
111
666 if !defined $data && $exists;
667  
668 return $data
669 2 ▶ if !defined $data || $this->{streaming} || $payload;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $data or $this->{"streaming"} or $payload 1 1 2
Condition66%4/6
not defined $data or $this->{"streaming"} or $payload
l!l&&r!l&&!r
101
not defined $data or $this->{"streaming"}
l!l&&r!l&&!r
011
MC/DC33%1/3
not defined $data or $this->{"streaming"} or $payload
not defined $data $this->{"streaming"} $payload
Truth table50%2/4
not(A) or B or C
A= not defined $dataB= $this->{"streaming"}C= $payload
ABCresult
1XX1
01X1
0011
0000
670  
671 1 require MIME::Base64;
672  
673 1 return MIME::Base64::decode_base64($data);
674 },
675 0 ▶ timestamp => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
676 $data
677 = ref $data
678 ? $data->{content}
679 0 ▶ : $data;
Branch: 1 branch
BranchTrueFalseTotal
ref $data ? : 0 0 0
680  
681 0 return parse_timestamp($data);
682 },
683 2 );
684  
685 $self->get_logger->trace(
686 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
687 0 return Dumper(
688 [ unknown_type => $type,
689 this => $this,
690 data => $data,
691 exists => $exists
692 ]
693 );
694 }
695 2 );
696  
697 2 my $result;
698  
699 2 ▶ if ( $serializers{$type} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($serializers{$type}) { } 2 0 2
700 2 $result = $serializers{$type}->($exists);
701 }
702 else {
703 $result = $self->serialize(
704 shape => $this->{shape},
705 0 data => $data,
706 service => $service,
707 exists => $exists,
708 );
709 }
710  
711 0 ▶ $self->get_logger->trace( sub { return Dumper( [ result => $result ] ) } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
712  
713 2 return $result;
714 }
715  
716 11 1;
« API/XML/Simple.pm ↑ Summary API/Botocore/Shape.pm »