blib/lib/HTTP/Entity/Parser/JSON.pm

filter: Statementstmt 100% 26 / 26 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 88.6% 39 / 44 SCAR 16.1
CC
5
Cov
94%
finalize
4.0
add
2.0
BEGIN
1.0
CRAP 5.0
« blib/lib/HTTP/Entity/Parser.pm ↑ Summary blib/lib/HTTP/Entity/Parser/UrlEncoded.pm »
1 package HTTP::Entity::Parser::JSON;
2  
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use JSON::MaybeXS qw/decode_json/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 5 ▶use Encode qw/encode_utf8/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub new {
9 1 ▶ bless [''], $_[0];
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
10 }
11  
12 sub add {
13 7 ▶ my $self = shift;
Subroutine add: called CC=2 SCAR=7.1
Pod undocumented
14 7 ▶ if (defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0]) 7 0 7
15 7 $self->[0] .= $_[0];
16 }
17 }
18  
19 sub finalize {
20 1 ▶ my $self = shift;
Subroutine finalize: called CC=4 SCAR=13.9
Pod undocumented
21  
22 1 my $p = decode_json($self->[0]);
23 1 my @params;
24 1 ▶ if (ref $p eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $p eq "HASH") 1 0 1
25 1 ▶ while (my ($k, $v) = each %$p) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$p) 5 1 6
26 5 ▶ if (ref $v) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $v) { } 3 2 5
27 3 push @params, encode_utf8($k), $v;
28 } else {
29 2 push @params, encode_utf8($k), encode_utf8($v);
30 }
31 }
32 }
33 1 return (\@params, []);
34 }
35  
36 5 1;
37  
38 __END__
« blib/lib/HTTP/Entity/Parser.pm ↑ Summary blib/lib/HTTP/Entity/Parser/UrlEncoded.pm »