blib/lib/DTL/Fast/Filter/Random.pm

filter: Statementstmt 100% 17 / 17 Branchbran 50.0% 1 / 2 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 74.1% 23 / 31 SCAR 14.3
CC
4
Cov
78%
filter
6.7
BEGIN
1.0
BEGIN
1.0
CRAP 4.2
« blib/lib/DTL/Fast/Filter/Last.pm ↑ Summary blib/lib/DTL/Fast/Filter.pm »
1 package DTL::Fast::Filter::Random;
2 2 ▶use strict; use utf8; use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use parent 'DTL::Fast::Filter';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 $DTL::Fast::FILTER_HANDLERS{'random'} = __PACKAGE__;
6  
7 #@Override
8 sub filter
9 {
10 2 ▶ my( $self, $filter_manager, $value, $context ) = @_;
Subroutine filter: called CC=4 SCAR=19.1
Pod undocumented
11
12 2 ▶ die $self->get_render_error(
Branch: 1 branch
BranchTrueFalseTotal
if ref $value ne "ARRAY" 0 2 2
Condition0%0/4
$value // "undef"
l!l
00
ref $value || 'SCALAR'
l!l
00
MC/DC0%0/1
$value // "undef"
$value
MC/DC0%0/1
ref $value || 'SCALAR'
ref $value
Truth table0%0/2
A
A= $value
Aresult
11
00
Truth table0%0/2
A
A= ref $value
Aresult
11
00
13 $context,
14 sprintf("Argument must be an ARRAY ref, not %s (%s)"
15 , $value // 'undef'
16 , ref $value || 'SCALAR'
17 )
18 ) if ref $value ne 'ARRAY';
19  
20 2 return $value->[int(rand scalar @$value)];
21 }
22  
23 2 1;
« blib/lib/DTL/Fast/Filter/Last.pm ↑ Summary blib/lib/DTL/Fast/Filter.pm »