ZofCMS/Plugin/AutoIMGSize.pm

filter: Statementstmt 37.8% 14 / 37 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 66.6% 4 / 6 Podpod 0.0% 0 / 2 totaltotal 25.7% 18 / 70 CC 11 SCAR 45.1
CC
11
Cov
24%
process
132.0
new
2.0
BEGIN
1.0
CRAP 91.1
« ZofCMS/Plugin/DateSelector.pm ↑ Summary ZofCMS/Plugin/Session.pm »
1 package App::ZofCMS::Plugin::AutoIMGSize;
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  
6 1 our $VERSION = '1.001010'; # VERSION
7  
8 1 ▶use HTML::Entities;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Image::Size (qw/html_imgsize/);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 0 ▶sub new { bless {}, shift }
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
12  
13 0 ▶sub process {
Subroutine process: not called CC=11 SCAR=48.8
Pod undocumented
14 0 my ( $self, $template, $query, $config ) = @_;
15  
16 return
17 unless $template->{plug_auto_img_size}
18 0 ▶ or $config->conf->{plug_auto_img_size};
Branch: 1 branch
BranchTrueFalseTotal
unless $template->{"plug_auto_img_size"} or $config->conf->{"plug_auto_img_size"} 0 0 0
Condition0%0/3
$template->{"plug_auto_img_size"} or $config->conf->{"plug_auto_img_size"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$template->{"plug_auto_img_size"} or $config->conf->{"plug_auto_img_size"}
$template->{"plug_auto_img_size"} $config->conf->{"plug_auto_img_size"}
Truth table0%0/3
A or B
A= $template->{"plug_auto_img_size"}B= $config->conf->{"plug_auto_img_size"}
ABresult
1X1
011
000
19  
20 my %conf = (
21 t_prefix => 'img_',
22 xhtml => 0,
23 0 ▶ %{ delete $config->conf->{plug_auto_img_size} || {} },
Condition0%0/2
delete $config->conf->{'plug_auto_img_size'} || {}
l!l
00
MC/DC0%0/1
delete $config->conf->{'plug_auto_img_size'} || {}
delete $config->conf->{'plug_auto_img_size'}
Truth table0%0/2
A
A= delete $config->conf->{'plug_auto_img_size'}
Aresult
11
00
24 0 ▶ %{ delete $template->{plug_auto_img_size} || {} },
Condition0%0/2
delete $template->{'plug_auto_img_size'} || {}
l!l
00
MC/DC0%0/1
delete $template->{'plug_auto_img_size'} || {}
delete $template->{'plug_auto_img_size'}
Truth table0%0/2
A
A= delete $template->{'plug_auto_img_size'}
Aresult
11
00
25 );
26  
27 0 ▶ if ( ref $conf{imgs} eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $conf{"imgs"} eq "ARRAY") 0 0 0
28 $conf{imgs} = {
29 0 map +( $_ => $_ ), @{ $conf{imgs} }
30 };
31 }
32  
33 0 keys %{ $conf{imgs} };
34 0 ▶ while ( my ( $name, $file ) = each %{ $conf{imgs} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$conf{"imgs"};}) 0 0 0
35 0 my $extra = '';
36 0 ▶ if ( ref $file eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $file eq "HASH") 0 0 0
37 0 ( $file, $extra ) = %$file;
38 }
39 0 ▶ unless ( -e $file ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $file) 0 0 0
40 0 $template->{t}{ $conf{t_prefix} . $name } = 'ERROR: File not found';
41 0 next;
42 }
43  
44 0 ▶ $extra = ' alt=""'
Branch: 1 branch
BranchTrueFalseTotal
unless length $extra 0 0 0
45 unless length $extra;
46  
47 0 my $size = html_imgsize $file;
48 0 encode_entities $file;
49  
50 $template->{t}{ $conf{t_prefix} . $name }
51 0 ▶ = qq|<img src="/$file" $size$extra| . ( $conf{xhtml} ? '/>' : '>' );
Branch: 1 branch
BranchTrueFalseTotal
$conf{'xhtml'} ? : 0 0 0
52 }
53  
54 }
55  
56 1 1;
57 __END__
« ZofCMS/Plugin/DateSelector.pm ↑ Summary ZofCMS/Plugin/Session.pm »