blib/lib/PDF/Make/Builder/Shape/Line.pm

filter: Statementstmt 97.0% 33 / 34 Branchbran 90.0% 9 / 10 Conditioncond 80.0% 4 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 91.3% 53 / 58 CC 8 SCAR 17.4
CC
8
Cov
94%
add
8.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.7
« blib/lib/PDF/Make/Form.pm ↑ Summary blib/lib/PDF/Make/Builder/Text/H4.pm »
1 package PDF::Make::Builder::Shape::Line;
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  
6 53 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
7 53 Object::Proto::define('PDF::Make::Builder::Shape::Line',
8 'fill_colour:Str:default(#000)',
9 'x:Num', 'y:Num',
10 'ex:Num', 'ey:Num',
11 'type:Str:default(solid)',
12 'dash:ArrayRef',
13 );
14 53 Object::Proto::import_accessors('PDF::Make::Builder::Shape::Line');
15 }
16  
17 8 ▶sub add {
Subroutine add: called CC=8 SCAR=20.8
Pod documented
18 8 my ($self, $builder) = @_;
19 8 my $page = $builder->page;
20 8 my $canvas = $page->canvas;
21 8 my $font = $builder->font;
22  
23 8 ▶ my $lx = $self->x // $page->content_x;
Condition66%2/3
$self->x // $page->content_x
l!l&&r!l&&!r
530
MC/DC0%0/2
$self->x // $page->content_x
$self->x $page->content_x
Truth table66%2/3
A // B
A= $self->xB= $page->content_x
ABresult
1X1
011
000
24 8 ▶ my $lex = ex($self) // ($page->content_x + $page->width);
Condition100%2/2
<custom op object_func_get> // $page->content_x + $page->width
l!l
53
MC/DC100%1/1
<custom op object_func_get> // $page->content_x + $page->width
<custom op object_func_get>
Truth table100%2/2
A
A= <custom op object_func_get>
Aresult
11
00
25 8 my $ly = $self->y;
26 8 my $ley = ey($self);
27  
28 8 ▶ if (!defined $ly) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ly) 6 2 8
29 6 $ly = $page->cursor_y;
30 }
31 8 ▶ $ley = defined $ley ? $ley : $ly;
Branch: 1 branch
BranchTrueFalseTotal
defined $ley ? : 2 6 8
32  
33 8 my ($r, $g, $b) = $font->hex_to_rgb(fill_colour $self);
34  
35 8 $canvas->q->w(1)->RG($r, $g, $b);
36  
37 8 my $tp = type $self;
38 8 my $d = dash $self;
39 8 ▶ if ($d) {
Branch: 3 branches
BranchTrueFalseTotal
if ($d) { } 0 8 8
elsif ($tp eq 'dashed') { } 1 7 8
elsif ($tp eq 'dots') { } 1 6 7
40 0 $canvas->d($d, 0);
41 } elsif ($tp eq 'dashed') {
42 1 $canvas->d([6, 3], 0);
43 } elsif ($tp eq 'dots') {
44 1 $canvas->J(1)->d([0, 4], 0);
45 }
46  
47 8 $canvas->m($lx, $ly)->l($lex, $ley)->S->Q;
48  
49 # Advance cursor
50 8 $page->advance_y(2);
51  
52 8 return $self;
53 }
54  
55 53 1;
56  
57 __END__
« blib/lib/PDF/Make/Form.pm ↑ Summary blib/lib/PDF/Make/Builder/Text/H4.pm »