blib/lib/Uniform/HTMX/Mojolicious.pm

filter: Statementstmt 100% 35 / 35 Branchbran 66.6% 4 / 6 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 86.6% 52 / 60 CC 8 SCAR 12.4
CC
8
Cov
89%
apply
5.5
new
4.0
BEGIN
1.0
CRAP 3.5
↑ Summary
1 package Uniform::HTMX::Mojolicious;
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=4 SCAR=13.9
Pod documented
12 3 my ($class, $c) = @_;
13  
14 3 ▶ croak "Constructor requires a Mojolicious controller object"
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($c) and $c->isa("Mojolicious::Controller") 1 2 3
Condition66%2/3
builtin::blessed($c) and $c->isa("Mojolicious::Controller")
!ll&&!rl&&r
102
MC/DC50%1/2
builtin::blessed($c) and $c->isa("Mojolicious::Controller")
builtin::blessed($c) $c->isa("Mojolicious::Controller")
Truth table66%2/3
A and B
A= builtin::blessed($c)B= $c->isa("Mojolicious::Controller")
ABresult
0X0
100
111
15 unless blessed($c) && $c->isa('Mojolicious::Controller');
16  
17 # Extract HTTP headers from Mojo::Headers object into CGI-style key hash
18 2 my $headers = $c->req->headers;
19 2 my %env;
20  
21 2 for my $name (@{ $headers->names }) {
22 4 my $key = uc($name);
23 4 $key =~ s/-/_/g;
24 4 $env{"HTTP_$key"} = $headers->header($name);
25 }
26  
27 2 return $class->SUPER::new(in => \%env, env => \%env);
28 }
29  
30 1 ▶sub apply {
Subroutine apply: called CC=5 SCAR=17.0
Pod documented
31 1 my ($self, $c) = @_;
32  
33 1 ▶ croak "apply() requires a Mojolicious controller object"
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($c) and $c->isa("Mojolicious::Controller") 0 1 1
Condition33%1/3
builtin::blessed($c) and $c->isa("Mojolicious::Controller")
!ll&&!rl&&r
001
MC/DC0%0/2
builtin::blessed($c) and $c->isa("Mojolicious::Controller")
builtin::blessed($c) $c->isa("Mojolicious::Controller")
Truth table33%1/3
A and B
A= builtin::blessed($c)B= $c->isa("Mojolicious::Controller")
ABresult
0X0
100
111
34 unless blessed($c) && $c->isa('Mojolicious::Controller');
35  
36 1 my $out = $self->_out;
37 1 ▶ return $c unless %$out;
Branch: 1 branch
BranchTrueFalseTotal
unless %$out 0 1 1
38  
39 1 my $res_headers = $c->res->headers;
40 1 for my $key (keys %$out) {
41 2 $res_headers->header($key => $out->{$key});
42 }
43  
44 1 return $c;
45 }
46  
47 3 1;
48  
49 __END__
↑ Summary