blib/lib/Graphics/Primitive/Brush.pm

filter: Statementstmt 91.3% 53 / 58 Branchbran 71.4% 20 / 28 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 86.6% 84 / 97 CC 16 SCAR 22.4
CC
16
Cov
85%
equal_to
14.9
derive
4.1
BEGIN
1.0
CRAP 9.4
« blib/lib/Graphics/Primitive/Font.pm ↑ Summary blib/lib/Graphics/Primitive/ComponentList.pm »
1 package Graphics::Primitive::Brush;
2 11 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 11 ▶use Moose::Util::TypeConstraints;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use MooseX::Storage;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 11 with 'MooseX::Clone';
7 11 with Storage (format => 'JSON', io => 'File');
8  
9 11 enum 'LineCap' => [qw(butt round square)];
10 11 enum 'LineJoin' => [qw(miter round bevel)];
11  
12 11 has 'color' => ( is => 'rw', isa => 'Graphics::Color', traits => [qw(Clone)] );
13 11 has 'dash_pattern' => ( is => 'rw', isa => 'ArrayRef' );
14 100 ▶has 'width' => ( is => 'rw', isa => 'Int', default => sub { 0 } );
Subroutine __ANON__: called CC=1 SCAR=0.0
15 11 has 'line_cap' => ( is => 'rw', isa => 'LineCap', default => 'butt' );
16 11 has 'line_join' => ( is => 'rw', isa => 'LineJoin', default => 'miter' );
17  
18 11 __PACKAGE__->meta->make_immutable;
19  
20 1 ▶sub derive {
Subroutine derive: called CC=4 SCAR=14.1
Pod documented
21 1 my ($self, $args) = @_;
22  
23 1 ▶ return unless ref($args) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args eq "HASH" 0 1 1
24 1 my $new = $self->clone;
25 1 foreach my $key (keys %{ $args }) {
26 1 ▶ $new->$key($args->{$key}) if($new->can($key));
Branch: 1 branch
BranchTrueFalseTotal
if $new->can($key) 1 0 1
27 }
28 1 return $new;
29 }
30  
31 22 ▶sub equal_to {
Subroutine equal_to: called CC=13 SCAR=27.0
Pod documented
32 22 my ($self, $other) = @_;
33  
34 22 ▶ return 0 unless defined($other);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $other 0 22 22
35  
36 22 ▶ unless($self->width == $other->width) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->width == $other->width) 1 21 22
37 1 return 0;
38 }
39  
40 21 ▶ unless($self->line_cap eq $other->line_cap) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->line_cap eq $other->line_cap) 0 21 21
41 0 return 0;
42 }
43  
44 21 ▶ unless($self->line_join eq $other->line_join) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->line_join eq $other->line_join) 0 21 21
45 0 return 0;
46 }
47  
48 21 ▶ if(defined($self->color)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->color) { } 13 8 21
49 13 ▶ unless($self->color->equal_to($other->color)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->color->equal_to($other->color)) 2 11 13
50 2 return 0;
51 }
52 } else {
53 8 ▶ if(defined($other->color)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $other->color) 0 8 8
54 0 return 0;
55 }
56 }
57  
58 19 ▶ if(defined($self->dash_pattern)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->dash_pattern) { } 2 17 19
59 2 ▶ unless(scalar(@{ $self->dash_pattern }) == scalar(@{ $other->dash_pattern })) {
Branch: 1 branch
BranchTrueFalseTotal
unless (scalar @{$self->dash_pattern;} == scalar @{$other->dash_pattern;}) 0 2 2
60 0 return 0;
61 }
62  
63 2 ▶ for(my $i = 0; $i < scalar(@{ $self->dash_pattern }); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$self->dash_pattern;}) 6 1 7
64 6 ▶ unless($self->dash_pattern->[$i] == $other->dash_pattern->[$i]) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->dash_pattern->[$i] == $other->dash_pattern->[$i]) 1 5 6
65 1 return 0;
66 }
67 }
68 } else {
69 17 ▶ if(defined($other->dash_pattern)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $other->dash_pattern) 0 17 17
70 0 return 0;
71 }
72 }
73  
74 18 return 1;
75 }
76  
77 2 ▶sub not_equal_to {
Subroutine not_equal_to: called CC=1 SCAR=0.0
Pod documented
78 2 my ($self, $other) = @_;
79  
80 2 return !$self->equal_to($other);
81 }
82  
83 11 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
84 11 1;
85 __END__
« blib/lib/Graphics/Primitive/Font.pm ↑ Summary blib/lib/Graphics/Primitive/ComponentList.pm »