API2/Resource/XObject/Form/BarCode/qrcode.pm

filter: Statementstmt 31.2% 15 / 48 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 66.6% 4 / 6 Podpod 100% 2 / 2 totaltotal 26.9% 21 / 78 SCAR 43.6
CC
12
Cov
23%
new
90.0
render
20.0
BEGIN
1.0
CRAP 78.4
« API2/Basic/PDF/Literal.pm ↑ Summary API2/Resource/ColorSpace/DeviceN.pm »
1 package PDF::API2::Resource::XObject::Form::BarCode::qrcode;
2  
3 1 ▶use base 'PDF::API2::Resource::XObject::Form::BarCode';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION = '2.044'; # VERSION
9  
10 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 our @CARP_NOT = qw(PDF::API2);
13  
14 sub new {
15 0 ▶ my ($class, $pdf, %options) = @_;
Subroutine new: not called CC=9 SCAR=45.0
Pod documented
16 0 my $self = $class->SUPER::new($pdf, %options);
17  
18 0 eval {
19 0 require Text::QRCode;
20 };
21 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
22 0 croak "Error loading Text::QRCode: $@";
23 }
24  
25 0 ▶ my $mode = $options{'mode'} // '8-bit';
Condition0%0/2
$options{"mode"} // "8-bit"
l!l
00
MC/DC0%0/1
$options{"mode"} // "8-bit"
$options{"mode"}
Truth table0%0/2
A
A= $options{"mode"}
Aresult
11
00
26 0 ▶ $mode = 'numerical' if $mode eq 'numeric';
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "numeric" 0 0 0
27 0 ▶ $mode = 'alpha-numerical' if $mode eq 'alphanumeric';
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "alphanumeric" 0 0 0
28 0 ▶ $mode = 'alpha-numerical' if $mode eq 'alpha-numeric';
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "alpha-numeric" 0 0 0
29  
30 my $generator = Text::QRCode->new(
31 level => ($options{'error_correction'} // 'L'),
32 version => ($options{'version'} // 0),
33 mode => $mode,
34 0 ▶ casesensitive => ($options{'case_sensitive'} // 1),
Condition0%0/6
$options{"error_correction"} // "L"
l!l
00
$options{"version"} // 0
l!l
00
$options{"case_sensitive"} // 1
l!l
00
MC/DC0%0/1
$options{"error_correction"} // "L"
$options{"error_correction"}
MC/DC0%0/1
$options{"version"} // 0
$options{"version"}
MC/DC0%0/1
$options{"case_sensitive"} // 1
$options{"case_sensitive"}
Truth table0%0/2
A
A= $options{"error_correction"}
Aresult
11
00
Truth table0%0/2
A
A= $options{"version"}
Aresult
11
00
Truth table0%0/2
A
A= $options{"case_sensitive"}
Aresult
11
00
35 );
36  
37 0 my $lines_ref = $generator->plot($options{'code'});
38 0 my @lines = reverse map { join('', @$_) } @$lines_ref;
39  
40 0 $self->render(@lines);
41 0 return $self;
42 }
43  
44 sub render {
45 0 ▶ my ($self, @lines) = @_;
Subroutine render: not called CC=4 SCAR=30.0
Pod documented
46  
47 0 $self->fillcolor($self->{' color'});
48  
49 0 my $y = $self->{' quzn'};
50 0 my $w = $self->{' mils'} / 1000 * 72;
51 0 my $h = $self->{' zone'};
52 0 foreach my $line (@lines) {
53 0 my $x = $self->{' quzn'};
54 0 foreach my $char (split m//, $line) {
55 0 ▶ if ($char eq '*') {
Branch: 1 branch
BranchTrueFalseTotal
if ($char eq "*") 0 0 0
56 0 $self->rectangle($x, $y, $x + $w, $y + $h);
57 0 $self->fill();
58 }
59 0 $x += $w;
60 }
61 0 $y += $h;
62 }
63  
64 0 $self->{' w'} = 2 * $self->{' quzn'} + length($lines[0]) * $w;
65 0 $self->{' h'} = 2 * $self->{' quzn'} + length($lines[0]) * $h;
66 0 $self->bbox(0, 0, $self->{' w'}, $self->{' h'});
67  
68 0 return $self;
69 }
70  
71 1 1;
72  
73 __END__
« API2/Basic/PDF/Literal.pm ↑ Summary API2/Resource/ColorSpace/DeviceN.pm »