blib/lib/Raisin/Request.pm

filter: Statementstmt 100% 31 / 31 Branchbran 100% 8 / 8 Conditioncond 77.7% 7 / 9 MC/DCmcdc 40.0% 2 / 5 Subroutinesub 100% 6 / 6 Podpod 100% 3 / 3 totaltotal 91.9% 57 / 62 CC 10 SCAR 19.5
CC
10
Cov
96%
prepare_params
10.0
BEGIN
1.0
BEGIN
1.0
CRAP 7.0
« blib/lib/Raisin/Routes/Endpoint.pm ↑ Summary blib/lib/Raisin/Middleware/Formatter.pm »
1 #!perl
2 #PODNAME: Raisin::Request
3 #ABSTRACT: Request class for Raisin.
4  
5 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 package Raisin::Request;
9 15 $Raisin::Request::VERSION = '0.94';
10 15 ▶use parent 'Plack::Request';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 41 ▶sub prepare_params {
Subroutine prepare_params: called CC=10 SCAR=23.0
Pod documented
13 41 my ($self, $declared, $named) = @_;
14  
15 41 $self->{'raisin.declared'} = $declared;
16  
17 # PRECEDENCE:
18 # - path
19 # - query
20 # - body
21 my %params = (
22 41 ▶ %{ $self->env->{'raisinx.body_params'} || {} },
Condition100%2/2
$self->env->{'raisinx.body_params'} || {}
l!l
1328
MC/DC100%1/1
$self->env->{'raisinx.body_params'} || {}
$self->env->{'raisinx.body_params'}
Truth table100%2/2
A
A= $self->env->{'raisinx.body_params'}
Aresult
11
00
23 41 ▶ %{ $self->query_parameters->as_hashref_mixed || {} },
Condition50%1/2
$self->query_parameters->as_hashref_mixed || {}
l!l
410
MC/DC0%0/1
$self->query_parameters->as_hashref_mixed || {}
$self->query_parameters->as_hashref_mixed
Truth table50%1/2
A
A= $self->query_parameters->as_hashref_mixed
Aresult
11
00
24 41 ▶ %{ $named || {} },
Condition100%2/2
$named || {}
l!l
338
MC/DC100%1/1
$named || {}
$named
Truth table100%2/2
A
A= $named
Aresult
11
00
25 );
26  
27 41 $self->{'raisin.parameters'} = \%params;
28  
29 41 my $retval = 1;
30  
31 41 foreach my $p (@$declared) {
32 69 my $name = $p->name;
33 69 my $value = $params{$name};
34  
35 69 ▶ if (not $p->validate(\$value)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($p->validate(\$value)) 3 66 69
36 3 $retval = 0;
37 3 ▶ $p->required ? return : next;
Branch: 1 branch
BranchTrueFalseTotal
$p->required ? : 2 1 3
38 }
39  
40 66 ▶ $value //= $p->default if defined $p->default;
Branch: 1 branch
BranchTrueFalseTotal
if defined $p->default 12 54 66
Condition66%2/3
$value //= $p->default
l!l&&r!l&&!r
1110
MC/DC0%0/2
$value //= $p->default
$value $p->default
Truth table66%2/3
A //= B
A= $valueB= $p->default
ABresult
1X1
011
000
41 66 ▶ next if not defined($value);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 8 58 66
42  
43 58 $self->{'raisin.declared_params'}{$name} = $value;
44 }
45  
46 39 $retval;
47 }
48  
49 35 ▶sub declared_params { shift->{'raisin.declared_params'} }
Subroutine declared_params: called CC=1 SCAR=0.0
Pod documented
50 4 ▶sub raisin_parameters { shift->{'raisin.parameters'} }
Subroutine raisin_parameters: called CC=1 SCAR=0.0
Pod documented
51  
52 15 1;
53  
54 __END__
« blib/lib/Raisin/Routes/Endpoint.pm ↑ Summary blib/lib/Raisin/Middleware/Formatter.pm »