API2/Basic/PDF/Literal.pm

filter: Statementstmt 35.7% 20 / 56 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 66.6% 6 / 9 Podpod 100% 3 / 3 totaltotal 31.1% 29 / 93 SCAR 45.6
CC
14
Cov
25%
outobjdeep
110.0
new
30.0
val
2.0
CRAP 95.6
« API2/Outline.pm ↑ Summary API2/Resource/XObject/Form/BarCode/qrcode.pm »
1 # Literal PDF Object for Dirty Hacks ...
2 package PDF::API2::Basic::PDF::Literal;
3  
4 40 ▶use base 'PDF::API2::Basic::PDF::Objind';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 40 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 40 our $VERSION = '2.044'; # VERSION
9  
10 40 ▶use PDF::API2::Basic::PDF::Filter;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 40 ▶use PDF::API2::Basic::PDF::Name;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 40 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 40 ▶no warnings qw[ deprecated recursion uninitialized ];
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 sub new
17 {
18 0 ▶ my ($class, @opts) = @_;
Subroutine new: not called CC=5 SCAR=34.0
Pod documented
19 0 my ($self);
20  
21 0 ▶ $class = ref $class if ref $class;
Branch: 1 branch
BranchTrueFalseTotal
if ref $class 0 0 0
22 0 $self = $class->SUPER::new(@_);
23 0 $self->{' realised'} = 1;
24 0 ▶ if(scalar @opts > 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @opts > 1) { } 0 0 0
elsif (scalar @opts == 1) { } 0 0 0
25 0 $self->{-isdict}=1;
26 0 my %opt=@opts;
27 0 foreach my $k (keys %opt) {
28 0 $self->{$k} = $opt{$k};
29 }
30 } elsif(scalar @opts == 1) {
31 0 $self->{-literal}=$opts[0];
32 }
33 0 return $self;
34 }
35  
36 sub outobjdeep
37 {
38 0 ▶ my ($self, $fh, $pdf) = @_;
Subroutine outobjdeep: not called CC=10 SCAR=47.0
Pod documented
39 0 ▶ if($self->{-isdict})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'-isdict'}) { } 0 0 0
40 {
41 0 ▶ if(defined $self->{' stream'})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{' stream'}) { } 0 0 0
42 {
43 0 $self->{Length} = length($self->{' stream'}) + 1;
44 }
45 else
46 {
47 0 delete $self->{Length};
48 }
49 0 $fh->print("<< ");
50 0 foreach my $k (sort keys %{$self})
51 {
52 0 ▶ next if($k=~m|^[ \-]|o);
Branch: 1 branch
BranchTrueFalseTotal
if $k =~ /^[ \-]/o 0 0 0
53 0 $fh->print('/'.PDF::API2::Basic::PDF::Name::string_to_name($k).' ');
54 0 ▶ if(ref($self->{$k}) eq 'ARRAY')
Branch: 3 branches
BranchTrueFalseTotal
if (ref $self->{$k} eq 'ARRAY') { } 0 0 0
elsif (ref $self->{$k} eq 'HASH') { } 0 0 0
elsif (builtin::blessed($self->{$k}) and $self->{$k}->can('outobj')) { } 0 0 0
55 {
56 0 $fh->print('['.join(' ',@{$self->{$k}})."]\n");
57 }
58 elsif(ref($self->{$k}) eq 'HASH')
59 {
60 0 $fh->print('<<'.join(' ', map { '/'.PDF::API2::Basic::PDF::Name::string_to_name($_).' '.$self->{$k}->{$_} } sort keys %{$self->{$k}})." >>\n");
61 }
62 ▶ elsif(blessed($self->{$k}) and $self->{$k}->can('outobj'))
Condition0%0/3
builtin::blessed($self->{$k}) and $self->{$k}->can("outobj")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($self->{$k}) and $self->{$k}->can("outobj")
builtin::blessed($self->{$k}) $self->{$k}->can("outobj")
Truth table0%0/3
A and B
A= builtin::blessed($self->{$k})B= $self->{$k}->can("outobj")
ABresult
0X0
100
111
63 {
64 0 $self->{$k}->outobj($fh, $pdf);
65 0 $fh->print("\n");
66 }
67 else
68 {
69 0 $fh->print("$self->{$k}\n");
70 }
71 }
72 0 $fh->print(">>\n");
73 0 ▶ if(defined $self->{' stream'})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{" stream"}) 0 0 0
74 {
75 0 $fh->print("stream\n$self->{' stream'}\nendstream"); # next is endobj which has the final cr
76 }
77 }
78 else
79 {
80 0 $fh->print($self->{-literal}); # next is endobj which has the final cr
81 }
82 }
83  
84 sub val
85 0 ▶{ $_[0]; }
Subroutine val: not called CC=1 SCAR=6.9
Pod documented
86  
87 40 1;
« API2/Outline.pm ↑ Summary API2/Resource/XObject/Form/BarCode/qrcode.pm »