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

filter: Statementstmt 100% 27 / 27 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 87.8% 36 / 41 SCAR 11.0
CC
3
Cov
94%
parse_parameters
2.0
normalize_text
2.0
BEGIN
1.0
CRAP 3.0
« blib/lib/DTL/Fast/Filter/Default.pm ↑ Summary blib/lib/DTL/Fast/Tag/Comment.pm »
1 package DTL::Fast::Filter::Urlizetrunc;
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::Urlize';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 $DTL::Fast::FILTER_HANDLERS{'urlizetrunc'} = __PACKAGE__;
6  
7 #@Override
8 sub parse_parameters
9 {
10 9 ▶ my $self = shift;
Subroutine parse_parameters: called CC=2 SCAR=7.0
Pod undocumented
11 die $self->get_parse_error("no max size specified")
12 9 ▶ if not scalar @{$self->{'parameter'}};
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @{$self->{"parameter"};} 0 9 9
13 9 $self->{'maxsize'} = $self->{'parameter'}->[0];
14 9 return $self;
15 }
16  
17 #@Override
18 sub filter
19 {
20 9 ▶ my($self, $filter_manager, $value, $context ) = @_;
Subroutine filter: called CC=1 SCAR=0.0
Pod undocumented
21
22 9 $self->{'size'} = $self->{'maxsize'}->render($context);
23 9 return $self->SUPER::filter($filter_manager, $value, $context);
24 }
25  
26 #@Override
27 sub normalize_text
28 {
29 10 ▶ my ($self, $text) = @_;
Subroutine normalize_text: called CC=2 SCAR=7.0
Pod undocumented
30
31 10 ▶ if( length $text > $self->{'size'} )
Branch: 1 branch
BranchTrueFalseTotal
if (length $text > $self->{"size"}) 10 0 10
32 {
33 10 $text = substr $text, 0, $self->{'size'};
34 10 $text =~ s/\s*$/.../s;
35 }
36
37 10 return $text;
38 }
39  
40 2 1;
« blib/lib/DTL/Fast/Filter/Default.pm ↑ Summary blib/lib/DTL/Fast/Tag/Comment.pm »