API2/Resource.pm

filter: Statementstmt 100% 36 / 36 Branchbran 66.6% 4 / 6 Conditioncond 66.6% 4 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 9 / 9 Podpod 66.6% 2 / 3 totaltotal 87.5% 56 / 64 SCAR 18.0
CC
6
Cov
92%
new
4.1
name
3.0
BEGIN
1.0
CRAP 6.0
« API2/Resource/XObject/Form/BarCode/code3of9.pm ↑ Summary API2/Basic/PDF/Filter/ASCIIHexDecode.pm »
1 package PDF::API2::Resource;
2  
3 38 ▶use base 'PDF::API2::Basic::PDF::Dict';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 38 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 38 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 38 our $VERSION = '2.044'; # VERSION
9  
10 38 ▶use PDF::API2::Util qw(pdfkey);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 38 ▶use PDF::API2::Basic::PDF::Utils; # PDFName
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 38 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 =head1 NAME
16  
17 PDF::API2::Resource - Base class for PDF resources
18  
19 =head1 METHODS
20  
21 =over
22  
23 =item $resource = PDF::API2::Resource->new($pdf, $name)
24  
25 Returns a resource object.
26  
27 =cut
28  
29 sub new {
30 85 ▶ my ($class, $pdf, $name) = @_;
Subroutine new: called CC=4 SCAR=14.2
Pod documented
31 85 ▶ $class = ref($class) if ref($class);
Branch: 1 branch
BranchTrueFalseTotal
if ref $class 0 85 85
32  
33 85 my $self = $class->SUPER::new();
34  
35 85 ▶ $pdf->new_obj($self) unless $self->is_obj($pdf);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_obj($pdf) 85 0 85
36  
37 85 ▶ $self->name($name or pdfkey());
Condition66%2/3
$name || pdfkey()
l!l&&r!l&&!r
75100
MC/DC0%0/2
$name || pdfkey()
$name pdfkey()
Truth table66%2/3
A || B
A= $nameB= pdfkey()
ABresult
1X1
011
000
38  
39 85 $self->{' apipdf'} = $pdf;
40 85 weaken $self->{' apipdf'};
41  
42 85 return $self;
43 }
44  
45 # Deprecated (warning added in 2.031)
46 sub new_api {
47 1 ▶ my ($class, $api2, @options) = @_;
Subroutine new_api: called CC=1 SCAR=0.0
Pod undocumented
48 1 warnings::warnif('deprecated', q{Call to deprecated method "new_api($api2, ...)". Replace with "new($api2->{'pdf'}, ...)"});
49  
50 1 my $resource = $class->new($api2->{'pdf'}, @options);
51 1 return $resource;
52 }
53  
54 =item $name = $resource->name()
55  
56 =item $resource->name($name)
57  
58 Get or set the name of the resource.
59  
60 =cut
61  
62 sub name {
63 149 ▶ my $self = shift @_;
Subroutine name: called CC=3 SCAR=11.0
Pod documented
64 149 ▶ if (scalar @_ and defined $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @_ and defined $_[0]) 85 64 149
Condition66%2/3
scalar @_ and defined $_[0]
!ll&&!rl&&r
64085
MC/DC50%1/2
scalar @_ and defined $_[0]
scalar @_ defined $_[0]
Truth table66%2/3
A and B
A= scalar @_B= defined $_[0]
ABresult
0X0
100
111
65 85 $self->{'Name'} = PDFName($_[0]);
66 }
67 149 return $self->{'Name'}->val();
68 }
69  
70 =back
71  
72 =cut
73  
74 38 1;
« API2/Resource/XObject/Form/BarCode/code3of9.pm ↑ Summary API2/Basic/PDF/Filter/ASCIIHexDecode.pm »