| 1 | package Web::ComposableRequest::Base; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use HTTP::Body; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use HTTP::Status qw( HTTP_EXPECTATION_FAILED | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | HTTP_INTERNAL_SERVER_ERROR | ||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | HTTP_REQUEST_ENTITY_TOO_LARGE ); | |||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Scalar::Util qw( weaken ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Web::ComposableRequest::Constants qw( EXCEPTION_CLASS NUL TRUE ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Web::ComposableRequest::Util qw( decode_array decode_hash first_char | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | is_arrayref is_hashref new_uri | ||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | throw ); | |||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Unexpected::Functions qw( Unspecified ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Unexpected::Types qw( ArrayRef CodeRef HashRef LoadableClass | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | NonEmptySimpleStr NonZeroPositiveInt | ||||||||||||||||||||||||||||||||||||||||||
| 18 | Object PositiveInt SimpleStr Str | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | Undef ); | |||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | # Attribute constructors | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 5 | ▶ | my $_build_body = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_body: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 5 | my $content = $self->_content; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 5 | my $len = length $content; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 5 | my $body = HTTP::Body->new($self->content_type, $len); | |||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 5 | $body->cleanup(TRUE); | |||||||||||||||||||||||||||||||||||||||||
| 30 | 5 | $body->tmpdir($self->_config->tempdir); | |||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 5 | ▶ | return $body unless $len; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | ▶ | try { $self->_decode_body($body, $content) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | # uncoverable subroutine | ||||||||||||||||||||||||||||||||||||||||||
| 37 | # uncoverable statement | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | $self->_log->({ level => 'error', message => $_ }); | |||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | return $body; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 5 | ▶ | my $_build__content = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build__content: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 5 | ▶ | my $cl = $self->content_length or return NUL; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | ▶ | my $fh = $self->_env->{ 'psgi.input' } or return NUL; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 2 | my $content = NUL; | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 2 | ▶ | $fh->can( 'seek' ) and $fh->seek( 0, 0 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 2 | $fh->read( $content, $cl, 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | ▶ | $fh->can( 'seek' ) and $fh->seek( 0, 0 ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | # uncoverable subroutine | ||||||||||||||||||||||||||||||||||||||||||
| 57 | # uncoverable statement | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $self->_log->( { level => 'error', message => $_ } ); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | }; | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 2 | return $content; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 3 | ▶ | my $_build_tunnel_method = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_tunnel_method: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 3 | ▶ | return $_[ 0 ]->body_params->( '_method', { optional => TRUE } ) | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%5/5
$_[0]->body_params->('_method', {'optional', 1}) || $_[0]->query_params->('_method', {'optional', 1}) || 'not_found'
$_[0]->body_params->("_method", {"optional", 1}) or $_[0]->query_params->("_method", {"optional", 1})
MC/DC100%2/2
$_[0]->body_params->('_method', {'optional', 1}) || $_[0]->query_params->('_method', {'optional', 1}) || 'not_found'
$_[0]->body_params->("_method", {"optional", 1})
$_[0]->query_params->("_method", {"optional", 1})
Truth table100%3/3
A or B
A= $_[0]->body_params->("_method", {"optional", 1})B= $_[0]->query_params->("_method", {"optional", 1})
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | || $_[ 0 ]->query_params->( '_method', { optional => TRUE } ) | ||||||||||||||||||||||||||||||||||||||||||
| 67 | || 'not_found'; | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | # Public attributes | ||||||||||||||||||||||||||||||||||||||||||
| 71 | has 'address' => is => 'lazy', isa => SimpleStr, | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | ▶ | builder => sub { $_[ 0 ]->_env->{ 'REMOTE_ADDR' } // NUL }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_address: called CC=2 SCAR=7.2
Condition50%1/2
$_[0]->_env->{"REMOTE_ADDR"} // ""
MC/DC0%0/1
$_[0]->_env->{"REMOTE_ADDR"} // ""
$_[0]->_env->{"REMOTE_ADDR"}
Truth table50%1/2
A
A= $_[0]->_env->{"REMOTE_ADDR"}
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | has 'base' => is => 'lazy', isa => Object, | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | ▶ | builder => sub { new_uri $_[ 0 ]->scheme, $_[ 0 ]->_base }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_base: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | init_arg => undef; | |||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | has 'body' => is => 'lazy', isa => Object, builder => $_build_body; | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | has 'content_length' => is => 'lazy', isa => PositiveInt, | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 5 | ▶ | builder => sub { $_[ 0 ]->_env->{ 'CONTENT_LENGTH' } // 0 }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Condition100%2/2
$_[0]->_env->{"CONTENT_LENGTH"} // 0
MC/DC100%1/1
$_[0]->_env->{"CONTENT_LENGTH"} // 0
$_[0]->_env->{"CONTENT_LENGTH"}
Truth table100%2/2
A
A= $_[0]->_env->{"CONTENT_LENGTH"}
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | has 'content_type' => is => 'lazy', isa => SimpleStr, | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 5 | ▶ | builder => sub { $_[ 0 ]->_env->{ 'CONTENT_TYPE' } // NUL }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Condition100%2/2
$_[0]->_env->{"CONTENT_TYPE"} // ""
MC/DC100%1/1
$_[0]->_env->{"CONTENT_TYPE"} // ""
$_[0]->_env->{"CONTENT_TYPE"}
Truth table100%2/2
A
A= $_[0]->_env->{"CONTENT_TYPE"}
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | has 'host' => is => 'lazy', isa => NonEmptySimpleStr, | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | ▶ | builder => sub { (split m{ : }mx, $_[ 0 ]->hostport)[ 0 ] }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_host: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | has 'hostport' => is => 'lazy', isa => NonEmptySimpleStr, | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 2 | ▶ | builder => sub { $_[ 0 ]->_env->{ 'HTTP_HOST' } // 'localhost' }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Condition50%1/2
$_[0]->_env->{"HTTP_HOST"} // "localhost"
MC/DC0%0/1
$_[0]->_env->{"HTTP_HOST"} // "localhost"
$_[0]->_env->{"HTTP_HOST"}
Truth table50%1/2
A
A= $_[0]->_env->{"HTTP_HOST"}
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | has 'method' => is => 'lazy', isa => SimpleStr, | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 1 | ▶ | builder => sub { lc( $_[ 0 ]->_env->{ 'REQUEST_METHOD' } // NUL )}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_method: called CC=2 SCAR=7.2
Condition50%1/2
$_[0]->_env->{"REQUEST_METHOD"} // ""
MC/DC0%0/1
$_[0]->_env->{"REQUEST_METHOD"} // ""
$_[0]->_env->{"REQUEST_METHOD"}
Truth table50%1/2
A
A= $_[0]->_env->{"REQUEST_METHOD"}
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | ▶ | has 'path' => is => 'lazy', isa => SimpleStr, builder => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | ▶ | my $v = $_[ 0 ]->_env->{ 'PATH_INFO' } // '/'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_[0]->_env->{"PATH_INFO"} // "/"
MC/DC0%0/1
$_[0]->_env->{"PATH_INFO"} // "/"
$_[0]->_env->{"PATH_INFO"}
Truth table50%1/2
A
A= $_[0]->_env->{"PATH_INFO"}
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | $v =~ s{ \A / }{}mx; $v =~ s{ \? .* \z }{}mx; $v }; | |||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | has 'port' => is => 'lazy', isa => NonZeroPositiveInt, | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | ▶ | builder => sub { $_[ 0 ]->_env->{ 'SERVER_PORT' } // 80 }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Condition50%1/2
$_[0]->_env->{"SERVER_PORT"} // 80
MC/DC0%0/1
$_[0]->_env->{"SERVER_PORT"} // 80
$_[0]->_env->{"SERVER_PORT"}
Truth table50%1/2
A
A= $_[0]->_env->{"SERVER_PORT"}
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | has 'protocol' => is => 'lazy', isa => NonEmptySimpleStr, | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | ▶ | builder => sub { $_[ 0 ]->_env->{ 'SERVER_PROTOCOL' } }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 1 | ▶ | has 'query' => is => 'lazy', isa => Str, builder => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | ▶ | my $v = $_[ 0 ]->_env->{ 'QUERY_STRING' }; $v ? "?${v}" : NUL }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | has 'referer' => is => 'lazy', isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | ▶ | builder => sub { $_[ 0 ]->_env->{ 'HTTP_REFERER' } // NUL }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Condition50%1/2
$_[0]->_env->{"HTTP_REFERER"} // ""
MC/DC0%0/1
$_[0]->_env->{"HTTP_REFERER"} // ""
$_[0]->_env->{"HTTP_REFERER"}
Truth table50%1/2
A
A= $_[0]->_env->{"HTTP_REFERER"}
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | has 'remote_host' => is => 'lazy', isa => SimpleStr, | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | ▶ | builder => sub { $_[ 0 ]->_env->{ 'REMOTE_HOST' } // NUL }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_remote_host: called CC=2 SCAR=7.2
Condition50%1/2
$_[0]->_env->{"REMOTE_HOST"} // ""
MC/DC0%0/1
$_[0]->_env->{"REMOTE_HOST"} // ""
$_[0]->_env->{"REMOTE_HOST"}
Truth table50%1/2
A
A= $_[0]->_env->{"REMOTE_HOST"}
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | has 'scheme' => is => 'lazy', isa => NonEmptySimpleStr, | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 3 | ▶ | builder => sub { $_[ 0 ]->_env->{ 'psgi.url_scheme' } // 'http' }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_scheme: called CC=2 SCAR=7.2
Condition50%1/2
$_[0]->_env->{"psgi.url_scheme"} // "http"
MC/DC0%0/1
$_[0]->_env->{"psgi.url_scheme"} // "http"
$_[0]->_env->{"psgi.url_scheme"}
Truth table50%1/2
A
A= $_[0]->_env->{"psgi.url_scheme"}
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | ▶ | has 'script' => is => 'lazy', isa => SimpleStr, builder => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_script: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | ▶ | my $v = $_[ 0 ]->_env->{ 'SCRIPT_NAME' } // '/'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$_[0]->_env->{"SCRIPT_NAME"} // "/"
MC/DC0%0/1
$_[0]->_env->{"SCRIPT_NAME"} // "/"
$_[0]->_env->{"SCRIPT_NAME"}
Truth table50%1/2
A
A= $_[0]->_env->{"SCRIPT_NAME"}
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | $v =~ s{ / \z }{}gmx; $v }; | |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 1 | has 'tunnel_method' => is => 'lazy', isa => NonEmptySimpleStr, | |||||||||||||||||||||||||||||||||||||||||
| 122 | builder => $_build_tunnel_method; | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 1 | has 'upload' => is => 'lazy', isa => Object | Undef, | |||||||||||||||||||||||||||||||||||||||||
| 125 | predicate => TRUE; | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | ▶ | has 'uri' => is => 'lazy', isa => Object, builder => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | new_uri $_[ 0 ]->scheme, $_[ 0 ]->_base.$_[ 0 ]->path.$_[ 0 ]->query }; | |||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | # Private attributes | ||||||||||||||||||||||||||||||||||||||||||
| 131 | has '_args' => is => 'ro', isa => ArrayRef, | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 5 | ▶ | builder => sub { [] }, init_arg => 'args'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build__args: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 2 | ▶ | has '_base' => is => 'lazy', isa => NonEmptySimpleStr, builder => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 2 | $_[ 0 ]->scheme.'://'.$_[ 0 ]->hostport.$_[ 0 ]->script.'/' }; | |||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | has '_config' => is => 'ro', isa => Object, | |||||||||||||||||||||||||||||||||||||||||
| 138 | required => TRUE, init_arg => 'config'; | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 1 | has '_content' => is => 'lazy', isa => Str, | |||||||||||||||||||||||||||||||||||||||||
| 141 | builder => $_build__content; | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 1 | has '_env' => is => 'ro', isa => HashRef, | |||||||||||||||||||||||||||||||||||||||||
| 144 | init_arg => 'env', required => TRUE; | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | has '_log' => is => 'lazy', isa => CodeRef, | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | ▶ | builder => sub { $_[ 0 ]->_env->{ 'psgix.logger' } // sub {} }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=9.2
Subroutine
__ANON__: called CC=1 SCAR=1.2
Condition33%1/3
$_[0]->_env->{"psgix.logger"} // sub {
}
MC/DC0%0/2
$_[0]->_env->{"psgix.logger"} // sub {
}
$_[0]->_env->{"psgix.logger"}
sub {
}
Truth table33%1/3
A // B
A= $_[0]->_env->{"psgix.logger"}B= sub {
}
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | init_arg => 'log'; | |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | has '_params' => is => 'ro', isa => HashRef, | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 2 | ▶ | builder => sub { {} }, init_arg => 'params'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build__params: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | # Construction | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 7 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 7 | my $enc = $self->_config->encoding; | |||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 7 | decode_array $enc, $self->_args; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 7 | decode_hash $enc, $self->_params; | |||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | # Private functions | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 39 | ▶ | my $_defined_or_throw = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 39 | ▶ | my ($k, $v, $opts) = @_; $opts->{optional} and return $v; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 11 | ▶ | $k =~ m{ \A \d+ \z }mx and $k = "arg[${k}]"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 11 | ▶ | defined $v or throw 'Parameter [_1] undefined value', [ $k ], | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | level => 6, rv => HTTP_EXPECTATION_FAILED; | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 11 | return $v; | |||||||||||||||||||||||||||||||||||||||||
| 174 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | my $_get_last_value = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my ($k, $v, $opts) = @_; return $_defined_or_throw->( $k, $v->[-1], $opts ); | |||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 39 | ▶ | my $_get_value_or_values = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 39 | my ($params, $name, $opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 39 | ▶ | defined $name or throw Unspecified, [ 'name' ], | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | level => 5, rv => HTTP_INTERNAL_SERVER_ERROR; | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | ▶ | my $v = (is_arrayref $params and $name eq '-1') ? [ @{ $params } ] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | : (is_arrayref $params ) ? $params->[ $name ] | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 4 | : ( $name eq '-1') ? { %{ $params } } | |||||||||||||||||||||||||||||||||||||||||
| 189 | 39 | ▶ | : $params->{ $name }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
&is_arrayref($params) and $name eq -1
MC/DC100%2/2
&is_arrayref($params) and $name eq -1
&is_arrayref($params)
$name eq -1
Truth table100%3/3
A and B
A= &is_arrayref($params)B= $name eq -1
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 39 | return $_defined_or_throw->( $name, $v, $opts ); | |||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 38 | ▶ | my $_get_defined_value = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 38 | my ($params, $name, $opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 38 | my $v = $_get_value_or_values->( $params, $name, $opts ); | |||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 38 | ▶ | return (is_arrayref $v) ? $_get_last_value->( $name, $v, $opts ) : $v; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | ▶ | my $_get_defined_values = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | my ($params, $name, $opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | my $v = $_get_value_or_values->( $params, $name, $opts ); | |||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | ▶ | return (is_arrayref $v) ? $v : [ $v ]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 47 | ▶ | my $_scrub_value = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.8
| |||||||||||||||||||||||||||||||||||||||||||
| 211 | 47 | my ($name, $v, $opts) = @_; my $pattern = $opts->{scrubber}; my $len; | |||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 47 | ▶ | $pattern and defined $v and $v =~ s{ $pattern }{}gmx; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$pattern and defined $v
MC/DC50%1/2
$pattern and defined $v
$pattern
defined $v
Truth table66%2/3
A and B
A= $patternB= defined $v
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 47 | ▶ | $name =~ m{ \A [\-]? \d+ \z }mx and $name = "arg[${name}]"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 47 | ▶ | $opts->{optional} or $opts->{allow_null} or $len = length $v | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$opts->{"optional"} or $opts->{"allow_null"} or $len = length $v
$opts->{"optional"} or $opts->{"allow_null"}
MC/DC0%0/3
$opts->{"optional"} or $opts->{"allow_null"} or $len = length $v
$opts->{"optional"}
$opts->{"allow_null"}
$len = length $v
Truth table50%2/4
A or B or C
A= $opts->{"optional"}B= $opts->{"allow_null"}C= $len = length $v
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | or throw Unspecified, [ $name ], level => 4, | ||||||||||||||||||||||||||||||||||||||||||
| 219 | rv => HTTP_EXPECTATION_FAILED; | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | $len and $len > $opts->{max_length} | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 47 | ▶ | and throw 'Parameter [_1] size [_2] too big', [ $name, $len ], level => 4, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$len and $len > $opts->{"max_length"}
MC/DC0%0/2
$len and $len > $opts->{"max_length"}
$len
$len > $opts->{"max_length"}
Truth table66%2/3
A and B
A= $lenB= $len > $opts->{"max_length"}
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | rv => HTTP_REQUEST_ENTITY_TOO_LARGE; | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 47 | return $v; | |||||||||||||||||||||||||||||||||||||||||
| 225 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 4 | ▶ | my $_scrub_hash = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 4 | my ($params, $opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 4 | my $hash = $_get_defined_value->( $params, -1, $opts ); | |||||||||||||||||||||||||||||||||||||||||
| 231 | 4 | my @keys = keys %{ $hash }; | |||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 4 | for my $k (@keys) { | |||||||||||||||||||||||||||||||||||||||||
| 234 | 8 | my $v = delete $hash->{ $k }; | |||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | $hash->{ $_scrub_value->( 'key', $k, $opts ) } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | = (is_arrayref $v && $opts->{multiple}) ? | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | [ map { $_scrub_value->( $k, $_, $opts ) } @{ $v } ] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
&is_arrayref($v) and $opts->{"multiple"}
MC/DC0%0/2
&is_arrayref($v) and $opts->{"multiple"}
&is_arrayref($v)
$opts->{"multiple"}
Truth table33%1/3
A and B
A= &is_arrayref($v)B= $opts->{"multiple"}
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | : (is_arrayref $v) ? $_get_last_value->( $k, $v, $opts ) | ||||||||||||||||||||||||||||||||||||||||||
| 240 | : $_scrub_value->( $k, $v, $opts ); | ||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 4 | return $hash; | |||||||||||||||||||||||||||||||||||||||||
| 244 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | 39 | ▶ | my $_get_scrubbed_param = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=21.3
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 39 | ▶ | my ($self, $params, $name, $opts) = @_; $opts = { %{ $opts // {} } }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opts // {}
MC/DC100%1/1
$opts // {}
$opts
Truth table100%2/2
A
A= $opts
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 39 | ▶ | $opts->{max_length} //= $self->_config->max_asset_size; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts->{"max_length"} //= $self->_config->max_asset_size
MC/DC0%0/2
$opts->{"max_length"} //= $self->_config->max_asset_size
$opts->{"max_length"}
$self->_config->max_asset_size
Truth table33%1/3
A //= B
A= $opts->{"max_length"}B= $self->_config->max_asset_size
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | 39 | ▶ | $opts->{scrubber } //= $self->_config->scrubber; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts->{"scrubber"} //= $self->_config->scrubber
MC/DC0%0/2
$opts->{"scrubber"} //= $self->_config->scrubber
$opts->{"scrubber"}
$self->_config->scrubber
Truth table33%1/3
A //= B
A= $opts->{"scrubber"}B= $self->_config->scrubber
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 39 | ▶ | $opts->{hashref } and return $_scrub_hash->( $params, $opts ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | $opts->{multiple } and return | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 3 | ▶ | [ map { $opts->{raw} ? $_ : $_scrub_value->( $name, $_, $opts ) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 35 | ▶ | @{ $_get_defined_values->( $params, $name, $opts ) } ]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 34 | my $v = $_get_defined_value->( $params, $name, $opts ); | |||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 34 | ▶ | return $opts->{raw} ? $v : $_scrub_value->( $name, $v, $opts ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | # Private methods | ||||||||||||||||||||||||||||||||||||||||||
| 262 | 1 | ▶ | sub _decode_body { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_body: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | 1 | my ($self, $body, $content) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 1 | $body->add( $content ); | |||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | decode_hash $self->_config->encoding, $body->param; | |||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | # Public methods | ||||||||||||||||||||||||||||||||||||||||||
| 272 | 8 | ▶ | sub body_params { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
body_params: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | 8 | my $self = shift; weaken( $self ); | |||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 8 | my $params = $self->body->param; | |||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 8 | ▶ | weaken($params) if ref $params; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | 8 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.3
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | return $_get_scrubbed_param->( | ||||||||||||||||||||||||||||||||||||||||||
| 281 | $self, $params, (defined $_[0] && !is_hashref $_[0]) | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 8 | ▶ | ? @_ : (-1, { hashref => TRUE, %{ $_[0] // {} } }) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
defined $_[0] and not &is_hashref($_[0])
$_[0] // {}
MC/DC50%1/2
defined $_[0] and not &is_hashref($_[0])
defined $_[0]
not &is_hashref($_[0])
MC/DC0%0/1
$_[0] // {}
$_[0]
Truth table66%2/3
A and not(B)
A= defined $_[0]B= not &is_hashref($_[0])
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 284 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | 27 | ▶ | sub query_params { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query_params: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | 27 | my $self = shift; weaken( $self ); | |||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 27 | my $params = $self->_params; weaken( $params ); | |||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | 27 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.3
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | return $_get_scrubbed_param->( | ||||||||||||||||||||||||||||||||||||||||||
| 294 | $self, $params, (defined $_[0] && !is_hashref $_[0]) | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 27 | ▶ | ? @_ : (-1, { hashref => TRUE, %{ $_[0] // {} } }) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
defined $_[0] and not &is_hashref($_[0])
$_[0] // {}
MC/DC50%1/2
defined $_[0] and not &is_hashref($_[0])
defined $_[0]
not &is_hashref($_[0])
MC/DC0%0/1
$_[0] // {}
$_[0]
Truth table66%2/3
A and not(B)
A= defined $_[0]B= not &is_hashref($_[0])
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 27 | }; | |||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | 3 | ▶ | sub uri_for { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uri_for: called CC=15 SCAR=32.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 301 | 3 | ▶ | my ($self, $path, @args) = @_; $path //= NUL; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$path //= ""
MC/DC0%0/1
$path //= ""
$path
Truth table50%1/2
A
A= $path
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 3 | my $base = $self->_base; | |||||||||||||||||||||||||||||||||||||||||
| 304 | 3 | my @query_params = (); | |||||||||||||||||||||||||||||||||||||||||
| 305 | 3 | my $uri_params = []; | |||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 3 | ▶ | if (is_arrayref $args[0]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 1 | $uri_params = shift @args; | |||||||||||||||||||||||||||||||||||||||||
| 309 | 1 | @query_params = @args; | |||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | elsif (is_hashref $args[0]) { | ||||||||||||||||||||||||||||||||||||||||||
| 312 | 1 | ▶ | $uri_params = $args[0]->{uri_params } // []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args[0]{"uri_params"} // []
MC/DC0%0/1
$args[0]{"uri_params"} // []
$args[0]{"uri_params"}
Truth table50%1/2
A
A= $args[0]{"uri_params"}
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | 1 | ▶ | @query_params = @{ $args[0]->{query_params} // [] }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args[0]{"query_params"} // []
MC/DC0%0/1
$args[0]{"query_params"} // []
$args[0]{"query_params"}
Truth table50%1/2
A
A= $args[0]{"query_params"}
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | 1 | ▶ | $base = $args[0]->{base} if $args[0]->{base}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | 3 | ▶ | $path = $base.$path if first_char $path ne '/'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | 3 | ▶ | if ($uri_params->[0]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 2 | ▶ | if ($path =~ m{ \* }mx) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | for my $arg (grep { defined and length } @{$uri_params}) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $_ && length $_
MC/DC0%0/2
defined $_ && length $_
defined $_
length $_
Truth table0%0/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | if ($path =~ m{ \* }mx) { $path =~ s{ \* }{$arg}mx } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | else { $path = "${path}/${arg}" } | |||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 328 | 2 | ▶ | $path = join '/', $path, grep { defined and length } @{$uri_params}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
defined $_ && length $_
MC/DC0%0/2
defined $_ && length $_
defined $_
length $_
Truth table33%1/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 3 | my $uri = new_uri $self->scheme, $path; | |||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | 3 | ▶ | $uri->query_form(@query_params) if $query_params[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 3 | return $uri; | |||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | 4 | ▶ | sub uri_params { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uri_params: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 4 | my $self = shift; weaken( $self ); | |||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | 4 | my $params = $self->_args; weaken( $params ); | |||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | 4 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.3
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | return $_get_scrubbed_param-> | ||||||||||||||||||||||||||||||||||||||||||
| 346 | ( $self, $params, (defined $_[ 0 ] && !is_hashref $_[ 0 ]) | ||||||||||||||||||||||||||||||||||||||||||
| 347 | 4 | ▶ | ? @_ : (-1, { %{ $_[ 0 ] // {} }, multiple => TRUE }) ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
defined $_[0] and not &is_hashref($_[0])
$_[0] // {}
MC/DC50%1/2
defined $_[0] and not &is_hashref($_[0])
defined $_[0]
not &is_hashref($_[0])
MC/DC0%0/1
$_[0] // {}
$_[0]
Truth table66%2/3
A and not(B)
A= defined $_[0]B= not &is_hashref($_[0])
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | __END__ | ||||||||||||||||||||||||||||||||||||||||||