blib/lib/CGI/FormBuilder/Mail/FormatMultiPart.pm

filter: Statementstmt 16.2% 37 / 228 Branchbran 10.0% 7 / 70 Conditioncond 28.8% 13 / 45 MC/DCmcdc 22.2% 6 / 27 Subroutinesub 44.4% 8 / 18 Podpod 0.0% 0 / 2 totaltotal 18.2% 71 / 390 CC 59 SCAR 52.8
CC
59
Cov
17%
mailresults
432.9
_format_text_html
72.0
_format_text_plain
56.0
CRAP 196.3
↑ Summary
1 package CGI::FormBuilder::Mail::FormatMultiPart;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = 1.000006;
7  
8 1 ▶use English '-no_match_vars;';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use CGI::FormBuilder::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use CGI::FormBuilder::Field;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 require MIME::Types; # for MIME::Lite's AUTO type detection - required
14 1 require MIME::Lite;
15 1 require Text::FormatTable;
16 1 require HTML::QuickTable;
17  
18 1 ▶use Regexp::Common qw( net );
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 13 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
21 13 my $class = shift;
22 13 my $self = { @_ };
23  
24 13 bless $self, $class;
25 13 return $self;
26 }
27  
28 11 ▶sub mailresults {
Subroutine mailresults: called CC=31 SCAR=60.7
Pod undocumented
29 11 my ($self) = @_;
30  
31 # slice args into nicer var names, checking some params
32  
33 11 my $form = $self->{form};
34 11 ▶ puke "No CGI::FormBuilder passed as form arg"
Branch: 1 branch
BranchTrueFalseTotal
unless $form and $form->isa("CGI::FormBuilder") 1 10 11
Condition66%2/3
$form and $form->isa("CGI::FormBuilder")
!ll&&!rl&&r
1010
MC/DC50%1/2
$form and $form->isa("CGI::FormBuilder")
$form $form->isa("CGI::FormBuilder")
Truth table66%2/3
A and B
A= $formB= $form->isa("CGI::FormBuilder")
ABresult
0X0
100
111
35 if !$form || !$form->isa('CGI::FormBuilder');
36  
37 my ($subject, $to, $cc, $bcc, $from, $smtp )
38 10 = @{$self}{qw( subject to cc bcc from smtp )};
39  
40 puke "Address/subject args should all be scalars"
41 10 ▶ if scalar grep { defined && ref }
Branch: 1 branch
BranchTrueFalseTotal
if scalar grep({defined $_ and ref $_;} $to, $from, $smtp, $cc, $bcc, $subject) 6 4 10
Condition100%3/3
defined $_ && ref $_
!ll&&!rl&&r
21336
MC/DC100%2/2
defined $_ && ref $_
defined $_ ref $_
Truth table100%3/3
A && B
A= defined $_B= ref $_
ABresult
0X0
100
111
42 ( $to, $from, $smtp, $cc, $bcc, $subject );
43  
44 4 ▶ puke "Cannot send mail without to, from, and smtp args"
Branch: 1 branch
BranchTrueFalseTotal
unless $to and $from and $smtp 3 1 4
Condition100%6/6
$to and $from and $smtp
!ll&&!rl&&r
211
$to and $from
!ll&&!rl&&r
112
MC/DC100%3/3
$to and $from and $smtp
$to $from $smtp
Truth table100%4/4
A and B and C
A= $toB= $fromC= $smtp
ABCresult
0XX0
10X0
1100
1111
45 if !$to || !$from || !$smtp;
46
47 1 ▶ puke "arg 'smtp' in bad format"
Branch: 1 branch
BranchTrueFalseTotal
unless $smtp eq "localhost" or $smtp =~ / \A $CGI::FormBuilder::Mail::FormatMultiPart::RE{"net"}{"domain"}{"-nospace"} \z /msx or $smtp =~ / \A $CGI::FormBuilder::Mail::FormatMultiPart::RE{"net"}{"IPv4"} \z /msx 1 0 1
Condition33%2/6
$smtp eq "localhost" or $smtp =~ / \A $CGI::FormBuilder::Mail::FormatMultiPart::RE{"net"}{"domain"}{"-nospace"} \z /msx or $smtp =~ / \A $CGI::FormBuilder::Mail::FormatMultiPart::RE{"net"}{"IPv4"} \z /msx
l!l&&r!l&&!r
001
$smtp eq "localhost" or $smtp =~ / \A $CGI::FormBuilder::Mail::FormatMultiPart::RE{"net"}{"domain"}{"-nospace"} \z /msx
l!l&&r!l&&!r
001
MC/DC0%0/3
$smtp eq "localhost" or $smtp =~ / \A $CGI::FormBuilder::Mail::FormatMultiPart::RE{"net"}{"domain"}{"-nospace"} \z /msx or $smtp =~ / \A $CGI::FormBuilder::Mail::FormatMultiPart::RE{"net"}{"IPv4"} \z /msx
$smtp eq "localhost" $smtp =~ / \A $CGI::FormBuilder::Mail::FormatMultiPart::RE{"net"}{"domain"}{"-nospace"} \z /msx $smtp =~ / \A $CGI::FormBuilder::Mail::FormatMultiPart::RE{"net"}{"IPv4"} \z /msx
Truth table25%1/4
A or B or C
A= $smtp eq "localhost"B= $smtp =~ / \A $CGI::FormBuilder::Mail::FormatMultiPart::RE{"net"}{"domain"}{"-nospace"} \z /msxC= $smtp =~ / \A $CGI::FormBuilder::Mail::FormatMultiPart::RE{"net"}{"IPv4"} \z /msx
ABCresult
1XX1
01X1
0011
0000
48 if !( $smtp eq 'localhost'
49 || $smtp =~ m{ \A $RE{net}{domain}{-nospace} \z }xms
50 || $smtp =~ m{ \A $RE{net}{IPv4} \z }xms
51 )
52 ;
53  
54 # let MIME::Lite check e-mail address or address list format
55 # (VALIDATE pattern for multiple addresses too much of a pain)
56  
57 0 my ($format, $skipfields, $skip ) = @{$self}{qw( format skipfields skip )};
58  
59 0 ▶ $format = $self->{format} = 'plain' if !$format;
Branch: 1 branch
BranchTrueFalseTotal
unless $format 0 0 0
60 0 ▶ if ( ref $format
Branch: 1 branch
BranchTrueFalseTotal
if (ref $format or not grep({$_ eq $format;} "plain", "html", "both")) 0 0 0
Condition0%0/3
ref $format or not grep({$_ eq $format;} "plain", "html", "both")
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $format or not grep({$_ eq $format;} "plain", "html", "both")
ref $format not grep({$_ eq $format;} "plain", "html", "both")
Truth table0%0/3
A or not(B)
A= ref $formatB= not grep({$_ eq $format;} "plain", "html", "both")
ABresult
1X1
011
000
61 0 || !grep { $_ eq $format } qw( plain html both )
62 ) {
63 0 puke "Arg format should be 'plain', 'html', or 'both'.";
64 }
65  
66 0 ▶ if ($skip || (defined $skipfields && ref $skipfields ne 'ARRAY')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($skip or defined $skipfields and ref $skipfields ne "ARRAY") 0 0 0
Condition0%0/6
$skip or defined $skipfields and ref $skipfields ne "ARRAY"
l!l&&r!l&&!r
000
defined $skipfields and ref $skipfields ne "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/3
$skip or defined $skipfields and ref $skipfields ne "ARRAY"
$skip defined $skipfields ref $skipfields ne "ARRAY"
Truth table0%0/4
A or B and C
A= $skipB= defined $skipfieldsC= ref $skipfields ne "ARRAY"
ABCresult
1XX1
0111
00X0
0100
67 0 belch __PACKAGE__
68 ." prefers arg 'skipfields' as arrayref, not skipping any";
69 0 $skipfields = $self->{skipfields} = [ ];
70 }
71  
72 # what's the default subject if not found?
73 0 ▶ if (!$subject) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($subject) 0 0 0
74 $self->{subject} = $subject
75 0 ▶ ||= sprintf $form->{messages}->mail_results_subject, $form->title;
Condition0%0/3
$subject ||= sprintf($form->{"messages"}->mail_results_subject, $form->title)
l!l&&r!l&&!r
000
MC/DC0%0/2
$subject ||= sprintf($form->{"messages"}->mail_results_subject, $form->title)
$subject sprintf($form->{"messages"}->mail_results_subject, $form->title)
Truth table0%0/3
A ||= B
A= $subjectB= sprintf($form->{"messages"}->mail_results_subject, $form->title)
ABresult
1X1
011
000
76 }
77  
78 # set up a hash of the individual CGI::FormBuilder::Field objects and
79 # put it into $self to pass around. it's useful.
80 0 my $fbflds = $self->{_fbflds} = { map { ( "$_" => $_ ) } $form->field };
81  
82 # ok, now set up the e-mail
83  
84 0 my $parts = 1; # count parts to determine message type, args, construction
85 0 ▶ $parts++ if $format eq 'both';
Branch: 1 branch
BranchTrueFalseTotal
if $format eq "both" 0 0 0
86  
87 0 my @file_attachments = $self->_file_attachments();
88 #debug 1, "file_attachments: '@file_attachments'";
89  
90 0 $parts += scalar @file_attachments;
91  
92 #debug 1, "parts: '$parts'";
93  
94 0 my $msg = undef;
95 0 ▶ my %msg_args = (
Branch: 1 branch
BranchTrueFalseTotal
$parts > 1 ? : 0 0 0
96 From => $from,
97 To => $to,
98 Subject => $subject,
99 Type => ($parts > 1) ? 'multipart/mixed' : "text/$format",
100 );
101 0 ▶ $msg_args{Cc} = $cc if defined $cc;
Branch: 1 branch
BranchTrueFalseTotal
if defined $cc 0 0 0
102 0 ▶ $msg_args{Bcc} = $bcc if defined $bcc;
Branch: 1 branch
BranchTrueFalseTotal
if defined $bcc 0 0 0
103  
104 0 ▶ if ($parts == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parts == 1) { } 0 0 0
105 0 $msg_args{Data} = $self->_format_text();
106 0 $msg = MIME::Lite->new( %msg_args );
107 }
108 else {
109 0 $msg = MIME::Lite->new( %msg_args );
110 0 ▶ if ($format eq 'plain' || $format eq 'both') {
Branch: 1 branch
BranchTrueFalseTotal
if ($format eq "plain" or $format eq "both") 0 0 0
Condition0%0/3
$format eq "plain" or $format eq "both"
l!l&&r!l&&!r
000
MC/DC0%0/2
$format eq "plain" or $format eq "both"
$format eq "plain" $format eq "both"
Truth table0%0/3
A or B
A= $format eq "plain"B= $format eq "both"
ABresult
1X1
011
000
111 0 $msg->attach(
112 Type => 'TEXT',
113 Data => $self->_format_text_plain(),
114 );
115 }
116 0 ▶ if ($format eq 'html' || $format eq 'both') {
Branch: 1 branch
BranchTrueFalseTotal
if ($format eq "html" or $format eq "both") 0 0 0
Condition0%0/3
$format eq "html" or $format eq "both"
l!l&&r!l&&!r
000
MC/DC0%0/2
$format eq "html" or $format eq "both"
$format eq "html" $format eq "both"
Truth table0%0/3
A or B
A= $format eq "html"B= $format eq "both"
ABresult
1X1
011
000
117 0 $msg->attach(
118 Type => 'text/html',
119 Data => $self->_format_text_html(),
120 );
121 }
122  
123 0 $msg->attach( %{$_} ) for @file_attachments;
124 }
125  
126 0 my $success = eval $msg->send_by_smtp( $smtp );
127  
128 0 ▶ if ($EVAL_ERROR || !$success) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CGI::FormBuilder::Mail::FormatMultiPart::EVAL_ERROR or not $success) 0 0 0
Condition0%0/3
$CGI::FormBuilder::Mail::FormatMultiPart::EVAL_ERROR or not $success
l!l&&r!l&&!r
000
MC/DC0%0/2
$CGI::FormBuilder::Mail::FormatMultiPart::EVAL_ERROR or not $success
$CGI::FormBuilder::Mail::FormatMultiPart::EVAL_ERROR not $success
Truth table0%0/3
A or not(B)
A= $CGI::FormBuilder::Mail::FormatMultiPart::EVAL_ERRORB= not $success
ABresult
1X1
011
000
129 0 puke("Could not send mail. $EVAL_ERROR");
130 }
131  
132 0 return;
133 }
134  
135 0 ▶sub _format_text {
Subroutine _format_text: not called CC=2 SCAR=17.9
136 # a simple dispatch
137 0 my ($self) = @_;
138 0 ▶ return ($self->{format} eq 'html')
Branch: 1 branch
BranchTrueFalseTotal
$self->{'format'} eq 'html' ? : 0 0 0
139 ? $self->_format_text_html()
140 : $self->_format_text_plain();
141 }
142  
143 0 ▶sub _format_text_plain {
Subroutine _format_text_plain: not called CC=7 SCAR=40.3
144 0 my ($self) = @_;
145  
146 0 my $text = $self->{subject}."\n\nForm Data:\n\n";
147  
148 0 my $fmt = '| l | l |';
149  
150 0 my $table_data = Text::FormatTable->new($fmt);
151 0 my $data_form = $self->_data_form();
152 0 $table_data->rule;
153 0 $table_data->head( @{ $data_form->[0] } );
154 0 $table_data->rule;
155  
156 # not sure yet if it's better to have rules between each var
157 0 do { $table_data->row( @{$_} ); $table_data->rule; }
158 0 for @{$data_form}[ 1 .. $#{$data_form} ];
159  
160 #$table_data->row( @{$_} ) for @{$data_form}[ 1 .. $#{$data_form} ];
161 #$table_data->rule;
162  
163 0 $text .= $table_data->render(72);
164  
165 0 my $data_files = $self->_data_files();
166 0 ▶ if (defined $data_files) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $data_files) 0 0 0
167 0 $text .= "\n\nUploaded Files:\n\n";
168 0 my $table_files = Text::FormatTable->new($fmt);
169 0 $table_files->rule;
170 0 $table_files->head( @{ $data_files->[0] } );
171 0 $table_files->rule;
172 0 $table_files->row( @{$_} ) for @{$data_files}[ 1 .. $#{$data_files} ];
173 0 $table_files->rule;
174 0 $text .= $table_files->render(72);
175 }
176  
177 0 my $data_env = $self->_data_env();
178 0 ▶ if (defined $data_env) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $data_env) 0 0 0
179 0 $text .= "\n\nBrowser/Connect Info:\n\n";
180 0 my $table_env = Text::FormatTable->new($fmt);
181 0 $table_env->rule;
182 0 $table_env->head( @{ $data_env->[0] } );
183 0 $table_env->rule;
184 0 $table_env->row( @{$_} ) for @{$data_env}[ 1 .. $#{$data_env} ];
185 0 $table_env->rule;
186 0 $text .= $table_env->render(72);
187 }
188  
189 0 $text .= "\n\nTime:\n\n";
190 0 my $table_time = Text::FormatTable->new($fmt);
191 0 my $data_time = $self->_data_time();
192 0 $table_time->rule;
193 0 $table_time->head( @{ $data_time->[0] } );
194 0 $table_time->rule;
195 0 $table_time->row( @{$_} ) for @{$data_time}[ 1 .. $#{$data_time} ];
196 0 $table_time->rule;
197 0 $text .= $table_time->render(72);
198  
199 #print "<pre>\n$text\n</pre>\n";
200  
201 0 return $text;
202 }
203  
204 0 ▶sub _format_text_html {
Subroutine _format_text_html: not called CC=8 SCAR=42.8
205 0 my ($self) = @_;
206  
207 my ($form, $fbflds, $skipfields, $subject, $css)
208 0 = @{$self}{qw( form _fbflds skipfields subject css )};
209  
210 0 my $fmt = $self->{html_qt_format};
211 0 ▶ if ($fmt && ref $fmt ne 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if ($fmt and ref $fmt ne "HASH") 0 0 0
Condition0%0/3
$fmt and ref $fmt ne "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
$fmt and ref $fmt ne "HASH"
$fmt ref $fmt ne "HASH"
Truth table0%0/3
A and B
A= $fmtB= ref $fmt ne "HASH"
ABresult
0X0
100
111
212 0 belch "html_qt_format is hashref for HTML::QuickTable. default used.";
213 0 undef $fmt;
214 }
215 0 ▶ $fmt = { } if !$fmt;
Branch: 1 branch
BranchTrueFalseTotal
unless $fmt 0 0 0
216  
217 my $qt_real_fmt = {
218 # all the defaults:
219 cellspacing => 0,
220 cellpadding => 0,
221 border => 0,
222 labels => 1,
223 stylesheet => 1,
224 styleclass => 'fb_mail',
225 useid => 'fb_mail',
226
227 # or override with specified values:
228 0 %{$fmt},
229  
230 # except no header, we never want to allow that:
231 header => 0,
232 };
233  
234 0 my $base_css_class = $qt_real_fmt->{styleclass};
235 0 my $default_css = <<END_CSS;
236 *.fb_mail {
237 font-family: Arial, Helvetica, sans-serif;
238 }
239 TABLE.fb_mail {
240 padding: 0.5em;
241 border: 1px solid black;
242 }
243 TD.fb_mail {
244 font-face: Arial, Helvetica, sans-serif;
245 text-align: left;
246 vertical-align: top;
247 padding: 0.5em;
248 background: white;
249 border: 1px dotted orange;
250 }
251 H1.fb_mail {
252 color: red;
253 }
254 END_CSS
255  
256 # their styles will override defaults, but defaults will still be used
257 # if they don't make a full CSS spec for the table:
258 0 ▶ $css = '' if !defined $css;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $css 0 0 0
259 0 $css = $default_css."\n".$css;
260  
261 # OK, the only question is how to format CSS for e-mail so it will work.
262 0 my $html = <<END_HTML;
263 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
264  
265 <HTML>
266 <HEAD>
267  
268 <STYLE type="text/css">
269 $css
270 </STYLE>
271  
272 </HEAD>
273 <BODY>
274  
275 <H1 CLASS="$base_css_class">$subject</H1>
276  
277 END_HTML
278  
279 my $qt = HTML::QuickTable->new(
280 0 %{$qt_real_fmt},
281 );
282  
283 0 $html .= qq{<H2 CLASS="$base_css_class">Form Data:</H2>\n};
284  
285 # clone form data so it's still ok for plain when we tweak it for html here
286 0 my @data_form = @{ $self->_data_form() };
287 0 $_->[1] =~ s{ \n }{<br>\n}xms for @data_form; # turn \n to <br>
288 0 $html .= $qt->render( \@data_form );
289  
290 0 my $data_files = $self->_data_files();
291 0 ▶ if (defined $data_files) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $data_files) 0 0 0
292 0 $html .= qq{<H2 CLASS="$base_css_class">Uploaded Files:</H2>\n};
293 0 $html .= $qt->render( $data_files );
294 }
295  
296 0 my $data_env = $self->_data_env();
297 0 ▶ if (defined $data_env) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $data_env) 0 0 0
298 0 $html .= qq{<H2 CLASS="$base_css_class">Browser/Connect Info:</H2>\n};
299 0 $html .= $qt->render( $data_env );
300 }
301  
302 0 $html .= qq{<H2 CLASS="$base_css_class">Time:</H2>\n};
303  
304 0 $html .= $qt->render( $self->_data_time() );
305  
306 #print $html;
307  
308 0 return $html;
309 }
310  
311 0 ▶sub _skipfields_lookup {
Subroutine _skipfields_lookup: not called CC=2 SCAR=17.9
312 0 my ($self) = @_;
313  
314 0 ▶ return $self->{_skipfields_lookup} if exists $self->{_skipfields_lookup};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"_skipfields_lookup"} 0 0 0
315  
316 my $skipfields_lookup
317 = $self->{_skipfields_lookup}
318 0 = { map { ( $_ => 1 ) } @{ $self->{skipfields} } };
319
320 0 return $skipfields_lookup;
321 }
322  
323 0 ▶sub _file_field_names {
Subroutine _file_field_names: not called CC=1 SCAR=6.9
324 0 my ($self) = @_;
325  
326 0 my $fbflds = $self->{_fbflds};
327  
328 0 my $skipfields_lookup = $self->_skipfields_lookup;
329  
330 return (
331 0 grep { !exists $skipfields_lookup->{$_} } # is not skipped
332 0 grep { $fbflds->{$_}->type eq 'file' } # type is file
333 $self->{form}->fields # in order of fields
334 0 );
335 }
336  
337 0 ▶sub _file_attachments {
Subroutine _file_attachments: not called CC=1 SCAR=6.9
338 0 my ($self) = @_;
339  
340 0 my ($form, $fbflds) = @{$self}{qw( form _fbflds )};
341  
342 return ( # return array of hashrefs suitable for MIME::Type attachments
343 0 map { { Type => 'AUTO',
344 FH => $form->field($_),
345 Filename => $form->field($_),
346 Id => $_,
347 Disposition => 'attachment',
348 }
349 }
350 0 grep { $fbflds->{$_}->value } # only files actually uploaded
351 $self->_file_field_names()
352 );
353 }
354  
355 0 ▶sub _data_form {
Subroutine _data_form: not called CC=6 SCAR=37.4
356 0 my ($self) = @_;
357  
358 # might be called twice in 'both', so no need to re-generate
359 0 ▶ return $self->{_data_form} if exists $self->{_data_form};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"_data_form"} 0 0 0
360  
361 0 my ($form, $fbflds) = @{$self}{qw( form _fbflds )};
362  
363 0 my $skipfields_lookup = $self->_skipfields_lookup;
364  
365 0 my $data = [
366 [ 'Field' => 'Value' ]
367 ];
368  
369 0 my @field_names = $form->fields;
370  
371  
372 FIELD:
373 0 foreach my $name ( @field_names ) {
374 0 ▶ next FIELD if exists $skipfields_lookup->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $skipfields_lookup->{$name} 0 0 0
375 0 ▶ next FIELD if $fbflds->{$name}->type eq 'file';
Branch: 1 branch
BranchTrueFalseTotal
if $fbflds->{$name}->type eq "file" 0 0 0
376 0 my @values = $form->field($name);
377 0 my $value = join("\n",@values);
378 0 ▶ $value = '&nbsp;' if !$value;
Branch: 1 branch
BranchTrueFalseTotal
unless $value 0 0 0
379 0 push @{$data}, [ "$name" => $value ];
380 }
381  
382 # cache in self
383 0 $self->{_data_form} = $data;
384 0 return $data;
385 }
386  
387 0 ▶sub _data_files {
Subroutine _data_files: not called CC=5 SCAR=34.0
388 0 my ($self) = @_;
389  
390 0 ▶ return $self->{_data_files} if exists $self->{_data_files};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"_data_files"} 0 0 0
391  
392 0 my ($form) = @{$self}{qw( form )};
393  
394 0 my $data = undef;
395  
396 0 my @file_field_names = $self->_file_field_names();
397  
398 0 ▶ if (scalar @file_field_names) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @file_field_names) 0 0 0
399 0 $data = [
400 [ 'Field' => 'Attachment Status', ],
401 ];
402 0 foreach my $name (@file_field_names) {
403 0 my $value = $form->field($name);
404 0 ▶ $value = 'Not Uploaded' if !defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 0 0
405 0 push @{$data}, [ "$name" => "attached as $value" ];
406 }
407 }
408 0 $self->{_data_files} = $data;
409  
410 0 return $data;
411 }
412  
413 0 ▶sub _data_env {
Subroutine _data_env: not called CC=4 SCAR=30.0
414 0 my ($self) = @_;
415 0 ▶ return $self->{_data_env} if exists $self->{_data_env};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"_data_env"} 0 0 0
416  
417 0 my $data = undef;
418 0 ▶ if (scalar(keys %ENV)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %ENV) 0 0 0
419 $data = [
420 [ 'Item', 'Value' ],
421 0 ▶ ( map { [ $_ => $ENV{$_} ] }
Condition0%0/3
exists $ENV{$_} && defined $ENV{$_}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $ENV{$_} && defined $ENV{$_}
exists $ENV{$_} defined $ENV{$_}
Truth table0%0/3
A && B
A= exists $ENV{$_}B= defined $ENV{$_}
ABresult
0X0
100
111
422 0 grep exists $ENV{$_} && defined $ENV{$_},
423 qw( HTTP_USER_AGENT HTTP_REFERER REMOTE_ADDR REQUEST_URI )
424 ),
425 ];
426 }
427 0 $self->{_data_env} = $data;
428
429 0 return $data;
430 }
431  
432 0 ▶sub _data_time {
Subroutine _data_time: not called CC=2 SCAR=17.9
433 0 my ($self) = @_;
434 0 ▶ return $self->{_data_time} if $self->{_data_time};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_data_time"} 0 0 0
435  
436 0 my $data = [
437 [ 'Time Zone' => 'Time' ],
438 [ 'Local System' => scalar localtime ],
439 [ 'Greenwich Mean' => scalar gmtime ],
440 ];
441  
442 0 $self->{_data_time} = $data;
443  
444 0 return $data;
445 }
446  
447 1 1;
448  
449 __END__
↑ Summary