line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Filter::Divisibleby; |
2
|
2
|
|
|
2
|
|
1238
|
use strict; use utf8; use warnings FATAL => 'all'; |
|
2
|
|
|
2
|
|
4
|
|
|
2
|
|
|
2
|
|
50
|
|
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
46
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
68
|
|
3
|
2
|
|
|
2
|
|
11
|
use parent 'DTL::Fast::Filter'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
13
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$DTL::Fast::FILTER_HANDLERS{'divisibleby'} = __PACKAGE__; |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
126
|
use Scalar::Util qw(looks_like_number); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
403
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#@Override |
10
|
|
|
|
|
|
|
sub parse_parameters |
11
|
|
|
|
|
|
|
{ |
12
|
144
|
|
|
144
|
0
|
206
|
my $self = shift; |
13
|
|
|
|
|
|
|
die $self->get_parse_error("no divider specified") |
14
|
144
|
50
|
|
|
|
165
|
if not scalar @{$self->{'parameter'}}; |
|
144
|
|
|
|
|
382
|
|
15
|
144
|
|
|
|
|
268
|
$self->{'divider'} = $self->{'parameter'}->[0]; |
16
|
144
|
|
|
|
|
435
|
return $self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#@Override |
20
|
|
|
|
|
|
|
sub filter |
21
|
|
|
|
|
|
|
{ |
22
|
144
|
|
|
144
|
0
|
238
|
my ($self, $filter_manager, $value, $context) = @_; |
23
|
|
|
|
|
|
|
|
24
|
144
|
|
|
|
|
398
|
my $divider = $self->{'divider'}->render($context); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
return ( |
27
|
144
|
100
|
100
|
|
|
1339
|
looks_like_number($value) |
28
|
|
|
|
|
|
|
and looks_like_number($divider) |
29
|
|
|
|
|
|
|
and $divider != 0 |
30
|
|
|
|
|
|
|
and not $value % $divider |
31
|
|
|
|
|
|
|
) ? 1: 0; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |