Barcode.pm

filter: Statementstmt 73.2% 41 / 56 Branchbran 66.6% 8 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 50.0% 2 / 4 totaltotal 72.8% 59 / 81 CC 10 SCAR 18.5
CC
10
Cov
72%
plot
20.0
dumpCode
4.0
new
3.0
CRAP 6.3
« Barcode/QRcode.pm ↑ Summary Barcode/UPCE.pm »
1 package GD::Barcode;
2 14 ▶use parent qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
3 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 14 ▶use vars qw( @ISA $errStr);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 14 ▶use parent qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 14 our $VERSION = '2.02';
9  
10 12 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
11 12 my ( $sClass, $sType, $sTxt, $rhPrm ) = @_;
12 12 my $oThis = {};
13 12 my $module = "GD::Barcode::$sType";
14 12 eval "require $module;";
15 12 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 1 11 12
16 1 $errStr = "Can't load $sType : $@";
17 1 return;
18 }
19 11 bless $oThis, $module;
20 11 ▶ return if ( $errStr = $oThis->init( $sTxt, $rhPrm ) );
Branch: 1 branch
BranchTrueFalseTotal
if $GD::Barcode::errStr = $oThis->init($sTxt, $rhPrm) 1 10 11
21 10 return $oThis;
22 }
23  
24 62 ▶sub barPtn {
Subroutine barPtn: called CC=2 SCAR=6.9
Pod undocumented
25 62 my ( $bar, $table ) = @_;
26 62 my $sRes;
27  
28 62 $sRes = '';
29 62 foreach my $sWk ( split( //, $bar ) ) {
30 62 $sRes .= $table->{$sWk};
31 }
32 62 return $sRes;
33 }
34  
35 16 ▶sub dumpCode {
Subroutine dumpCode: called CC=4 SCAR=13.9
Pod undocumented
36 16 my ($sCode) = @_;
37 16 my ( $sRes, $sClr );
38  
39 #Init
40 16 $sRes = '';
41 16 $sClr = '1'; # 1: Black, 0:White
42  
43 16 foreach my $sWk ( split( //, $sCode ) ) {
44 142 ▶ $sRes .= ( $sWk eq '1' ) ? $sClr x 3 : $sClr; #3 times or Normal
Branch: 1 branch
BranchTrueFalseTotal
$sWk eq '1' ? : 46 96 142
45 142 ▶ $sClr = ( $sClr eq '0' ) ? '1' : '0';
Branch: 1 branch
BranchTrueFalseTotal
$sClr eq '0' ? : 71 71 142
46 }
47 16 return $sRes;
48 }
49  
50 0 ▶sub plot {
Subroutine plot: not called CC=4 SCAR=30.0
Pod documented
51 0 my ( $sBarcode, $iWidth, $iHeight, $fH, $iStart ) = @_;
52  
53 #Create Image
54 0 my ( $gdNew, $cWhite, $cBlack );
55 0 eval {
56 0 $gdNew = GD::Image->new( $iWidth, $iHeight );
57 0 $cWhite = $gdNew->colorAllocate( 255, 255, 255 );
58 0 $cBlack = $gdNew->colorAllocate( 0, 0, 0 );
59 0 $gdNew->filledRectangle( 0, 0, $iWidth, $iHeight, $cWhite );
60  
61 0 my $iPos = $iStart;
62 0 foreach my $cWk ( split( //, $sBarcode ) ) {
63 0 ▶ if ( $cWk eq '0' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($cWk eq '0') { } 0 0 0
elsif ($cWk eq 'G') { } 0 0 0
64 0 $gdNew->line( $iPos, 0, $iPos, $iHeight - $fH, $cWhite );
65 }
66 elsif ( $cWk eq 'G' ) {
67 0 $gdNew->line( $iPos, 0, $iPos, $iHeight - 2 * ( $fH / 3 ),
68 $cBlack );
69 }
70 else { #$cWk eq "1" etc.
71 0 $gdNew->line( $iPos, 0, $iPos, $iHeight - $fH, $cBlack );
72 }
73 0 $iPos++;
74 }
75 };
76 0 return ( $gdNew, $cBlack );
77 }
78 14 1;
79 __END__
« Barcode/QRcode.pm ↑ Summary Barcode/UPCE.pm »