Form/FileInput.pm

filter: Statementstmt 100% 45 / 45 Branchbran 81.8% 18 / 22 Conditioncond 63.6% 7 / 11 MC/DCmcdc 42.8% 3 / 7 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 5 totaltotal 82.4% 80 / 97 CC 16 SCAR 19.2
CC
16
Cov
90%
form_name_value
11.3
headers
3.1
filename
3.0
CRAP 6.8
« Form/TextInput.pm ↑ Summary Form/ImageInput.pm »
1 package HTML::Form::FileInput;
2  
3 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use parent 'HTML::Form::TextInput';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 11 our $VERSION = '6.13';
7  
8 # ABSTRACT: An HTML form file input element for use with HTML::Form
9  
10 32 ▶sub file {
Subroutine file: called CC=1 SCAR=0.0
Pod undocumented
11 32 my $self = shift;
12 32 $self->value(@_);
13 }
14  
15 16 ▶sub filename {
Subroutine filename: called CC=3 SCAR=11.0
Pod undocumented
16 16 my $self = shift;
17 16 my $old = $self->{filename};
18 16 ▶ $self->{filename} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 3 13 16
19 16 ▶ $old = $self->file unless defined $old;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $old 13 3 16
20 16 $old;
21 }
22  
23 15 ▶sub content {
Subroutine content: called CC=2 SCAR=6.9
Pod undocumented
24 15 my $self = shift;
25 15 my $old = $self->{content};
26 15 ▶ $self->{content} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 2 13 15
27 15 $old;
28 }
29  
30 13 ▶sub headers {
Subroutine headers: called CC=3 SCAR=11.4
Pod undocumented
31 13 my $self = shift;
32 13 ▶ my $old = $self->{headers} || [];
Condition50%1/2
$self->{'headers'} || []
l!l
013
MC/DC0%0/1
$self->{'headers'} || []
$self->{'headers'}
Truth table50%1/2
A
A= $self->{'headers'}
Aresult
11
00
33 13 ▶ $self->{headers} = [@_] if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 13 13
34 13 @$old;
35 }
36  
37 14 ▶sub form_name_value {
Subroutine form_name_value: called CC=11 SCAR=24.2
Pod undocumented
38 14 my ( $self, $form ) = @_;
39 14 ▶ return $self->SUPER::form_name_value($form)
Branch: 1 branch
BranchTrueFalseTotal
if $form->method ne "POST" or $form->enctype ne "multipart/form-data" 1 13 14
Condition66%2/3
$form->method ne "POST" or $form->enctype ne "multipart/form-data"
l!l&&r!l&&!r
0113
MC/DC50%1/2
$form->method ne "POST" or $form->enctype ne "multipart/form-data"
$form->method ne "POST" $form->enctype ne "multipart/form-data"
Truth table66%2/3
A or B
A= $form->method ne "POST"B= $form->enctype ne "multipart/form-data"
ABresult
1X1
011
000
40 if $form->method ne "POST"
41 || $form->enctype ne "multipart/form-data";
42  
43 13 my $name = $self->name;
44 13 ▶ return unless defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 0 13 13
45 13 ▶ return if $self->{disabled};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"disabled"} 0 13 13
46  
47 13 my $file = $self->file;
48 13 my $filename = $self->filename;
49 13 my @headers = $self->headers;
50 13 my $content = $self->content;
51 13 my %headers = @headers;
52 13 ▶ if ( defined $content || grep m/^Content$/i, keys %headers ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $content or grep /^Content$/i, keys %headers) { } 2 11 13
elsif (not defined $file or length $file == 0) { } 1 10 11
Condition66%2/3
defined $content or grep /^Content$/i, keys %headers
l!l&&r!l&&!r
2011
MC/DC50%1/2
defined $content or grep /^Content$/i, keys %headers
defined $content grep /^Content$/i, keys %headers
Truth table66%2/3
A or B
A= defined $contentB= grep /^Content$/i, keys %headers
ABresult
1X1
011
000
53 2 ▶ $filename = $file unless defined $filename;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $filename 0 2 2
54 2 $file = undef;
55 2 unshift( @headers, "Content" => $content );
56 }
57 ▶ elsif ( !defined($file) || length($file) == 0 ) {
Condition66%2/3
not defined $file or length $file == 0
l!l&&r!l&&!r
0110
MC/DC50%1/2
not defined $file or length $file == 0
not defined $file length $file == 0
Truth table66%2/3
not(A) or B
A= not defined $fileB= length $file == 0
ABresult
1X1
011
000
58 1 return;
59 }
60  
61 # legacy (this used to be the way to do it)
62 12 ▶ if ( ref($file) eq "ARRAY" ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $file eq "ARRAY") 7 5 12
63 7 my $f = shift @$file;
64 7 my $fn = shift @$file;
65 7 push( @headers, @$file );
66 7 $file = $f;
67 7 $filename = $fn;
68 }
69  
70 12 return ( $name => [ $file, $filename, @headers ] );
71 }
72  
73 11 1;
74  
75 __END__
« Form/TextInput.pm ↑ Summary Form/ImageInput.pm »