| 1 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## Asynchronous HTTP Request and Promise - ~/lib/HTTP/Promise/Body/Form.pm | ||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Version v0.2.4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Copyright(c) 2025 DEGUEST Pte. Ltd. | ||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ## Created 2022/05/18 | ||||||||||||||||||||||||||||||||||||||||||||||
| 7 | ## Modified 2025/08/30 | ||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ## All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||||
| 9 | ## | ||||||||||||||||||||||||||||||||||||||||||||||
| 10 | ## | ||||||||||||||||||||||||||||||||||||||||||||||
| 11 | ## This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||||||
| 12 | ## under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | package HTTP::Promise::Body::Form; | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 5 | warnings::register_categories( 'HTTP::Promise' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 20 | 5 | ▶ | use parent qw( Module::Generic::Hash ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 5 | ▶ | use vars qw( $VERSION ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # use Nice::Try; | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 5 | ▶ | use URL::Encode::XS (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 5 | our $VERSION = 'v0.2.4'; | |||||||||||||||||||||||||||||||||||||||||||||
| 25 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 22 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=28.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 22 | my $this = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 33 | 22 | ▶ | if( @_ ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 20 | ▶ | if( scalar( @_ ) > 1 ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my $data = [@_]; | |||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | my $ref = $this->decode_to_hash( $data ) || | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$this->decode_to_hash($data) || (return $this->pass_error)
MC/DC0%0/1
$this->decode_to_hash($data) || (return $this->pass_error)
$this->decode_to_hash($data)
Truth table0%0/2
A
A= $this->decode_to_hash($data)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | return( $this->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | return( $this->SUPER::new( $ref ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 20 | my $data = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 45 | 20 | ▶ | if( ref( $data ) eq 'HASH' ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 14 | return( $this->SUPER::new( $data, @_ ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ▶ | elsif( !ref( $data ) || | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition16%1/6
not ref $data or ref $data ne "HASH" and overload::Method($data, "\"\"")
ref $data ne "HASH" and overload::Method($data, "\"\"")
MC/DC0%0/3
not ref $data or ref $data ne "HASH" and overload::Method($data, "\"\"")
not ref $data
ref $data ne "HASH"
overload::Method($data, "\"\"")
Truth table25%1/4
not(A) or B and C
A= not ref $dataB= ref $data ne "HASH"C= overload::Method($data, "\"\"")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ( ref( $data ) ne 'HASH' && overload::Method( $data => '""' ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 6 | ▶ | my $ref = $this->decode_to_hash( "${data}" ) || | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$this->decode_to_hash("$data") || (return $this->pass_error)
MC/DC0%0/1
$this->decode_to_hash("$data") || (return $this->pass_error)
$this->decode_to_hash("$data")
Truth table50%1/2
A
A= $this->decode_to_hash("$data")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | return( $this->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 6 | return( $this->SUPER::new( $ref, @_ ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | return( $this->error( "Unsupported data type '", ref( $data ), "'." ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | return( $this->SUPER::new ); | |||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | sub init | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $self->{_init_strict_use_sub} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | sub as_form_data | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_form_data: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $hash = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $keys = $self->keys->sort; | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | $self->_load_class( 'HTTP::Promise::Body::Form' ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | my $form = HHTP::Promise::Body::Form->new; | |||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | foreach my $n ( @$keys ) | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $v = $self->{ $n }; | |||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if( $self->_is_array( $v ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 87 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | foreach my $v2 ( @$v ) | |||||||||||||||||||||||||||||||||||||||||||||
| 89 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | my $e = $self->_is_a( $v2 => 'HTTP::Promise::Body::Form::Field' ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | ? $v2 | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | : $form->new_field( | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | name => $n, | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | body => $v2, | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if( exists( $form->{ $n } ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | $form->{ $n } = [$form->{ $n }] unless( $self->_is_array( $form->{ $n } ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | push( @{$form->{ $n }}, $e ); | |||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | $form->{ $n } = $e; | |||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | my $e = $self->_is_a( $v => 'HTTP::Promise::Body::Form::Field' ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | ? $v | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | : $form->new_field( | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | name => $n, | ||||||||||||||||||||||||||||||||||||||||||||||
| 113 | body => $v, | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if( exists( $form->{ $n } ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | $form->{ $n } = [$form->{ $n }] unless( $self->_is_array( $form->{ $n } ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | push( @{$form->{ $n }}, $e ); | |||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $form->{ $n } = $e; | |||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | return( $form ); | |||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | sub as_string | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=17 SCAR=34.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 132 | 1 | my $keys = []; | |||||||||||||||||||||||||||||||||||||||||||||
| 133 | 1 | ▶ | if( @_ && $self->_is_array( $_[0] ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ and $self->_is_array($_[0])
MC/DC0%0/2
@_ and $self->_is_array($_[0])
@_
$self->_is_array($_[0])
Truth table33%1/3
A and B
A= @_B= $self->_is_array($_[0])
| |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $keys = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 137 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 1 | $keys = $self->keys->sort; | |||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 1 | my @pairs = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 142 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 1 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | 1 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||
| 145 | # We need to temporarily enable public storage access, so we force enable to true, but put it back to what it was after. | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | ▶ | $obj->enable(1) if( !$flag ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | eval | ||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | { | |||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | foreach my $n ( @$keys ) | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 4 | my $v = $self->{ $n }; | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | 4 | ▶ | if( ref( $v ) eq 'ARRAY' ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | foreach my $v2 ( @$v ) | |||||||||||||||||||||||||||||||||||||||||||||
| 156 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 2 | ▶ | if( $self->_is_a( $v2 => 'HTTP::Promise::Body::Form::Field' ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 158 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | $v2 = $v2->body->as_string( binmode => 'utf-8' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | ▶ | warn( "Found a value, within an array for item '$n', that is a reference (", overload::StrVal( $v2 ), "), but does not stringify.\n" ) if( ref( $v2 ) && !overload::Method( $v2 => '""' ) && $self->_is_warnings_enabled ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $v2 and not overload::Method($v2, "\"\"") and $self->_is_warnings_enabled
ref $v2 and not overload::Method($v2, "\"\"")
MC/DC0%0/3
ref $v2 and not overload::Method($v2, "\"\"") and $self->_is_warnings_enabled
ref $v2
not overload::Method($v2, "\"\"")
$self->_is_warnings_enabled
Truth table25%1/4
A and not(B) and C
A= ref $v2B= not overload::Method($v2, "\"\"")C= $self->_is_warnings_enabled
| |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 2 | push( @pairs, join( '=', $n, URL::Encode::XS::url_encode_utf8( "$v2" ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 3 | ▶ | if( $self->_is_a( $v => 'HTTP::Promise::Body::Form::Field' ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $v = $v->body->as_string( binmode => 'utf-8' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 3 | ▶ | warn( "Found a value, for form item '$n', that is a reference (", overload::StrVal( $v ), "), but does not stringify.\n" ) if( ref( $v ) && !overload::Method( $v => '""' ) && $self->_is_warnings_enabled ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $v and not overload::Method($v, "\"\"") and $self->_is_warnings_enabled
ref $v and not overload::Method($v, "\"\"")
MC/DC0%0/3
ref $v and not overload::Method($v, "\"\"") and $self->_is_warnings_enabled
ref $v
not overload::Method($v, "\"\"")
$self->_is_warnings_enabled
Truth table25%1/4
A and not(B) and C
A= ref $vB= not overload::Method($v, "\"\"")C= $self->_is_warnings_enabled
| |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 3 | push( @pairs, join( '=', $n, URL::Encode::XS::url_encode_utf8( "$v" ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | ▶ | $obj->enable(0) if( !$flag ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | return( $self->error( "Error while Trying to url-encode ", scalar( @$keys ), " form elements: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | return( join( '&', @pairs ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | sub decode { return( shift->decode_to_array( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | sub decode_string | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode_string: called CC=7 SCAR=22.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | 1 | my $data = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 190 | 1 | ▶ | warn( "No data to url-decode was provided.\n" ) if( ( !defined( $data ) || !length( "$data" ) ) && $self->_is_warnings_enabled ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $data && CORE::length "$data" and $self->_is_warnings_enabled
defined $data && CORE::length "$data"
MC/DC0%0/3
not defined $data && CORE::length "$data" and $self->_is_warnings_enabled
defined $data
CORE::length "$data"
$self->_is_warnings_enabled
Truth table20%1/5
not(A && B) and C
A= defined $dataB= CORE::length "$data"C= $self->_is_warnings_enabled
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 1 | ▶ | return( $self->error( "Invalid parameter provided. You can only pass a string or an object that stringifies." ) ) if( ref( $data ) && !overload::Method( $data => '""' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $data and not overload::Method($data, "\"\"")
MC/DC0%0/2
ref $data and not overload::Method($data, "\"\"")
ref $data
not overload::Method($data, "\"\"")
Truth table33%1/3
A and not(B)
A= ref $dataB= not overload::Method($data, "\"\"")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | my $decoded; | |||||||||||||||||||||||||||||||||||||||||||||
| 193 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||
| 195 | eval | ||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 1 | { | |||||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | $decoded = URL::Encode::XS::url_decode_utf8( "${data}" ); | |||||||||||||||||||||||||||||||||||||||||||||
| 198 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | return( $self->error( "Error while Trying to url-decode ", length( $data ), " bytes of data: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | return( $decoded ); | |||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | sub decode_to_array | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 6 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode_to_array: called CC=7 SCAR=22.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 6 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 209 | 6 | my $data = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 210 | # warn( "No data to url-decode was provided.\n" ) if( ( !defined( $data ) || !length( "$data" ) ) && $self->_is_warnings_enabled ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 6 | ▶ | warn( "No data to url-decode was provided.\n" ) if( ( !defined( $data ) || !length( "$data" ) ) && $self->_is_warnings_enabled ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $data && CORE::length "$data" and $self->_is_warnings_enabled
defined $data && CORE::length "$data"
MC/DC0%0/3
not defined $data && CORE::length "$data" and $self->_is_warnings_enabled
defined $data
CORE::length "$data"
$self->_is_warnings_enabled
Truth table20%1/5
not(A && B) and C
A= defined $dataB= CORE::length "$data"C= $self->_is_warnings_enabled
| |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 6 | ▶ | return( $self->error( "Invalid parameter provided. You can only pass a string or an object that stringifies." ) ) if( ref( $data ) && !overload::Method( $data => '""' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $data and not overload::Method($data, "\"\"")
MC/DC0%0/2
ref $data and not overload::Method($data, "\"\"")
ref $data
not overload::Method($data, "\"\"")
Truth table33%1/3
A and not(B)
A= ref $dataB= not overload::Method($data, "\"\"")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 6 | my $ref; | |||||||||||||||||||||||||||||||||||||||||||||
| 214 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 6 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||
| 216 | eval | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 6 | { | |||||||||||||||||||||||||||||||||||||||||||||
| 218 | 6 | $ref = URL::Encode::XS::url_params_flat( "${data}" ); | |||||||||||||||||||||||||||||||||||||||||||||
| 219 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 6 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | return( $self->error( "Error while Trying to url-decode ", length( $data ), " bytes of data: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 6 | return( $ref ); | |||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | sub decode_to_hash | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 6 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode_to_hash: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 6 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 230 | 6 | ▶ | my $ref = $self->_is_array( $_[0] ) ? shift( @_ ) : $self->decode_to_array( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 6 | ▶ | return( $self->pass_error ) if( !defined( $ref ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 6 | my $hash = {}; | |||||||||||||||||||||||||||||||||||||||||||||
| 233 | 6 | ▶ | while( my( $n, $v ) = splice( @$ref, 0, 2 ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 14 | ▶ | if( exists( $hash->{ $n } ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 236 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 3 | ▶ | $hash->{ $n } = [ $hash->{ $n } ] unless( ref( $hash->{ $n } ) eq 'ARRAY' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 3 | push( @{$hash->{ $n }}, $v ); | |||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 240 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 11 | $hash->{ $n } = $v; | |||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 6 | return( $hash ); | |||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # TODO: This is redundant with code in as_string. as_string should be revamped to call encode() | ||||||||||||||||||||||||||||||||||||||||||||||
| 249 | sub encode | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encode: called CC=19 SCAR=40.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 252 | 1 | my $ref = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 253 | 1 | ▶ | return( $self->error( "Invalid argument provided. I was expecting an array or an hash reference." ) ) if( ref( $ref ) ne 'ARRAY' && ref( $ref ) ne 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $ref ne "ARRAY" and ref $ref ne "HASH"
MC/DC0%0/2
ref $ref ne "ARRAY" and ref $ref ne "HASH"
ref $ref ne "ARRAY"
ref $ref ne "HASH"
Truth table33%1/3
A and B
A= ref $ref ne "ARRAY"B= ref $ref ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 254 | # Work on a copy | ||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 1 | ▶ | my $this = ref( $ref ) eq 'ARRAY' ? [@$ref] : [%$ref]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 1 | ▶ | return( '' ) if( !scalar( @$this ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 1 | my $rv; | |||||||||||||||||||||||||||||||||||||||||||||
| 258 | 1 | my @pairs = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | my $obj = $self->_tie_object; | |||||||||||||||||||||||||||||||||||||||||||||
| 260 | # We need to temporarily enable public storage access, so we force enable to true, but put it back to what it was after. | ||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 1 | my $flag = $obj->enable; | |||||||||||||||||||||||||||||||||||||||||||||
| 262 | 1 | ▶ | $obj->enable(1) if( !$flag ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 1 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||
| 265 | eval | ||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | { | |||||||||||||||||||||||||||||||||||||||||||||
| 267 | 1 | ▶ | while( my( $n, $v ) = splice( @$this, 0, 2 ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 268 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 1 | ▶ | if( ref( $v ) eq 'ARRAY' ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 270 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | foreach my $v2 ( @$v ) | |||||||||||||||||||||||||||||||||||||||||||||
| 272 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | if( $self->_is_a( $v2 => 'HTTP::Promise::Body::Form::Field' ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 274 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | $v2 = $v2->body->as_string( binmode => 'utf-8' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | warn( "Found a value, within an array for item '$n', that is a reference, but does not stringifies.\n" ) if( ref( $v2 ) && !overload::Method( $v2 => '""' ) && $self->_is_warnings_enabled ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
ref $v2 and not overload::Method($v2, "\"\"") and $self->_is_warnings_enabled
ref $v2 and not overload::Method($v2, "\"\"")
MC/DC0%0/3
ref $v2 and not overload::Method($v2, "\"\"") and $self->_is_warnings_enabled
ref $v2
not overload::Method($v2, "\"\"")
$self->_is_warnings_enabled
Truth table0%0/4
A and not(B) and C
A= ref $v2B= not overload::Method($v2, "\"\"")C= $self->_is_warnings_enabled
| |||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | push( @pairs, join( '=', $n, URL::Encode::XS::url_encode_utf8( "$v2" ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 281 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 1 | ▶ | if( $self->_is_a( $v => 'HTTP::Promise::Body::Form::Field' ) ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 284 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | $v = $v->body->as_string( binmode => 'utf-8' ); | |||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 1 | ▶ | warn( "Found a value, for item '$n', that is a reference, but does not stringifies.\n" ) if( ref( $v ) && !overload::Method( $v => '""' ) && $self->_is_warnings_enabled ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $v and not overload::Method($v, "\"\"") and $self->_is_warnings_enabled
ref $v and not overload::Method($v, "\"\"")
MC/DC0%0/3
ref $v and not overload::Method($v, "\"\"") and $self->_is_warnings_enabled
ref $v
not overload::Method($v, "\"\"")
$self->_is_warnings_enabled
Truth table25%1/4
A and not(B) and C
A= ref $vB= not overload::Method($v, "\"\"")C= $self->_is_warnings_enabled
| |||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 1 | push( @pairs, join( '=', $n, URL::Encode::XS::url_encode_utf8( "$v" ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 1 | $rv = join( '&', @pairs ); | |||||||||||||||||||||||||||||||||||||||||||||
| 292 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 1 | ▶ | $obj->enable(0) if( !$flag ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 295 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | return( $self->error( "Error while Trying to url-encode ", scalar( @$this ), " elements provided: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 1 | return( $rv ); | |||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||
| 301 | sub encode_string | ||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encode_string: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 1 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 304 | 1 | my $encoded; | |||||||||||||||||||||||||||||||||||||||||||||
| 305 | # try-catch | ||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 1 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||
| 307 | eval | ||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 1 | { | |||||||||||||||||||||||||||||||||||||||||||||
| 309 | 1 | $encoded = URL::Encode::XS::url_encode_utf8( shift( @_ ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 310 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 1 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | return( $self->error( "Error while trying to url-encode: $@" ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 1 | return( $encoded ); | |||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||
| 318 | sub length | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
length: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | require bytes; | |||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | return( bytes::length( shift->as_string( @_ ) ) ); | |||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||
| 324 | sub open | ||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
open: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | my $self = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my $encoded = $self->as_string; | |||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | return( $self->pass_error ) if( !defined( $encoded ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | my $s = $self->new_scalar( \$encoded ) || | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->new_scalar(\$encoded) || (return $self->pass_error)
MC/DC0%0/1
$self->new_scalar(\$encoded) || (return $self->pass_error)
$self->new_scalar(\$encoded)
Truth table0%0/2
A
A= $self->new_scalar(\$encoded)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 330 | return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | my $io = $s->open( @_ ) || | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$s->open(@_) || (return $self->pass_error($s->error))
MC/DC0%0/1
$s->open(@_) || (return $self->pass_error($s->error))
$s->open(@_)
Truth table0%0/2
A
A= $s->open(@_)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 332 | return( $self->pass_error( $s->error ) ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | return( $io ); | |||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||
| 336 | sub print | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | my( $self, $fh ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my $nread; | |||||||||||||||||||||||||||||||||||||||||||||
| 340 | # Get output filehandle, and ensure that it's a printable object: | ||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | $fh ||= select; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$fh ||= select
MC/DC0%0/2
$fh ||= select
$fh
select
Truth table0%0/3
A ||= B
A= $fhB= select
| |||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | return( $self->error( "Filehandle provided ($fh) is not a proper filehandle and its not a HTTP::Promise::IO object." ) ) if( !$self->_is_glob( $fh ) && !$self->_is_a( $fh => 'HTTP::Promise::IO' ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->_is_glob($fh) or $self->_is_a($fh, "HTTP::Promise::IO")
MC/DC0%0/2
$self->_is_glob($fh) or $self->_is_a($fh, "HTTP::Promise::IO")
$self->_is_glob($fh)
$self->_is_a($fh, "HTTP::Promise::IO")
Truth table0%0/3
A or B
A= $self->_is_glob($fh)B= $self->_is_a($fh, "HTTP::Promise::IO")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my $encoded = $self->as_string; | |||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | return( $self->pass_error ) if( !defined( $encoded ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | $fh->print( $encoded ) || return( $self->error( "Unable to print on given filehandle '$fh': $!" ) ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | return(1); | |||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | sub _is_warnings_enabled { return( warnings::enabled( 'HTTP::Promise' ) ); } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_warnings_enabled: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||
| 351 | # NOTE: FREEZE is inherited | ||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||
| 353 | # NOTE: STORABLE_freeze is inherited | ||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||
| 355 | # NOTE: STORABLE_thaw is inherited | ||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||
| 357 | # NOTE: THAW is inherited | ||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 360 | # NOTE: POD | ||||||||||||||||||||||||||||||||||||||||||||||
| 361 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||