blib/lib/PDF/Make/Builder/Layout.pm

filter: Statementstmt 97.5% 39 / 40 Branchbran 83.3% 5 / 6 Conditioncond 100% 4 / 4 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 96.8% 61 / 63 CC 8 SCAR 9.7
CC
8
Cov
96%
_weaken_layout_ref
4.1
row
4.0
render
2.0
CRAP 2.6
« blib/lib/PDF/Make/Extract/Result.pm ↑ Summary blib/lib/PDF/Make/Builder/Form/Field/Text.pm »
1 package PDF::Make::Builder::Layout;
2 53 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 53 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 53 ▶use Object::Proto;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 53 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 53 ▶use PDF::Make::Builder::Layout::Row;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 53 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
9 53 Object::Proto::define('PDF::Make::Builder::Layout',
10 'builder:required',
11 'rows:ArrayRef:default([])',
12 );
13 53 Object::Proto::import_accessors('PDF::Make::Builder::Layout');
14 }
15  
16 # Layout holds its rows and each row points back at the layout: the same
17 # cycle as Row and Cell, and leaked the same way. Weakened here for the same
18 # reason and by the same identity scan.
19 4016 ▶sub _weaken_layout_ref {
Subroutine _weaken_layout_ref: called CC=4 SCAR=14.1
20 4016 my ($row, $layout) = @_;
21 4016 for my $i (0 .. $#$row) {
22 8032 ▶ next unless ref $row->[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless ref $row->[$i] 4016 4016 8032
23 4016 ▶ next unless $row->[$i] == $layout;
Branch: 1 branch
BranchTrueFalseTotal
unless $row->[$i] == $layout 0 4016 4016
24 4016 Scalar::Util::weaken($row->[$i]);
25 4016 return 1;
26 }
27 0 return 0;
28 }
29  
30 4016 ▶sub row {
Subroutine row: called CC=4 SCAR=13.9
Pod documented
31 4016 my ($self, %args) = @_;
32 4016 my $rows = rows $self;
33 my %row_args = (
34 layout => $self,
35 margin => $args{margin} // 5,
36 4016 ▶ gap => $args{gap} // 0,
Condition100%4/4
$args{"margin"} // 5
l!l
34013
$args{"gap"} // 0
l!l
14015
MC/DC100%1/1
$args{"margin"} // 5
$args{"margin"}
MC/DC100%1/1
$args{"gap"} // 0
$args{"gap"}
Truth table100%2/2
A
A= $args{"margin"}
Aresult
11
00
Truth table100%2/2
A
A= $args{"gap"}
Aresult
11
00
37 );
38 4016 ▶ $row_args{height} = $args{height} if defined $args{height};
Branch: 1 branch
BranchTrueFalseTotal
if defined $args{"height"} 9 4007 4016
39 4016 my $row = PDF::Make::Builder::Layout::Row->new(%row_args);
40 4016 _weaken_layout_ref($row, $self);
41 4016 push @$rows, $row;
42 4016 return $row;
43 }
44  
45 378 ▶sub render {
Subroutine render: called CC=2 SCAR=6.9
Pod documented
46 378 my ($self) = @_;
47 378 my $builder = builder $self;
48 378 my $page = $builder->page;
49  
50 378 for my $row (@{rows $self}) {
51 4011 $row->render($builder, $page);
52 }
53  
54 378 return $builder;
55 }
56  
57 53 1;
58  
59 __END__
« blib/lib/PDF/Make/Extract/Result.pm ↑ Summary blib/lib/PDF/Make/Builder/Form/Field/Text.pm »