Upload.pm

filter: Statementstmt 100% 24 / 24 Branchbran 100% 8 / 8 Conditioncond 83.3% 5 / 6 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 96.0% 48 / 50 CC 7 SCAR 11.5
CC
7
Cov
97%
file
5.0
has_file
3.0
BEGIN
1.0
CRAP 3.2
« Upload/File.pm ↑ Summary
1 package Uniform::Upload;
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 Uniform::Exceptions;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Uniform::Upload::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our $VERSION = '0.01';
9  
10 # Base check method to be extended by concrete subclass constructor maps
11 sub has_file {
12 6 ▶ my ($self, $field) = @_;
Subroutine has_file: called CC=3 SCAR=11.1
Pod documented
13 6 ▶ return (defined $field && exists $self->{files}->{$field}) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $field && exists $self->{'files'}{$field} ? : 4 2 6
Condition66%2/3
defined $field and exists $self->{"files"}{$field}
!ll&&!rl&&r
024
MC/DC50%1/2
defined $field and exists $self->{"files"}{$field}
defined $field exists $self->{"files"}{$field}
Truth table66%2/3
A and B
A= defined $fieldB= exists $self->{"files"}{$field}
ABresult
0X0
100
111
14 }
15  
16 # Accessor method: Retrieves or instantiates the target Uniform::Upload::File object wrapper
17 sub file {
18 6 ▶ my ($self, $field) = @_;
Subroutine file: called CC=5 SCAR=16.1
Pod documented
19  
20 6 ▶ unless (defined $field && length $field) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $field and length $field) 2 4 6
Condition100%3/3
defined $field and length $field
!ll&&!rl&&r
114
MC/DC100%2/2
defined $field and length $field
defined $field length $field
Truth table100%3/3
A and B
A= defined $fieldB= length $field
ABresult
0X0
100
111
21 2 Uniform::Exceptions->throw(
22 type => 'ValidationError',
23 message => 'File method requires a defined input field parameter name',
24 );
25 }
26  
27 4 ▶ unless ($self->has_file($field)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->has_file($field)) 1 3 4
28 1 Uniform::Exceptions->throw(
29 type => 'NotFoundError',
30 message => "No upload data payload found matching field name '$field'",
31 attribute => $field,
32 );
33 }
34  
35 # Lazily wrap the raw file data payload inside the universal File mutator instance
36 3 ▶ unless (ref($self->{files}->{$field}) eq 'Uniform::Upload::File') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self->{"files"}{$field} eq "Uniform::Upload::File") 2 1 3
37 2 $self->{files}->{$field} = Uniform::Upload::File->new($self->{files}->{$field});
38 }
39  
40 3 return $self->{files}->{$field};
41 }
42  
43 2 1;
44  
45 __END__
« Upload/File.pm ↑ Summary