Create/Outline.pm

filter: Statementstmt 91.5% 65 / 71 Branchbran 81.2% 13 / 16 Conditioncond 44.4% 4 / 9 MC/DCmcdc 20.0% 1 / 5 Subroutinesub 92.3% 12 / 13 Podpod 0.0% 0 / 6 totaltotal 79.1% 95 / 120 CC 14 SCAR 13.5
CC
14
Cov
85%
add
7.4
count
5.0
list
3.0
CRAP 3.8
« Create.pm ↑ Summary
1 #
2 # PDF::Create::Outline - PDF outline support for PDF::Create
3 #
4 # Author: Fabien Tassin
5 #
6 # Copyright 1999-2001 Fabien Tassin
7 # Copyright 2007 Markus Baertschi <markus@markus.org>
8 # Copyright 2010 Gary Lieberman
9 #
10 # Please see the CHANGES and Changes file for the detailed change log
11 #
12 # Please do not use any of the methods here directly. You will be
13 # punished with your application no longer working after an upgrade !
14 #
15  
16 package PDF::Create::Outline;
17  
18 18 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 18 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 18 ▶use FileHandle;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 18 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 18 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 18 our $VERSION = '1.28';
28 18 our $DEBUG = 0;
29  
30 sub new
31 {
32 25 ▶ my $this = shift;
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
33 25 ▶ my $class = ref($this) || $this;
Condition33%1/3
ref $this || $this
l!l&&r!l&&!r
0250
MC/DC0%0/2
ref $this || $this
ref $this $this
Truth table33%1/3
A || B
A= ref $thisB= $this
ABresult
1X1
011
000
34 25 my $self = {};
35 25 bless $self, $class;
36 25 $self->{'Kids'} = [];
37 25 $self;
38 }
39  
40 sub add
41 {
42 20 ▶ my $self = shift;
Subroutine add: called CC=7 SCAR=20.0
Pod undocumented
43 20 my $outline = PDF::Create::Outline->new();
44 20 $outline->{'id'} = shift;
45 20 $outline->{'name'} = shift;
46 20 $outline->{'Parent'} = $self;
47 20 weaken $outline->{Parent};
48 20 $outline->{'pdf'} = $self->{'pdf'};
49 20 weaken $outline->{pdf};
50 20 my %params = @_;
51 20 ▶ $outline->{'Title'} = $params{'Title'} if defined $params{'Title'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $params{"Title"} 20 0 20
52 20 ▶ $outline->{'Action'} = $params{'Action'} if defined $params{'Action'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $params{"Action"} 0 20 20
53 $outline->{'Status'} = defined $params{'Status'}
54 20 ▶ && ( $params{'Status'} eq 'closed' || !$params{'Status'} ) ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $params{'Status'} && ($params{'Status'} eq 'closed' || !$params{'Status'}) ? : 2 18 20
Condition50%3/6
defined $params{"Status"} and $params{"Status"} eq "closed" || !$params{"Status"}
!ll&&!rl&&r
1802
$params{"Status"} eq "closed" or not $params{"Status"}
l!l&&r!l&&!r
200
MC/DC33%1/3
defined $params{"Status"} and $params{"Status"} eq "closed" || !$params{"Status"}
defined $params{"Status"} $params{"Status"} eq "closed" not $params{"Status"}
Truth table50%2/4
A and B or not(C)
A= defined $params{"Status"}B= $params{"Status"} eq "closed"C= not $params{"Status"}
ABCresult
0XX0
1000
11X1
1011
55 $outline->{'Dest'} = $params{'Destination'}
56 20 ▶ if defined $params{'Destination'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $params{"Destination"} 20 0 20
57 20 push @{ $self->{'Kids'} }, $outline;
58 20 $outline;
59 }
60  
61 sub count
62 {
63 51 ▶ my $self = shift;
Subroutine count: called CC=5 SCAR=16.1
Pod undocumented
64  
65 51 my $c = scalar @{ $self->{'Kids'} };
66 51 ▶ return $c unless $c;
Branch: 1 branch
BranchTrueFalseTotal
unless $c 36 15 51
67 15 for my $outline ( @{ $self->{'Kids'} } ) {
68 30 my $v = $outline->count;
69 30 ▶ $c += $v if $outline->{'Status'};
Branch: 1 branch
BranchTrueFalseTotal
if $outline->{"Status"} 26 4 30
70 }
71 15 ▶ $c *= -1 unless $self->{'Status'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"Status"} 6 9 15
72 15 $c;
73 }
74  
75 sub kids
76 {
77 0 ▶ my $self = shift;
Subroutine kids: not called CC=1 SCAR=6.9
Pod undocumented
78  
79 0 my $t = [];
80 0 map { push @$t, $_->{'id'} } @{ $self->{'Kids'} };
81 0 $t;
82 }
83  
84 sub list
85 {
86 21 ▶ my $self = shift;
Subroutine list: called CC=3 SCAR=11.0
Pod undocumented
87 21 my @l;
88 21 for my $e ( @{ $self->{'Kids'} } ) {
89 18 my @t = $e->list;
90 18 push @l, $e;
91 18 ▶ push @l, @t if scalar @t;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @t 5 13 18
92 }
93 21 @l;
94 }
95  
96 sub new_outline
97 {
98 8 ▶ my $self = shift;
Subroutine new_outline: called CC=1 SCAR=0.0
Pod undocumented
99  
100 8 $self->{'pdf'}->new_outline( 'Parent' => $self, @_ );
101 }
102  
103 18 1;
« Create.pm ↑ Summary