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

filter: Statementstmt 94.1% 32 / 34 Branchbran 66.6% 4 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 82.6% 43 / 52 SCAR 16.2
CC
5
Cov
86%
parse_parameters
5.0
render
2.0
BEGIN
1.0
CRAP 5.1
« blib/lib/DTL/Fast/Tag/Include.pm ↑ Summary blib/lib/DTL/Fast/Renderer.pm »
1 package DTL::Fast::Tag::Widthratio;
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::Tag::Simple';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 $DTL::Fast::TAG_HANDLERS{'widthratio'} = __PACKAGE__;
6  
7 2 ▶use DTL::Fast::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 #@Override
10 sub parse_parameters
11 {
12 3 ▶ my $self = shift;
Subroutine parse_parameters: called CC=4 SCAR=16.1
Pod undocumented
13  
14 3 ▶ if( $self->{'parameter'} =~ /^\s*(.+?)(?:\s+as\s+([^\s]+))?\s*$/s )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'parameter'} =~ /^\s*(.+?)(?:\s+as\s+([^\s]+))?\s*$/s) { } 3 0 3
15 {
16 3 $self->{'target_name'} = $2;
17
18 3 $self->{'sources'} = $self->parse_sources($1);
19
20 die $self->get_parse_error(
21 sprintf(
22 "Three arguments should be passed to widthratio: %s %s"
23 , $self->{'parameter'} // 'undef'
24 0 , scalar @{$self->{'sources'}}
25 )
26 3 ▶ ) if scalar @{$self->{'sources'}} != 3;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$self->{"sources"};} != 3 0 3 3
Condition0%0/2
$self->{"parameter"} // "undef"
l!l
00
MC/DC0%0/1
$self->{"parameter"} // "undef"
$self->{"parameter"}
Truth table0%0/2
A
A= $self->{"parameter"}
Aresult
11
00
27 }
28 else
29 {
30 0 die die $self->get_parse_error("Unable to parse ratio parameters $self->{'parameter'}");
31 }
32
33 3 return $self;
34 }
35  
36 #@Override
37 sub render
38 {
39 3 ▶ my $self = shift;
Subroutine render: called CC=2 SCAR=6.9
Pod undocumented
40 3 my $context = shift;
41  
42 3 my $sources = $self->{'sources'};
43 3 my $result = int(
44 $sources->[0]->render($context)
45 / $sources->[1]->render($context)
46 * $sources->[2]->render($context)
47 );
48
49 3 ▶ if( $self->{'target_name'} )
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"target_name"}) 1 2 3
50 {
51 1 $context->set($self->{'target_name'} => $result);
52 1 $result = '';
53 }
54
55 3 return $result;
56 }
57  
58 2 1;
« blib/lib/DTL/Fast/Tag/Include.pm ↑ Summary blib/lib/DTL/Fast/Renderer.pm »