line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Filter::Divisibleby; |
2
|
2
|
|
|
2
|
|
739
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
45
|
|
3
|
2
|
|
|
2
|
|
8
|
use utf8; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
8
|
|
4
|
2
|
|
|
2
|
|
38
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
54
|
|
5
|
2
|
|
|
2
|
|
8
|
use parent 'DTL::Fast::Filter'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
7
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$DTL::Fast::FILTER_HANDLERS{divisibleby} = __PACKAGE__; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
112
|
use Scalar::Util qw(looks_like_number); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
324
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#@Override |
12
|
|
|
|
|
|
|
sub parse_parameters |
13
|
|
|
|
|
|
|
{ |
14
|
144
|
|
|
144
|
0
|
225
|
my $self = shift; |
15
|
|
|
|
|
|
|
die $self->get_parse_error("no divider specified") |
16
|
144
|
50
|
|
|
|
213
|
if (not scalar @{$self->{parameter}}); |
|
144
|
|
|
|
|
377
|
|
17
|
144
|
|
|
|
|
271
|
$self->{divider} = $self->{parameter}->[0]; |
18
|
144
|
|
|
|
|
390
|
return $self; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#@Override |
22
|
|
|
|
|
|
|
sub filter |
23
|
|
|
|
|
|
|
{ |
24
|
144
|
|
|
144
|
0
|
292
|
my ($self, $filter_manager, $value, $context) = @_; |
25
|
|
|
|
|
|
|
|
26
|
144
|
|
|
|
|
376
|
my $divider = $self->{divider}->render($context); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
return ( |
29
|
144
|
100
|
100
|
|
|
1107
|
looks_like_number($value) |
30
|
|
|
|
|
|
|
and looks_like_number($divider) |
31
|
|
|
|
|
|
|
and $divider != 0 |
32
|
|
|
|
|
|
|
and not $value % $divider |
33
|
|
|
|
|
|
|
) ? 1 : 0; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |