ResponseHelper/Text.pm

filter: Statementstmt 100% 23 / 23 Branchbran 100% 2 / 2 Conditioncond 40.0% 4 / 10 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 76.0% 35 / 46 CC 6 SCAR 11.7
CC
6
Cov
83%
helper
5.5
__ANON__
2.0
BEGIN
1.0
CRAP 3.2
« ResponseHelper.pm ↑ Summary ResponseHelper/Redirect.pm »
1 package Plack::ResponseHelper::Text;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Encode qw/encode/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Plack::Response;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶sub helper {
Subroutine helper: called CC=5 SCAR=17.1
Pod undocumented
9 1 my $init = shift;
10 1 ▶ my $content_type = $init && $init->{content_type} || 'text/plain';
Condition40%2/5
$init && $init->{'content_type'} || 'text/plain'
l!l
01
$init and $init->{"content_type"}
!ll&&!rl&&r
100
MC/DC0%0/2
$init && $init->{'content_type'} || 'text/plain'
$init $init->{"content_type"}
Truth table33%1/3
A and B
A= $initB= $init->{"content_type"}
ABresult
111
0X0
100
11 1 ▶ my $encoding = $init && $init->{encoding} || 'utf-8';
Condition40%2/5
$init && $init->{'encoding'} || 'utf-8'
l!l
01
$init and $init->{"encoding"}
!ll&&!rl&&r
100
MC/DC0%0/2
$init && $init->{'encoding'} || 'utf-8'
$init $init->{"encoding"}
Truth table33%1/3
A and B
A= $initB= $init->{"encoding"}
ABresult
111
0X0
100
12  
13 2 ▶ return sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
14 2 my $r = shift;
15 2 my $response = Plack::Response->new(200);
16 2 $response->content_type($content_type);
17 2 ▶ $response->body(ref $r eq 'ARRAY' ? [map {encode $encoding, $_} @$r] : encode $encoding, $r);
Branch: 1 branch
BranchTrueFalseTotal
ref $r eq 'ARRAY' ? : 1 1 2
18 2 return $response;
19 1 };
20 }
21  
22 1 1;
23  
24 __END__
« ResponseHelper.pm ↑ Summary ResponseHelper/Redirect.pm »