blib/lib/DTL/Fast/Tag/If.pm

filter: Statementstmt 100% 46 / 46 Branchbran 100% 6 / 6 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 6 totaltotal 91.8% 68 / 74 SCAR 17.9
CC
6
Cov
100%
parse_tag_chunk
4.0
render
3.0
BEGIN
1.0
CRAP 6.0
« blib/lib/DTL/Fast/Cache/Memcached.pm ↑ Summary blib/lib/DTL/Fast/Filter/Truncatewords.pm »
1 package DTL::Fast::Tag::If;
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::Tag';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 8 $DTL::Fast::TAG_HANDLERS{'if'} = __PACKAGE__;
6  
7 8 ▶use DTL::Fast::Tag::If::Condition;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 #@Override
10 757 ▶sub get_close_tag{ return 'endif';}
Subroutine get_close_tag: called CC=1 SCAR=0.0
Pod undocumented
11  
12 #@Override
13 sub parse_parameters
14 {
15 531 ▶ my( $self ) = @_;
Subroutine parse_parameters: called CC=1 SCAR=0.0
Pod undocumented
16  
17 531 $self->{'conditions'} = [];
18 531 $self->add_condition($self->{'parameter'});
19
20 526 return $self;
21 }
22  
23 #@Override
24 sub add_chunk
25 {
26 3448 ▶ my( $self, $chunk ) = @_;
Subroutine add_chunk: called CC=1 SCAR=0.0
Pod undocumented
27
28 3448 $self->{'conditions'}->[-1]->add_chunk($chunk);
29 3448 return $self;
30 }
31  
32 #@Override
33 sub parse_tag_chunk
34 {
35 1683 ▶ my( $self, $tag_name, $tag_param, $chunk_lines ) = @_;
Subroutine parse_tag_chunk: called CC=4 SCAR=13.9
Pod undocumented
36
37 1683 my $result = undef;
38  
39 1683 ▶ if( $tag_name eq 'elif' or $tag_name eq 'elsif' )
Branch: 2 branches
BranchTrueFalseTotal
if ($tag_name eq 'elif' or $tag_name eq 'elsif') { } 420 1263 1683
elsif ($tag_name eq 'else') { } 474 789 1263
Condition100%3/3
$tag_name eq "elif" or $tag_name eq "elsif"
l!l&&r!l&&!r
1053151263
MC/DC100%2/2
$tag_name eq "elif" or $tag_name eq "elsif"
$tag_name eq "elif" $tag_name eq "elsif"
Truth table100%3/3
A or B
A= $tag_name eq "elif"B= $tag_name eq "elsif"
ABresult
1X1
011
000
40 {
41 420 $self->add_condition($tag_param);
42 420 $DTL::Fast::Template::CURRENT_TEMPLATE_LINE += $chunk_lines;
43 }
44 elsif( $tag_name eq 'else' )
45 {
46 474 $self->add_condition(1);
47 474 $DTL::Fast::Template::CURRENT_TEMPLATE_LINE += $chunk_lines;
48 }
49 else
50 {
51 789 $result = $self->SUPER::parse_tag_chunk($tag_name, $tag_param, $chunk_lines);
52 }
53
54 1667 return $result;
55 }
56  
57 #@Override
58 sub render
59 {
60 1786 ▶ my( $self, $context ) = @_;
Subroutine render: called CC=3 SCAR=11.0
Pod undocumented
61
62 1786 my $result = '';
63
64 1786 foreach my $condition (@{$self->{'conditions'}})
65 {
66 2742 ▶ if( $condition->is_true($context) )
Branch: 1 branch
BranchTrueFalseTotal
if ($condition->is_true($context)) 1774 965 2739
67 {
68 1774 $result = $condition->render($context);
69 1770 last;
70 }
71 }
72 1779 return $result;
73 }
74  
75 sub add_condition
76 {
77 1425 ▶ my( $self, $condition ) = @_;
Subroutine add_condition: called CC=1 SCAR=0.0
Pod undocumented
78 1425 push @{$self->{'conditions'}}, DTL::Fast::Tag::If::Condition->new($condition);
79 1420 return $self;
80 }
81  
82 8 1;
« blib/lib/DTL/Fast/Cache/Memcached.pm ↑ Summary blib/lib/DTL/Fast/Filter/Truncatewords.pm »