blib/lib/Uniform/HTMX/PSGI.pm

filter: Statementstmt 93.7% 30 / 32 Branchbran 60.0% 6 / 10 Conditioncond 33.3% 3 / 9 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 74.2% 49 / 66 CC 12 SCAR 25.2
CC
12
Cov
76%
apply
19.6
new
2.0
BEGIN
1.0
CRAP 12.5
↑ Summary
1 package Uniform::HTMX::PSGI;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use parent 'Uniform::HTMX';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 our $VERSION = '1.03';
10  
11 2 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
12 2 my ($class, $env) = @_;
13  
14 2 ▶ croak "Environment must be a hash reference"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $env eq "HASH" 1 1 2
15 unless ref($env) eq 'HASH';
16  
17 1 return $class->SUPER::new(in => $env, env => $env);
18 }
19  
20 2 ▶sub apply {
Subroutine apply: called CC=11 SCAR=29.7
Pod documented
21 2 my ($self, $res) = @_;
22 2 my $out = $self->_out;
23  
24 2 ▶ return $res unless keys %$out;
Branch: 1 branch
BranchTrueFalseTotal
unless keys %$out 0 2 2
25  
26 2 ▶ if (ref($res) eq 'ARRAY' && ref($res->[1]) eq 'ARRAY') {
Branch: 3 branches
BranchTrueFalseTotal
if (ref $res eq 'ARRAY' and ref $res->[1] eq 'ARRAY') { } 1 1 2
elsif (builtin::blessed($res) and $res->can('headers')) { } 1 0 1
elsif (builtin::blessed($res) and $res->can('header')) { } 0 0 0
Condition66%2/3
ref $res eq "ARRAY" and ref $res->[1] eq "ARRAY"
!ll&&!rl&&r
101
MC/DC50%1/2
ref $res eq "ARRAY" and ref $res->[1] eq "ARRAY"
ref $res eq "ARRAY" ref $res->[1] eq "ARRAY"
Truth table66%2/3
A and B
A= ref $res eq "ARRAY"B= ref $res->[1] eq "ARRAY"
ABresult
0X0
100
111
27 1 for my $key (keys %$out) {
28 2 push @{ $res->[1] }, $key, $out->{$key};
29 }
30 }
31 ▶ elsif (blessed($res) && $res->can('headers')) {
Condition33%1/3
builtin::blessed($res) and $res->can("headers")
!ll&&!rl&&r
001
MC/DC0%0/2
builtin::blessed($res) and $res->can("headers")
builtin::blessed($res) $res->can("headers")
Truth table33%1/3
A and B
A= builtin::blessed($res)B= $res->can("headers")
ABresult
0X0
100
111
32 1 for my $key (keys %$out) {
33 3 $res->headers->header($key => $out->{$key});
34 }
35 }
36 ▶ elsif (blessed($res) && $res->can('header')) {
Condition0%0/3
builtin::blessed($res) and $res->can("header")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($res) and $res->can("header")
builtin::blessed($res) $res->can("header")
Truth table0%0/3
A and B
A= builtin::blessed($res)B= $res->can("header")
ABresult
0X0
100
111
37 0 for my $key (keys %$out) {
38 0 $res->header($key => $out->{$key});
39 }
40 }
41  
42 2 return $res;
43 }
44 1 1;
45  
46 __END__
↑ Summary