lib/SVG/Estimate/Path/HorizontalLineto.pm

filter: Statementstmt 100% 22 / 22 Branchbran 58.3% 7 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod 0.0% 0 / 1 totaltotal 83.7% 31 / 37 CC 7 SCAR 18.8
CC
7
Cov
85%
BUILDARGS
7.3
BEGIN
1.0
CRAP 6.6
« lib/SVG/Estimate/Polyline.pm ↑ Summary lib/SVG/Estimate/Path/VerticalLineto.pm »
1 package SVG::Estimate::Path::HorizontalLineto;
2 4 $SVG::Estimate::Path::HorizontalLineto::VERSION = '1.0111';
3 4 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 4 extends 'SVG::Estimate::Path::Command';
6 4 with 'SVG::Estimate::Role::Pythagorean';
7  
8 =head1 NAME
9  
10 SVG::Estimate::Path::HorizontalLineto - Handles estimating horizontal lines.
11  
12 =head1 VERSION
13  
14 version 1.0111
15  
16 =head1 SYNOPSIS
17  
18 my $line = SVG::Estimate::Path::HorizontalLineto->new(
19 transformer => $transform,
20 start_point => [13, 19],
21 x => 13,
22 );
23  
24 my $length = $line->length;
25  
26 =head1 INHERITANCE
27  
28 This class extends L<SVG::Estimate::Path::Command> and consumes L<SVG::Estimate::Role::Pythagorean>.
29  
30 =head1 METHODS
31  
32 =head2 new()
33  
34 Constructor.
35  
36 =over
37  
38 =item x
39  
40 A float indicating what to change the x value to.
41  
42 =back
43  
44 =cut
45  
46 4 has x => (
47 is => 'ro',
48 required => 1,
49 );
50  
51 sub BUILDARGS {
52 2 ▶ my ($class, @args) = @_;
Subroutine BUILDARGS: called CC=7 SCAR=19.9
Pod undocumented
53 ##Upgrade to hashref
54 2 ▶ my $args = @args % 2 ? $args[0] : { @args };
Branch: 1 branch
BranchTrueFalseTotal
@args % 2 ? : 0 2 2
55 2 my $end = [$args->{x}, $args->{start_point}[0]];
56 2 ▶ if ($args->{transformer}->has_transforms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"transformer"}->has_transforms) 1 1 2
57 1 $end = $args->{transformer}->transform($end);
58 }
59 2 $args->{end_point} = [$end->[0], $args->{start_point}[1]];
60 2 $args->{y} = $args->{end_point}[1];
61 2 $args->{shape_length} = $class->pythagorean($args->{start_point}, $args->{end_point});
62 2 $args->{travel_length} = 0;
63 2 ▶ $args->{min_x} = $args->{start_point}[0] < $args->{end_point}->[0] ? $args->{start_point}[0] : $args->{end_point}->[0];
Branch: 1 branch
BranchTrueFalseTotal
$args->{'start_point'}[0] < $args->{'end_point'}[0] ? : 2 0 2
64 2 ▶ $args->{min_y} = $args->{start_point}[1] < $args->{end_point}->[1] ? $args->{start_point}[1] : $args->{end_point}->[1];
Branch: 1 branch
BranchTrueFalseTotal
$args->{'start_point'}[1] < $args->{'end_point'}[1] ? : 0 2 2
65 2 ▶ $args->{max_x} = $args->{start_point}[0] > $args->{end_point}->[0] ? $args->{start_point}[0] : $args->{end_point}->[0];
Branch: 1 branch
BranchTrueFalseTotal
$args->{'start_point'}[0] > $args->{'end_point'}[0] ? : 0 2 2
66 2 ▶ $args->{max_y} = $args->{start_point}[1] > $args->{end_point}->[1] ? $args->{start_point}[1] : $args->{end_point}->[1];
Branch: 1 branch
BranchTrueFalseTotal
$args->{'start_point'}[1] > $args->{'end_point'}[1] ? : 0 2 2
67 2 return $args;
68 }
69  
70 4 1;
« lib/SVG/Estimate/Polyline.pm ↑ Summary lib/SVG/Estimate/Path/VerticalLineto.pm »