blib/lib/SVG/Barcode/Code128.pm

filter: Statementstmt 100% 38 / 38 Branchbran n/a Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 12 / 12 Podpod 100% 1 / 1 totaltotal 92.8% 52 / 56 CC 2 SCAR 1.6
CC
2
Cov
95%
_plot
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
↑ Summary
1 package SVG::Barcode::Code128;
2 2 ▶use parent 'SVG::Barcode';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use v5.24;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use feature 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶no warnings 'experimental::signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 our @EXPORT_OK = qw|plot_code128|;
12  
13 2 ▶use Barcode::Code128;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 our $VERSION = '0.10';
16  
17 2 use constant DEFAULTS => {
18 lineheight => 30,
19 linewidth => 1,
20 textsize => 10,
21 2 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 2 SVG::Barcode::_param(__PACKAGE__, $_, DEFAULTS->{$_}) for keys DEFAULTS->%*;
24  
25 # functions
26  
27 ▶sub plot_code128 ($text, %params) {
Subroutine plot_code128: called CC=1 SCAR=0.0
Pod documented
28 2 return __PACKAGE__->new(%params)->plot($text);
29 }
30  
31 # internal methods
32  
33 ▶sub _plot ($self, $text) {
Subroutine _plot: called CC=2 SCAR=7.4
34 4 ▶ $self->{plotter} ||= Barcode::Code128->new;
Condition33%1/3
$self->{"plotter"} ||= "Barcode::Code128"->new
l!l&&r!l&&!r
040
MC/DC0%0/2
$self->{"plotter"} ||= "Barcode::Code128"->new
$self->{"plotter"} "Barcode::Code128"->new
Truth table33%1/3
A ||= B
A= $self->{"plotter"}B= "Barcode::Code128"->new
ABresult
1X1
011
000
35  
36 4 my @code = split //, $self->{plotter}->barcode($text);
37 4 $self->_plot_1d(\@code, '#');
38 4 $self->_plot_text($text);
39 }
40  
41 2 1;
42  
43 =encoding utf8
44  
45 =head1 NAME
46  
47 SVG::Barcode::Code128 - Generator for SVG based Code 128 barcodes
48  
49 =head1 SYNOPSIS
50  
51 use SVG::Barcode::Code128;
52  
53 my $code128 = SVG::Barcode::Code128->new;
54 my $svg = $code128->plot('https://perldoc.pl');
55  
56 $code118->linewidth; # 1
57 $code118->lineheight; # 30
58 $code118->textsize; # 10
59 # from SVG::Barcode:
60 $code118->foreground; # black
61 $code118->background; # white
62 $code118->margin; # 2
63 $code118->id;
64 $code118->class;
65 $code118->width;
66 $code118->height;
67  
68 my %params = (
69 lineheight => 40,
70 textsize => 0,
71 );
72 $code128 = SVG::Barcode::Code128->new(%params);
73  
74 # use as function
75 use SVG::Barcode::Code128 'plot_code128';
76  
77 my $svg = plot_code128('https://perldoc.pl', %params);
78  
79 =head1 DESCRIPTION
80  
81 L<SVG::Barcode::Code128> is a generator for SVG based Code 128 barcodes.
82  
83 =head1 FUNCTIONS
84  
85 =head2 plot_code128
86  
87 use SVG::Barcode::Code128 'plot_code128';
88  
89 $svg = plot_code128($text, %params);
90  
91 Returns a Code 128 barcode using the provided text and parameters.
92  
93 =head1 CONSTRUCTOR
94  
95 =head2 new
96  
97 $code128 = SVG::Barcode::Code128->new; # create with defaults
98 $code128 = SVG::Barcode::Code128->new(\%params);
99  
100 Creates a new Code 128 plotter. Inherited from L<SVG::Barcode|SVG::Barcode/new>.
101  
102 =head1 METHODS
103  
104 =head2 plot
105  
106 Creates a SVG code. Inherited from L<SVG::Barcode|SVG::Barcode/plot>.
107  
108 =head1 PARAMETERS
109  
110 Inherited from L<SVG::Barcode>:
111 L<background|SVG::Barcode/background>,
112 L<class|SVG::Barcode/class>,
113 L<foreground|SVG::Barcode/foreground>,
114 L<height|SVG::Barcode/height>,
115 L<id|SVG::Barcode/id>,
116 L<margin|SVG::Barcode/margin>,
117 L<width|SVG::Barcode/width>.
118  
119 =head2 lineheight
120  
121 $value = $qrcode->lineheight;
122 $qrcode = $qrcode->lineheight($newvalue);
123 $qrcode = $qrcode->lineheight(''); # 30
124  
125 Getter and setter for the height of a line. Default C<30>.
126  
127 =head2 linewidth
128  
129 $value = $qrcode->linewidth;
130 $qrcode = $qrcode->linewidth($newvalue);
131 $qrcode = $qrcode->linewidth(''); # 1
132  
133 Getter and setter for the width of a single line. Default C<1>.
134  
135 =head2 textsize
136  
137 $value = $qrcode->textsize;
138 $qrcode = $qrcode->textsize($newvalue);
139 $qrcode = $qrcode->textsize(''); # 10
140  
141 Getter and setter for the size of the text a the bottom. C<0> hides the text. Default C<10>.
142  
143 =head1 SEE ALSO
144  
145 L<SVG::Barcode>, L<Barcode::Code128>.
146  
147 =head1 AUTHOR & COPYRIGHT
148  
149 © 2019 by Tekki (Rolf Stöckli).
150  
151 This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.
152  
153 =cut
↑ Summary