| 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
Condition66%2/3
defined $field and exists $self->{"files"}{$field}
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}
| |||||||||||||||||||||||||||||
| 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
Condition100%3/3
defined $field and length $field
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||