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

filter: Statementstmt 100% 32 / 32 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 2 totaltotal 93.7% 45 / 48 SCAR 13.9
CC
4
Cov
97%
parse_parameters
3.0
render
2.0
BEGIN
1.0
CRAP 4.0
« blib/lib/DTL/Fast/Tag/Ifequal.pm ↑ Summary blib/lib/DTL/Fast/Text.pm »
1 package DTL::Fast::Tag::Now;
2 3 ▶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 3 ▶use parent 'DTL::Fast::Tag::Simple';
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 $DTL::Fast::TAG_HANDLERS{'now'} = __PACKAGE__;
6  
7 3 ▶use DTL::Fast::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use DTL::Fast::Variable;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 #@Override
11 sub parse_parameters
12 {
13 5 ▶ my $self = shift;
Subroutine parse_parameters: called CC=3 SCAR=11.0
Pod undocumented
14
15 5 ▶ if(
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'parameter'} =~ /^ \s* (.+?) (?:\s+as\s+(.+)\s*)? $/six) { } 4 1 5
16 $self->{'parameter'} =~ /^
17 \s*
18 (.+?)
19 (?:\s+as\s+(.+)\s*)?
20 $/xsi
21 )
22 {
23 4 @{$self}{'format', 'target_variable'} = (
24 DTL::Fast::Variable->new( $1 )
25 , $2
26 );
27 }
28 else
29 {
30 1 ▶ die $self->get_parse_error("no time format specified") unless $self->{'parameter'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"parameter"} 1 0 1
31 }
32
33 4 return $self;
34 }
35  
36 #@Override
37 sub render
38 {
39 4 ▶ my ($self, $context) = @_;
Subroutine render: called CC=2 SCAR=6.9
Pod undocumented
40  
41 4 my $result = DTL::Fast::Utils::time2str_php( $self->{'format'}->render($context), time);
42  
43 4 ▶ if ( $self->{'target_variable'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"target_variable"}) 2 2 4
44 $context->set(
45 2 $self->{'target_variable'} => $result
46 );
47 2 $result = '';
48 }
49
50 4 return $result;
51 }
52  
53  
54 3 1;
« blib/lib/DTL/Fast/Tag/Ifequal.pm ↑ Summary blib/lib/DTL/Fast/Text.pm »