File Coverage

blib/lib/DTL/Fast/Filter/Length.pm
Criterion Covered Total %
statement 20 20 100.0
branch 2 2 100.0
condition 1 2 50.0
subroutine 5 5 100.0
pod 0 1 0.0
total 28 30 93.3


line stmt bran cond sub pod time code
1             package DTL::Fast::Filter::Length;
2 3     3   1073 use strict; use utf8; use warnings FATAL => 'all';
  3     3   4  
  3     3   62  
  3         8  
  3         3  
  3         11  
  3         49  
  3         3  
  3         79  
3 3     3   9 use parent 'DTL::Fast::Filter';
  3         3  
  3         12  
4              
5             $DTL::Fast::FILTER_HANDLERS{'length'} = __PACKAGE__;
6              
7             #@Override
8             sub filter
9             {
10 6     6 0 4 shift; # self
11 6         5 shift; # filter_manager
12 6         8 my $value = shift; # value
13 6         4 shift; # context
14              
15 6 100       8 if( ref $value eq 'ARRAY' )
16             {
17 3         5 $value = scalar @$value;
18             }
19             else
20             {
21 3   50     8 $value = length( $value // '' );
22             }
23            
24 6         9 return $value;
25             }
26              
27             1;