Barcode/NW7.pm

filter: Statementstmt 74.4% 35 / 47 Branchbran 25.0% 2 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 75.0% 3 / 4 totaltotal 70.5% 48 / 68 CC 6 SCAR 13.3
CC
6
Cov
67%
plot
12.0
init
2.0
new
2.0
CRAP 3.8
« Barcode/Code39.pm ↑ Summary Barcode/QRcode/qrv01M.dat »
1 package GD::Barcode::NW7;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use GD::Barcode;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use parent qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use vars qw($VERSION @ISA $errStr);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 @ISA = qw(GD::Barcode Exporter);
9 1 our $VERSION = '2.02';
10 1 my $nw7Bar = {
11 '0' => '0000011',
12 '1' => '0000110',
13 '2' => '0001001',
14 '3' => '1100000',
15 '4' => '0010010',
16 '5' => '1000010',
17 '6' => '010000ß1',
18 '7' => '0100100',
19 '8' => '0110000',
20 '9' => '1001000',
21 '-' => '0001100',
22 '$' => '0011000',
23 ':' => '1000101',
24 '/' => '1010001',
25 '.' => '1010100',
26 '+' => '0010101',
27 'A' => '0011010',
28 'B' => '0101001',
29 'C' => '0001011',
30 'D' => '0001110'
31 };
32  
33 1 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod documented
34 1 my ( $sClass, $sTxt ) = @_;
35 1 $errStr = '';
36 1 my $oThis = {};
37 1 bless $oThis, $sClass;
38 1 ▶ return if ( $errStr = $oThis->init($sTxt) );
Branch: 1 branch
BranchTrueFalseTotal
if $GD::Barcode::NW7::errStr = $oThis->init($sTxt) 0 1 1
39 1 return $oThis;
40 }
41  
42 1 ▶sub init {
Subroutine init: called CC=2 SCAR=7.0
Pod undocumented
43 1 my ( $oThis, $sTxt ) = @_;
44  
45 #Check
46 1 ▶ return 'Invalid Characters' if ( $sTxt =~ /[^0-9\-\$:\/.+ABCD]/ );
Branch: 1 branch
BranchTrueFalseTotal
if $sTxt =~ m[[^0-9\-\$:/.+ABCD]] 0 1 1
47  
48 #CalcCd
49 1 $oThis->{text} = $sTxt;
50 1 return '';
51 }
52  
53 1 ▶sub barcode {
Subroutine barcode: called CC=2 SCAR=6.9
Pod documented
54 1 my ($oThis) = @_;
55  
56 1 my $sTxt = $oThis->{text};
57 1 my $sRes = '';
58 1 foreach my $sWk ( split( //, $sTxt ) ) {
59 9 $sRes .= GD::Barcode::dumpCode( $nw7Bar->{$sWk} . '0' );
60 }
61 1 return $sRes;
62 }
63  
64 0 ▶sub plot {
Subroutine plot: not called CC=3 SCAR=24.8
Pod documented
65 0 my ( $oThis, %hParam ) = @_;
66  
67 0 my $sTxt = $oThis->{text};
68 0 my $sPtn = $oThis->barcode();
69  
70 #Create Image
71 0 ▶ my $iHeight = ( $hParam{Height} ) ? $hParam{Height} : 50;
Branch: 1 branch
BranchTrueFalseTotal
$hParam{'Height'} ? : 0 0 0
72 0 my ( $oGd, $cBlack );
73 0 ▶ if ( $hParam{NoText} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($hParam{'NoText'}) { } 0 0 0
74 0 ( $oGd, $cBlack ) =
75 GD::Barcode::plot( $sPtn, length($sPtn), $iHeight, 0, 0 );
76 }
77 else {
78 0 my ( $fW, $fH ) = ( GD::Font->Small->width, GD::Font->Small->height );
79 0 my $iWidth = length($sPtn);
80  
81 #Bar Image
82 0 ( $oGd, $cBlack ) =
83 GD::Barcode::plot( $sPtn, $iWidth, $iHeight, $fH, 0 );
84  
85 #String
86 0 $oGd->string(
87 GD::Font->Small,
88 ( length($sPtn) - $fW * ( length($sTxt) ) ) / 2,
89 $iHeight - $fH,
90 $sTxt, $cBlack
91 );
92 }
93 0 return $oGd;
94 }
95 1 1;
96  
97 __END__
« Barcode/Code39.pm ↑ Summary Barcode/QRcode/qrv01M.dat »