Sims/Util.pm

filter: Statementstmt 100% 29 / 29 Branchbran 94.4% 17 / 18 Conditioncond 54.5% 6 / 11 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 82.4% 61 / 74 CC 14 SCAR 17.7
CC
14
Cov
90%
normalize_aoh
8.0
compare_values
7.6
reftype
2.0
CRAP 5.9
« Sims/Column.pm ↑ Summary Sims/Source.pm »
1 # vim: set sw=2 ft=perl:
2 package DBIx::Class::Sims::Util;
3  
4 55 ▶use 5.010_001;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 55 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 55 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 55 our @EXPORT_OK = qw(
10 compare_values normalize_aoh reftype
11 );
12  
13 55 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 19 ▶sub compare_values {
Subroutine compare_values: called CC=6 SCAR=20.3
Pod undocumented
16 19 my ($v1, $v2) = @_;
17  
18 19 ▶ return 1 if !defined($v1) && !defined($v2);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v1 or defined $v2 0 19 19
Condition33%1/3
defined $v1 or defined $v2
l!l&&r!l&&!r
1900
MC/DC0%0/2
defined $v1 or defined $v2
defined $v1 defined $v2
Truth table33%1/3
A or B
A= defined $v1B= defined $v2
ABresult
1X1
011
000
19 19 ▶ return 1 if defined($v1) && defined($v2) && $v1 eq $v2;
Branch: 1 branch
BranchTrueFalseTotal
if defined $v1 and defined $v2 and $v1 eq $v2 18 1 19
Condition50%3/6
defined $v1 and defined $v2 and $v1 eq $v2
!ll&&!rl&&r
0118
defined $v1 and defined $v2
!ll&&!rl&&r
0019
MC/DC33%1/3
defined $v1 and defined $v2 and $v1 eq $v2
defined $v1 defined $v2 $v1 eq $v2
Truth table50%2/4
A and B and C
A= defined $v1B= defined $v2C= $v1 eq $v2
ABCresult
0XX0
10X0
1100
1111
20 1 return;
21 }
22  
23 19789 ▶sub reftype {
Subroutine reftype: called CC=2 SCAR=6.9
Pod undocumented
24 19789 ▶ return Scalar::Util::reftype($_[0]) // '';
Condition100%2/2
builtin::reftype($_[0]) // ""
l!l
110848705
MC/DC100%1/1
builtin::reftype($_[0]) // ""
builtin::reftype($_[0])
Truth table100%2/2
A
A= builtin::reftype($_[0])
Aresult
11
00
25 }
26  
27 741 ▶sub normalize_aoh {
Subroutine normalize_aoh: called CC=8 SCAR=20.8
Pod undocumented
28 741 my ($input) = @_;
29  
30 741 ▶ return unless defined $input;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $input 2 739 741
31  
32 # If it's an arrayref, verify all elements are hashrefs
33 739 ▶ if (reftype($input) eq 'ARRAY') {
Branch: 3 branches
BranchTrueFalseTotal
if (reftype($input) eq 'ARRAY') { } 561 178 739
elsif (reftype($input) eq 'HASH') { } 132 46 178
elsif (not reftype($input)) { } 45 1 46
34 561 ▶ return $input unless @$input;
Branch: 1 branch
BranchTrueFalseTotal
unless @$input 1 560 561
35 560 ▶ return $input unless grep { reftype($_) ne 'HASH' } @$input;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {reftype($_) ne "HASH";} @$input 559 1 560
36 }
37 elsif (reftype($input) eq 'HASH') {
38 132 return [$input];
39 }
40 elsif (!reftype($input)) {
41 45 ▶ if ($input =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($input =~ /^\d+$/) 43 2 45
42 43 return [ map { {} } 1 .. $input ];
43 }
44 }
45  
46 4 return;
47 }
48  
49 55 1;
50 __END__
« Sims/Column.pm ↑ Summary Sims/Source.pm »