| 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
| |||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | if (ref($res) eq 'ARRAY' && ref($res->[1]) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
ref $res eq "ARRAY" and ref $res->[1] eq "ARRAY"
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"
| |||||||||||||||||||||||||||||||||||||
| 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
Condition33%1/3
@$headers and ref $headers->[0] eq "ARRAY"
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"
| |||||||||||||||||||||||||||||||||||||
| 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")
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")
| |||||||||||||||||||||||||||||||||||||
| 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")
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")
| |||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||