blib/lib/Uniform/HTMX/PAGI.pm

filter: Statementstmt 82.8% 29 / 35 Branchbran 41.6% 5 / 12 Conditioncond 16.6% 2 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 59.2% 45 / 76 CC 15 SCAR 37.2
CC
15
Cov
61%
apply
61.1
new
2.0
BEGIN
1.0
CRAP 41.1
↑ Summary
1 package Uniform::HTMX::PAGI;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use parent 'Uniform::HTMX';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 our $VERSION = '1.02';
10  
11 3 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
12 3 my ($class, $env) = @_;
13  
14 3 ▶ croak "Environment must be a hash reference"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $env eq "HASH" 1 2 3
15 unless ref($env) eq 'HASH';
16  
17 2 return $class->SUPER::new(in => $env, env => $env);
18 }
19  
20 1 ▶sub apply {
Subroutine apply: called CC=14 SCAR=41.1
Pod documented
21 1 my ($self, $res) = @_;
22 1 my $out = $self->_out;
23  
24 1 ▶ return $res unless keys %$out;
Branch: 1 branch
BranchTrueFalseTotal
unless keys %$out 0 1 1
25  
26 1 ▶ 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 0 1
elsif (builtin::blessed($res) and $res->can('headers')) { } 0 0 0
elsif (builtin::blessed($res) and $res->can('header')) { } 0 0 0
Condition33%1/3
ref $res eq "ARRAY" and ref $res->[1] eq "ARRAY"
!ll&&!rl&&r
001
MC/DC0%0/2
ref $res eq "ARRAY" and ref $res->[1] eq "ARRAY"
ref $res eq "ARRAY" ref $res->[1] eq "ARRAY"
Truth table33%1/3
A and B
A= ref $res eq "ARRAY"B= ref $res->[1] eq "ARRAY"
ABresult
0X0
100
111
27 1 my $headers = $res->[1];
28  
29 # If headers array uses 2-element sub-arrays [ [k1, v1], [k2, v2] ]
30 1 ▶ if (@$headers && ref($headers->[0]) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (@$headers and ref $headers->[0] eq 'ARRAY') { } 0 1 1
Condition33%1/3
@$headers and ref $headers->[0] eq "ARRAY"
!ll&&!rl&&r
010
MC/DC0%0/2
@$headers and ref $headers->[0] eq "ARRAY"
@$headers ref $headers->[0] eq "ARRAY"
Truth table33%1/3
A and B
A= @$headersB= ref $headers->[0] eq "ARRAY"
ABresult
0X0
100
111
31 0 for my $key (keys %$out) {
32 0 push @$headers, [ $key => $out->{$key} ];
33 }
34 }
35 # Flat key-value array backup [ k1, v1, k2, v2 ]
36 else {
37 1 for my $key (keys %$out) {
38 2 push @$headers, $key, $out->{$key};
39 }
40 }
41 }
42 ▶ elsif (blessed($res) && $res->can('headers')) {
Condition0%0/3
builtin::blessed($res) and $res->can("headers")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($res) and $res->can("headers")
builtin::blessed($res) $res->can("headers")
Truth table0%0/3
A and B
A= builtin::blessed($res)B= $res->can("headers")
ABresult
0X0
100
111
43 0 for my $key (keys %$out) {
44 0 $res->headers->header($key => $out->{$key});
45 }
46 }
47 ▶ 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
48 0 for my $key (keys %$out) {
49 0 $res->header($key => $out->{$key});
50 }
51 }
52  
53 1 return $res;
54 }
55  
56 3 1;
57  
58 __END__
↑ Summary