| 1 | package Uniform::Upload; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use Uniform::Utils qw(parse_size_limit); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Uniform::Exceptions; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Uniform::Upload::File; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 3 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 13 | 2 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | 2 | my $max_bytes; | |||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | if (defined $args{max_size}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 17 | 2 | my $limit = $args{max_size}; | |||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | $limit =~ s/b$//i if $limit =~ /[a-z]$/i; # Strip trailing 'B' or 'b' (e.g. '2MB' -> '2M') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 19 | 2 | $max_bytes = parse_size_limit($limit); | |||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | my $self = { | ||||||||||||||||||||||||||||||||
| 23 | max_size => $max_bytes, | ||||||||||||||||||||||||||||||||
| 24 | allowed_types => $args{allowed_types} || [], | ||||||||||||||||||||||||||||||||
| 25 | file_class => $args{file_class} || 'Uniform::Upload::File', | ||||||||||||||||||||||||||||||||
| 26 | in => $args{in} || undef, | ||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | }; | ||||||||||||||||||||||||||||||
|
Condition83%5/6
$args{'allowed_types'} || []
$args{'file_class'} || 'Uniform::Upload::File'
$args{'in'} || undef
MC/DC100%1/1
$args{'allowed_types'} || []
$args{'allowed_types'}
MC/DC0%0/1
$args{'file_class'} || 'Uniform::Upload::File'
$args{'file_class'}
MC/DC100%1/1
$args{'in'} || undef
$args{'in'}
Truth table100%2/2
A
A= $args{'allowed_types'}
Truth table50%1/2
A
A= $args{'file_class'}
Truth table100%2/2
A
A= $args{'in'}
| |||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 2 | return bless $self, $class; | |||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | 3 | ▶ | sub file_class { $_[0]->{file_class} } | ||||||||||||||||||||||||||||||
|
Subroutine
file_class: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | sub max_size { $_[0]->{max_size} } | ||||||||||||||||||||||||||||||
|
Subroutine
max_size: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 34 | 1 | ▶ | sub allowed_types { $_[0]->{allowed_types} } | ||||||||||||||||||||||||||||||
|
Subroutine
allowed_types: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | 2 | ▶ | sub wrap { | ||||||||||||||||||||||||||||||
|
Subroutine
wrap: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 37 | 2 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | 2 | my $file_class = $self->file_class; | |||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | return $file_class->new( | ||||||||||||||||||||||||||||||||
| 42 | name => $args{name}, | ||||||||||||||||||||||||||||||||
| 43 | filename => $args{filename}, | ||||||||||||||||||||||||||||||||
| 44 | tmp_path => $args{tmp_path}, | ||||||||||||||||||||||||||||||||
| 45 | size => $args{size}, | ||||||||||||||||||||||||||||||||
| 46 | type => $args{type}, | ||||||||||||||||||||||||||||||||
| 47 | max_size => $self->{max_size}, | ||||||||||||||||||||||||||||||||
| 48 | allowed_types => $self->{allowed_types}, | ||||||||||||||||||||||||||||||||
| 49 | 2 | ); | |||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||
| 52 | 1 | ▶ | sub extract { | ||||||||||||||||||||||||||||||
|
Subroutine
extract: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 53 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 54 | 1 | croak ref($self) . " must implement extract()"; | |||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||
| 57 | 3 | 1; | |||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | __END__ | ||||||||||||||||||||||||||||||||