« blib/lib/DTL/Fast/Expression/Operator/Binary/Div.pm
↑ Summary
blib/lib/DTL/Fast/Tag/BlockSuper.pm »
| 1 | package DTL::Fast::Filter::Join; | ||||||||||||||||||||||||||||
| 2 | 8 | ▶ | 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 | 8 | ▶ | use parent 'DTL::Fast::Filter'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 8 | $DTL::Fast::FILTER_HANDLERS{'join'} = __PACKAGE__; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | #@Override | ||||||||||||||||||||||||||||
| 8 | sub parse_parameters | ||||||||||||||||||||||||||||
| 9 | { | ||||||||||||||||||||||||||||
| 10 | 39 | ▶ | my( $self ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
parse_parameters: called CC=3 SCAR=11.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | die $self->get_parse_error("no separator passed to the join filter") | ||||||||||||||||||||||||||||
| 13 | if( | ||||||||||||||||||||||||||||
| 14 | ref $self->{'parameter'} ne 'ARRAY' | ||||||||||||||||||||||||||||
| 15 | 39 | ▶ | or not scalar @{$self->{'parameter'}} | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $self->{"parameter"} ne "ARRAY" or not scalar @{$self->{"parameter"};}
MC/DC0%0/2
ref $self->{"parameter"} ne "ARRAY" or not scalar @{$self->{"parameter"};}
ref $self->{"parameter"} ne "ARRAY"
not scalar @{$self->{"parameter"};}
Truth table33%1/3
A or not(B)
A= ref $self->{"parameter"} ne "ARRAY"B= not scalar @{$self->{"parameter"};}
| |||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 39 | $self->{'sep'} = $self->{'parameter'}->[0]; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 39 | return $self; | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | #@Override | ||||||||||||||||||||||||||||
| 24 | sub filter | ||||||||||||||||||||||||||||
| 25 | { | ||||||||||||||||||||||||||||
| 26 | 34 | ▶ | my( $self, $filter_manager, $value, $context ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
filter: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 34 | my $value_type = ref $value; | |||||||||||||||||||||||||||
| 29 | 34 | my $result = undef; | |||||||||||||||||||||||||||
| 30 | 34 | my $separator = $self->{'sep'}->render($context, 1); | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 34 | my @source = (); | |||||||||||||||||||||||||||
| 33 | 34 | ▶ | if( $value_type eq 'HASH' ) | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 34 | { | ||||||||||||||||||||||||||||
| 35 | 1 | @source = (%$value); | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | elsif( $value_type eq 'ARRAY' ) | ||||||||||||||||||||||||||||
| 38 | { | ||||||||||||||||||||||||||||
| 39 | 32 | @source = @$value; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | else | ||||||||||||||||||||||||||||
| 42 | { | ||||||||||||||||||||||||||||
| 43 | 1 | ▶ | die $self->get_render_error( | ||||||||||||||||||||||||||
|
Condition50%1/2
$value_type || 'SCALAR'
MC/DC0%0/1
$value_type || 'SCALAR'
$value_type
Truth table50%1/2
A
A= $value_type
| |||||||||||||||||||||||||||||
| 44 | $context, | ||||||||||||||||||||||||||||
| 45 | sprintf( "Unable to apply join filter to the %s value" | ||||||||||||||||||||||||||||
| 46 | , $value_type || 'SCALAR' | ||||||||||||||||||||||||||||
| 47 | ) | ||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 33 | ▶ | if( $filter_manager->{'safeseq'} ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | { | ||||||||||||||||||||||||||||
| 53 | $separator = DTL::Fast::html_protect($separator) | ||||||||||||||||||||||||||||
| 54 | 2 | ▶ | if not $context->{'ns'}->[-1]->{'_dtl_safe'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 2 | $filter_manager->{'safe'} = 1; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 33 | return join $separator, @source; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 8 | 1; | |||||||||||||||||||||||||||