| 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]) // ""
MC/DC100%1/1
builtin::reftype($_[0]) // ""
builtin::reftype($_[0])
Truth table100%2/2
A
A= builtin::reftype($_[0])
| |||||||||||||||||||
| 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
| |||||||||||||||||||
| 19 | |||||||||||||||||||
| 20 | # If it's an arrayref, verify all elements are hashrefs | ||||||||||||||||||
| 21 | 93 | ▶ | if (reftype($input) eq 'ARRAY') { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 22 | 36 | ▶ | return $input unless @$input; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 23 | 35 | ▶ | return $input unless grep { reftype($_) ne 'HASH' } @$input; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 24 | } | ||||||||||||||||||
| 25 | elsif (reftype($input) eq 'HASH') { | ||||||||||||||||||
| 26 | 37 | return [$input]; | |||||||||||||||||
| 27 | } | ||||||||||||||||||
| 28 | elsif (!reftype($input)) { | ||||||||||||||||||
| 29 | 19 | ▶ | if ($input =~ /^\d+$/) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 30 | 17 | return [ map { {} } 1 .. $input ]; | |||||||||||||||||
| 31 | } | ||||||||||||||||||
| 32 | } | ||||||||||||||||||
| 33 | |||||||||||||||||||
| 34 | 4 | return; | |||||||||||||||||
| 35 | } | ||||||||||||||||||
| 36 | |||||||||||||||||||
| 37 | 26 | 1; | |||||||||||||||||
| 38 | __END__ | ||||||||||||||||||