blib/lib/Uniform/Upload/PAGI.pm

filter: Statementstmt 93.3% 28 / 30 Branchbran 60.0% 6 / 10 Conditioncond 46.1% 6 / 13 MC/DCmcdc 12.5% 1 / 8 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 70.1% 47 / 67 CC 12 SCAR 25.8
CC
12
Cov
75%
new
17.3
BEGIN
1.0
BEGIN
1.0
CRAP 13.2
↑ Summary
1 package Uniform::Upload::PAGI;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use parent 'Uniform::Upload';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our $VERSION = '1.01';
9  
10 # Constructor: Explicitly expects an asynchronous PAGI HTTP connection scope hash reference
11 sub new {
12 2 ▶ my ($class, $scope) = @_;
Subroutine new: called CC=12 SCAR=28.5
Pod documented
13  
14 2 ▶ unless (defined $scope && ref($scope) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $scope and ref $scope eq "HASH") 0 2 2
Condition33%1/3
defined $scope and ref $scope eq "HASH"
!ll&&!rl&&r
002
MC/DC0%0/2
defined $scope and ref $scope eq "HASH"
defined $scope ref $scope eq "HASH"
Truth table33%1/3
A and B
A= defined $scopeB= ref $scope eq "HASH"
ABresult
0X0
100
111
15 0 require Uniform::Exceptions;
16 0 Uniform::Exceptions->throw(
17 type => 'TypeError',
18 message => 'PAGI scope context must be a strict HASH reference',
19 );
20 }
21  
22 2 ▶ unless (defined $scope->{type} && $scope->{type} eq 'http') {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $scope->{"type"} and $scope->{"type"} eq "http") 1 1 2
Condition66%2/3
defined $scope->{"type"} and $scope->{"type"} eq "http"
!ll&&!rl&&r
011
MC/DC50%1/2
defined $scope->{"type"} and $scope->{"type"} eq "http"
defined $scope->{"type"} $scope->{"type"} eq "http"
Truth table66%2/3
A and B
A= defined $scope->{"type"}B= $scope->{"type"} eq "http"
ABresult
0X0
100
111
23 1 require Uniform::Exceptions;
24 1 Uniform::Exceptions->throw(
25 type => 'ValidationError',
26 message => 'Not a valid PAGI HTTP connection scope',
27 );
28 }
29  
30 1 my $self = bless { files => {}, _ctx => $scope }, $class;
31  
32 # Extract PAGI multipart attachments if parsed by the gateway pipeline.
33 # The PAGI spec exposes uploaded files inside an array reference block: $scope->{uploads}
34 # where each element is a hash containing: field, tempname, filename, size, and type.
35 1 ▶ my $uploads = $scope->{uploads} || [];
Condition50%1/2
$scope->{'uploads'} || []
l!l
10
MC/DC0%0/1
$scope->{'uploads'} || []
$scope->{'uploads'}
Truth table50%1/2
A
A= $scope->{'uploads'}
Aresult
11
00
36 1 ▶ if (ref($uploads) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $uploads eq "ARRAY") 1 0 1
37 1 foreach my $upload_payload (@$uploads) {
38 2 ▶ next unless ref($upload_payload) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $upload_payload eq "HASH" 0 2 2
39  
40 2 my $field = $upload_payload->{field};
41 2 ▶ next unless defined $field && length $field;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $field and length $field 0 2 2
Condition33%1/3
defined $field and length $field
!ll&&!rl&&r
002
MC/DC0%0/2
defined $field and length $field
defined $field length $field
Truth table33%1/3
A and B
A= defined $fieldB= length $field
ABresult
0X0
100
111
42  
43 # Map values explicitly to match your core layout specification expectations.
44 # If duplicate field keys are passed, the trailing definition overrides prior entries,
45 # respecting the strict last-scalar-wins policy standard of your ecosystem.
46 $self->{files}->{$field} = {
47 tempname => $upload_payload->{tempname},
48 filename => $upload_payload->{filename},
49 size => $upload_payload->{size} || 0,
50 type => $upload_payload->{type},
51 2 ▶ };
Condition50%1/2
$upload_payload->{'size'} || 0
l!l
20
MC/DC0%0/1
$upload_payload->{'size'} || 0
$upload_payload->{'size'}
Truth table50%1/2
A
A= $upload_payload->{'size'}
Aresult
11
00
52 }
53 }
54  
55 1 return $self;
56 }
57  
58 2 1;
59  
60 __END__
↑ Summary