ZofCMS/Plugin/HTMLMailer.pm

filter: Statementstmt 42.5% 20 / 47 Branchbran 0.0% 0 / 26 Conditioncond 0.0% 0 / 30 MC/DCmcdc 0.0% 0 / 17 Subroutinesub 66.6% 6 / 9 Podpod n/a totaltotal 20.1% 26 / 129 CC 27 SCAR 63.7
CC
27
Cov
19%
_do
756.0
_key
2.0
_defaults
2.0
CRAP 583.5
↑ Summary ZofCMS/Plugin/FormChecker.pm »
1 package App::ZofCMS::Plugin::HTMLMailer;
2  
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use base 'App::ZofCMS::Plugin::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use MIME::Lite;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use HTML::Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use File::Spec::Functions (qw/catfile/);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our $VERSION = '1.001010'; # VERSION
11  
12 0 ▶sub _key { 'plug_htmlmailer' }
Subroutine _key: not called CC=1 SCAR=6.9
13  
14 0 ▶sub _defaults {
Subroutine _defaults: not called CC=1 SCAR=6.9
15 return (
16 #to => [ qw/foo@bar.com ber@bar.com/ ],
17 #template => 'mail_templates/new-forum-post.tmpl',
18  
19 0 subject => '',
20 template_dir => undef,
21 precode => undef,
22 mime_lite_params => undef,
23 from => undef,
24 cc => undef,
25 bcc => undef,
26 template_params => undef,
27 html_template_object => undef,
28 );
29 }
30  
31 0 ▶sub _do {
Subroutine _do: not called CC=27 SCAR=66.3
32 0 my ( $self, $conf, $t, $q, $config ) = @_;
33  
34 0 for ( qw/to bcc cc / ) {
35 $conf->{$_} = $conf->{$_}->( $t, $q, $config )
36 0 ▶ if ref $conf->{$_} eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $conf->{$_} eq "CODE" 0 0 0
37  
38 $conf->{$_} = [ $conf->{$_} ]
39 if ref $conf->{$_} ne 'ARRAY'
40 and defined $conf->{$_}
41 0 ▶ and length $conf->{$_};
Branch: 1 branch
BranchTrueFalseTotal
if ref $conf->{$_} ne "ARRAY" and defined $conf->{$_} and length $conf->{$_} 0 0 0
Condition0%0/6
ref $conf->{$_} ne "ARRAY" and defined $conf->{$_} and length $conf->{$_}
!ll&&!rl&&r
000
ref $conf->{$_} ne "ARRAY" and defined $conf->{$_}
!ll&&!rl&&r
000
MC/DC0%0/3
ref $conf->{$_} ne "ARRAY" and defined $conf->{$_} and length $conf->{$_}
ref $conf->{$_} ne "ARRAY" defined $conf->{$_} length $conf->{$_}
Truth table0%0/4
A and B and C
A= ref $conf->{$_} ne "ARRAY"B= defined $conf->{$_}C= length $conf->{$_}
ABCresult
0XX0
10X0
1100
1111
42 }
43  
44 $conf->{attach} = $conf->{attach}->( $t, $q, $config )
45 0 ▶ if ref $conf->{attach} eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $conf->{"attach"} eq "CODE" 0 0 0
46  
47 $conf->{attach} = [ $conf->{attach} ]
48 if $conf->{attach}
49 0 ▶ and ref $conf->{attach}[0] ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"attach"} and ref $conf->{"attach"}[0] ne "ARRAY" 0 0 0
Condition0%0/3
$conf->{"attach"} and ref $conf->{"attach"}[0] ne "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
$conf->{"attach"} and ref $conf->{"attach"}[0] ne "ARRAY"
$conf->{"attach"} ref $conf->{"attach"}[0] ne "ARRAY"
Truth table0%0/3
A and B
A= $conf->{"attach"}B= ref $conf->{"attach"}[0] ne "ARRAY"
ABresult
0X0
100
111
50  
51 return
52 0 ▶ unless @{ $conf->{to} || [] }
Condition0%0/8
$conf->{'to'} || []
l!l
00
defined $conf->{"template"} and length $conf->{"template"} or defined $conf->{"html_template_object"}
l!l&&r!l&&!r
000
defined $conf->{"template"} and length $conf->{"template"}
!ll&&!rl&&r
000
MC/DC0%0/1
$conf->{'to'} || []
$conf->{'to'}
MC/DC0%0/3
defined $conf->{"template"} and length $conf->{"template"} or defined $conf->{"html_template_object"}
defined $conf->{"template"} length $conf->{"template"} defined $conf->{"html_template_object"}
Truth table0%0/2
A
A= $conf->{'to'}
Aresult
11
00
Truth table0%0/5
A and B or C
A= defined $conf->{"template"}B= length $conf->{"template"}C= defined $conf->{"html_template_object"}
ABCresult
11X1
0X11
1011
0X00
1000
53 and (
54 ( defined $conf->{template} and length $conf->{template} )
55 or defined $conf->{html_template_object}
56 0 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
unless @{$conf->{"to"} or [];} and defined $conf->{"template"} && length $conf->{"template"} || defined $conf->{"html_template_object"} 0 0 0
Condition0%0/3
@{$conf->{"to"} or [];} and defined $conf->{"template"} && length $conf->{"template"} || defined $conf->{"html_template_object"}
!ll&&!rl&&r
000
MC/DC0%0/2
@{$conf->{"to"} or [];} and defined $conf->{"template"} && length $conf->{"template"} || defined $conf->{"html_template_object"}
@{$conf->{"to"} or [];} defined $conf->{"template"} && length $conf->{"template"} || defined $conf->{"html_template_object"}
Truth table0%0/3
A and B
A= @{$conf->{"to"} or [];}B= defined $conf->{"template"} && length $conf->{"template"} || defined $conf->{"html_template_object"}
ABresult
0X0
100
111
57  
58 0 ▶ if ( ref $conf->{precode} eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $conf->{"precode"} eq "CODE") 0 0 0
59 0 $conf->{precode}->( $t, $q, $config, $conf );
60 }
61  
62 my $temp = $conf->{html_template_object}
63 || HTML::Template->new(
64 filename => (
65 ( defined $conf->{template_dir}
66 and length $conf->{template_dir}
67 ) ? catfile( $conf->{template_dir}, $conf->{template} )
68 : $conf->{template_dir},
69 0 ▶ ),
Branch: 1 branch
BranchTrueFalseTotal
defined $conf->{'template_dir'} && length $conf->{'template_dir'} ? : 0 0 0
Condition0%0/6
$conf->{'html_template_object'} || 'HTML::Template'->new('filename', defined $conf->{'template_dir'} && length $conf->{'template_dir'} ? catfile($conf->{'template_dir'}, $conf->{'template'}) : $conf->{'template_dir'}, 'die_on_bad_params', 0)
l!l&&r!l&&!r
000
defined $conf->{"template_dir"} and length $conf->{"template_dir"}
!ll&&!rl&&r
000
MC/DC0%0/2
$conf->{'html_template_object'} || 'HTML::Template'->new('filename', defined $conf->{'template_dir'} && length $conf->{'template_dir'} ? catfile($conf->{'template_dir'}, $conf->{'template'}) : $conf->{'template_dir'}, 'die_on_bad_params', 0)
$conf->{'html_template_object'} 'HTML::Template'->new('filename', defined $conf->{'template_dir'} && length $conf->{'template_dir'} ? catfile($conf->{'template_dir'}, $conf->{'template'}) : $conf->{'template_dir'}, 'die_on_bad_params', 0)
MC/DC0%0/2
defined $conf->{"template_dir"} and length $conf->{"template_dir"}
defined $conf->{"template_dir"} length $conf->{"template_dir"}
Truth table0%0/3
A || B
A= $conf->{'html_template_object'}B= 'HTML::Template'->new('filename', defined $conf->{'template_dir'} && length $conf->{'template_dir'} ? catfile($conf->{'template_dir'}, $conf->{'template'}) : $conf->{'template_dir'}, 'die_on_bad_params', 0)
ABresult
1X1
011
000
Truth table0%0/3
A and B
A= defined $conf->{"template_dir"}B= length $conf->{"template_dir"}
ABresult
0X0
100
111
70 die_on_bad_params => 0,
71 );
72  
73 $conf->{template_params} = $conf->{template_params}->( $t, $q, $config )
74 0 ▶ if ref $conf->{template_params} eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $conf->{"template_params"} eq "CODE" 0 0 0
75  
76 0 $temp->param( @{ $conf->{template_params} } )
77 0 ▶ if @{ $conf->{template_params} || [] };
Branch: 1 branch
BranchTrueFalseTotal
if @{$conf->{"template_params"} or [];} 0 0 0
Condition0%0/2
$conf->{'template_params'} || []
l!l
00
MC/DC0%0/1
$conf->{'template_params'} || []
$conf->{'template_params'}
Truth table0%0/2
A
A= $conf->{'template_params'}
Aresult
11
00
78  
79 my $msg = MIME::Lite->new (
80 Subject => $conf->{subject},
81 ( defined $conf->{from} ? ( From => $conf->{from} ) : (), ),
82 0 ▶ To => ( join ',', @{ $conf->{to} } ),
Branch: 1 branch
BranchTrueFalseTotal
defined $conf->{'bcc'} ? : 0 0 0
83 0 ▶ ( ( defined $conf->{bcc} ) ? ( Bcc => ( join ',', @{ $conf->{bcc} } ), ) : () ),
Branch: 1 branch
BranchTrueFalseTotal
defined $conf->{'cc'} ? : 0 0 0
84 0 ▶ ( ( defined $conf->{cc} ) ? ( cc => ( join ',', @{ $conf->{cc} } ), ) : () ),
Branch: 1 branch
BranchTrueFalseTotal
defined $conf->{'from'} ? : 0 0 0
85 Type => 'text/html',
86 Data => $temp->output,
87 );
88  
89 0 ▶ for ( @{ $conf->{attach} || [] } ) {
Condition0%0/2
$conf->{'attach'} || []
l!l
00
MC/DC0%0/1
$conf->{'attach'} || []
$conf->{'attach'}
Truth table0%0/2
A
A= $conf->{'attach'}
Aresult
11
00
90 0 $msg->attach( @$_ );
91 }
92  
93 0 MIME::Lite->send( @{ $conf->{mime_lite_params} } )
94 0 ▶ if $conf->{mime_lite_params};
Branch: 1 branch
BranchTrueFalseTotal
if $conf->{"mime_lite_params"} 0 0 0
95  
96 0 $msg->send;
97 }
98  
99 1 1;
100 __END__
↑ Summary ZofCMS/Plugin/FormChecker.pm »