OFC/Role/OFCDataLines.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 100% 46 / 46 CC 3 SCAR 5.1
CC
3
Cov
100%
_format_value
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.7
« OFC/Types.pm ↑ Summary OFC/YAxis.pm »
1 package Chart::OFC::Role::OFCDataLines;
2 41 $Chart::OFC::Role::OFCDataLines::VERSION = '0.12';
3 41 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 41 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 41 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 41 requires '_ofc_data_lines';
9  
10 sub _data_line ## no critic RequireArgUnpacking
11 215 ▶{
Subroutine _data_line: called CC=1 SCAR=0.0
12 215 my $self = shift;
13 215 my $label = shift;
14 215 my @vals = @_;
15  
16 215 $label =~ s/color/colour/;
17  
18 215 my $line = q{&} . $label . q{=};
19  
20 $line .=
21 215 join ',', map { $self->_format_value($_) } @vals;
22  
23 215 $line .= q{&};
24  
25 215 return $line;
26 }
27  
28 sub _format_value
29 694 ▶{
Subroutine _format_value: called CC=3 SCAR=11.0
30 694 my $self = shift;
31 694 my $value = shift;
32  
33 694 ▶ return 'null' unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 5 689 694
34  
35 # nested array ref values attr for things like scatter charts
36 689 ▶ if ( ref $value eq 'ARRAY' )
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq 'ARRAY') { } 21 668 689
37 {
38 21 return '[' . ( join ',', @{ $value } ) . ']';
39 }
40 else
41 {
42 668 return $self->_escape($value);
43 }
44 }
45  
46 sub _escape
47 668 ▶{
Subroutine _escape: called CC=1 SCAR=0.0
48 668 shift;
49 668 my $string = shift;
50  
51 668 $string =~ s/,/#comma#/g;
52  
53 668 return $string;
54 }
55  
56 41 ▶no Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
57  
58 41 1;
59  
60 # ABSTRACT: helper for classes which generate OFC data
61  
62 __END__
« OFC/Types.pm ↑ Summary OFC/YAxis.pm »