line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Filter::Reverse; |
2
|
3
|
|
|
3
|
|
1120
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
70
|
|
3
|
3
|
|
|
3
|
|
14
|
use utf8; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
13
|
|
4
|
3
|
|
|
3
|
|
60
|
use warnings FATAL => 'all'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
78
|
|
5
|
3
|
|
|
3
|
|
49
|
use parent 'DTL::Fast::Filter'; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
14
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$DTL::Fast::FILTER_HANDLERS{reverse} = __PACKAGE__; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#@Overrde |
10
|
|
|
|
|
|
|
sub filter |
11
|
|
|
|
|
|
|
{ |
12
|
3
|
|
|
3
|
0
|
7
|
my ( $self, $filter_manager, $value, $context ) = @_; |
13
|
3
|
|
|
|
|
6
|
my $result; |
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
|
|
6
|
my $value_type = ref $value; |
16
|
|
|
|
|
|
|
|
17
|
3
|
100
|
|
|
|
13
|
if ($value_type eq 'ARRAY') |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
18
|
|
|
|
|
|
|
{ |
19
|
2
|
|
|
|
|
6
|
$result = [ reverse @$value ]; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
elsif ($value_type eq 'HASH') |
22
|
|
|
|
|
|
|
{ |
23
|
0
|
|
|
|
|
0
|
$result = { reverse % $value }; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
elsif (UNIVERSAL::can($value_type, 'reverse')) |
26
|
|
|
|
|
|
|
{ |
27
|
0
|
|
|
|
|
0
|
$result = $value->reverse($context); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
elsif (not $value_type) |
30
|
|
|
|
|
|
|
{ |
31
|
1
|
|
|
|
|
9
|
$result = join '', reverse ($value =~ /(.)/gs); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
else |
34
|
|
|
|
|
|
|
{ |
35
|
0
|
|
|
|
|
0
|
die $self->get_render_error( $context, "don't know how to reverse $value ($value_type)"); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
3
|
|
|
|
|
10
|
return $result; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |