ZofCMS/Plugin/Barcode.pm

filter: Statementstmt 36.8% 14 / 38 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 57.1% 4 / 7 Podpod n/a totaltotal 23.0% 18 / 78 CC 13 SCAR 48.3
CC
13
Cov
22%
_do
182.0
_key
2.0
_defaults
2.0
CRAP 124.9
« ZofCMS/Plugin/SendFile.pm ↑ Summary ZofCMS/Plugin/AccessDenied.pm »
1 package App::ZofCMS::Plugin::Barcode;
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 GD::Barcode;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use base 'App::ZofCMS::Plugin::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 0 ▶sub _key { 'plug_barcode' }
Subroutine _key: not called CC=1 SCAR=6.9
12 0 ▶sub _defaults {
Subroutine _defaults: not called CC=1 SCAR=6.9
13 0 code => undef,
14 format => 'png', # gif or png
15 type => 'UPCA',
16 no_text => 0,
17 height => 50,
18 file => undef,
19 }
20 0 ▶sub _do {
Subroutine _do: not called CC=13 SCAR=52.0
21 0 my ( $self, $conf, $t, $q, $config ) = @_;
22  
23 $conf->{code} = $conf->{code}->( $t, $q, $config )
24 0 ▶ if ref $conf->{code} eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $conf->{"code"} eq "CODE" 0 0 0
25  
26 return
27 unless defined $conf->{code}
28 0 ▶ and length $conf->{code};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $conf->{"code"} and length $conf->{"code"} 0 0 0
Condition0%0/3
defined $conf->{"code"} and length $conf->{"code"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $conf->{"code"} and length $conf->{"code"}
defined $conf->{"code"} length $conf->{"code"}
Truth table0%0/3
A and B
A= defined $conf->{"code"}B= length $conf->{"code"}
ABresult
0X0
100
111
29  
30 $conf->{type} = $conf->{type}->( $t, $q, $config )
31 0 ▶ if ref $conf->{type} eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $conf->{"type"} eq "CODE" 0 0 0
32  
33 return
34 unless defined $conf->{type}
35 0 ▶ and length $conf->{type};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $conf->{"type"} and length $conf->{"type"} 0 0 0
Condition0%0/3
defined $conf->{"type"} and length $conf->{"type"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $conf->{"type"} and length $conf->{"type"}
defined $conf->{"type"} length $conf->{"type"}
Truth table0%0/3
A and B
A= defined $conf->{"type"}B= length $conf->{"type"}
ABresult
0X0
100
111
36  
37 0 my $bar = GD::Barcode->new( @$conf{ qw/type code/ } );
38  
39 0 ▶ unless ( $bar ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($bar) 0 0 0
40 0 $t->{t}{plug_barcode_error} = $GD::Barcode::errStr;
41 0 return;
42 }
43  
44 0 ▶ if ( defined $conf->{file} and length $conf->{file} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $conf->{'file'} and length $conf->{'file'}) { } 0 0 0
Condition0%0/3
defined $conf->{"file"} and length $conf->{"file"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $conf->{"file"} and length $conf->{"file"}
defined $conf->{"file"} length $conf->{"file"}
Truth table0%0/3
A and B
A= defined $conf->{"file"}B= length $conf->{"file"}
ABresult
0X0
100
111
45 0 ▶ if ( open my $fh, '>', $conf->{file} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fh, '>', $conf->{'file'}) { } 0 0 0
46 0 binmode $fh;
47 print $fh $conf->{format} eq 'png'
48 ? $bar->plot( Height => $conf->{height}, NoText => $conf->{no_text} )->png
49 0 ▶ : $bar->plot( Height => $conf->{height}, NoText => $conf->{no_text} )->gif;
Branch: 1 branch
BranchTrueFalseTotal
$conf->{'format'} eq 'png' ? : 0 0 0
50 }
51 else {
52 0 $t->{t}{plug_barcode_error} = $!;
53 0 return;
54 }
55 }
56 else {
57 0 binmode STDOUT;
58 0 ▶ if ( $conf->{format} eq 'png' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($conf->{'format'} eq 'png') { } 0 0 0
59 0 print "Content-Type: image/png\n\n";
60 0 print $bar->plot( Height => $conf->{height}, NoText => $conf->{no_text} )->png;
61 }
62 else {
63 0 print "Content-Type: image/gif\n\n";
64 0 print $bar->plot( Height => $conf->{height}, NoText => $conf->{no_text} )->gif;
65 }
66 0 exit;
67 }
68 }
69  
70 1 1;
71 __END__
« ZofCMS/Plugin/SendFile.pm ↑ Summary ZofCMS/Plugin/AccessDenied.pm »