Sims/Util.pm

filter: Statementstmt 100% 22 / 22 Branchbran 100% 14 / 14 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 95.6% 44 / 46 CC 9 SCAR 17.0
CC
9
Cov
100%
normalize_aoh
8.0
reftype
2.0
BEGIN
1.0
CRAP 5.5
« Sims.pm ↑ Summary Sims/Types.pm »
1 # vim: set sw=2 ft=perl:
2 package DBIx::Class::Sims::Util;
3  
4 26 ▶use 5.010_002;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 26 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 26 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 sub reftype {
11 227 ▶ return Scalar::Util::reftype($_[0]) // '';
Subroutine reftype: called CC=2 SCAR=6.9
Pod undocumented
Condition100%2/2
builtin::reftype($_[0]) // ""
l!l
16958
MC/DC100%1/1
builtin::reftype($_[0]) // ""
builtin::reftype($_[0])
Truth table100%2/2
A
A= builtin::reftype($_[0])
Aresult
11
00
12 }
13  
14 sub normalize_aoh {
15 95 ▶ shift;
Subroutine normalize_aoh: called CC=8 SCAR=20.8
Pod undocumented
16 95 my ($input) = @_;
17  
18 95 ▶ return unless defined $input;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $input 2 93 95
19  
20 # If it's an arrayref, verify all elements are hashrefs
21 93 ▶ if (reftype($input) eq 'ARRAY') {
Branch: 3 branches
BranchTrueFalseTotal
if (reftype($input) eq 'ARRAY') { } 36 57 93
elsif (reftype($input) eq 'HASH') { } 37 20 57
elsif (not reftype($input)) { } 19 1 20
22 36 ▶ return $input unless @$input;
Branch: 1 branch
BranchTrueFalseTotal
unless @$input 1 35 36
23 35 ▶ return $input unless grep { reftype($_) ne 'HASH' } @$input;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {reftype($_) ne "HASH";} @$input 34 1 35
24 }
25 elsif (reftype($input) eq 'HASH') {
26 37 return [$input];
27 }
28 elsif (!reftype($input)) {
29 19 ▶ if ($input =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($input =~ /^\d+$/) 17 2 19
30 17 return [ map { {} } 1 .. $input ];
31 }
32 }
33  
34 4 return;
35 }
36  
37 26 1;
38 __END__
« Sims.pm ↑ Summary Sims/Types.pm »