| 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
Condition33%1/3
defined $v1 or defined $v2
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
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 19 | ▶ | return 1 if defined($v1) && defined($v2) && $v1 eq $v2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $v1 and defined $v2 and $v1 eq $v2
defined $v1 and defined $v2
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
| |||||||||||||||||||||||||||||||||||||||||||
| 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]) // ""
MC/DC100%1/1
builtin::reftype($_[0]) // ""
builtin::reftype($_[0])
Truth table100%2/2
A
A= builtin::reftype($_[0])
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | # If it's an arrayref, verify all elements are hashrefs | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 739 | ▶ | if (reftype($input) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 561 | ▶ | return $input unless @$input; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 560 | ▶ | return $input unless grep { reftype($_) ne 'HASH' } @$input; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | elsif (reftype($input) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 132 | return [$input]; | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | elsif (!reftype($input)) { | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 45 | ▶ | if ($input =~ /^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 43 | return [ map { {} } 1 .. $input ]; | |||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 55 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 50 | __END__ | ||||||||||||||||||||||||||||||||||||||||||