blib/lib/Template/Plugin/SafeInclude.pm

filter: Statementstmt 100% 29 / 29 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 100% 40 / 40 CC 3 SCAR 6.2
CC
3
Cov
100%
inc
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
↑ Summary
1 package Template::Plugin::SafeInclude;
2  
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use parent qw/Template::Plugin/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 our $VERSION = '0.02';
9  
10 4 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
11 4 my $class = shift;
12 4 my $context = shift;
13 4 my $args = shift;
14  
15 4 my $self = bless {}, $class;
16 4 $self->{_context} = $context;
17 4 $self->{_verbose} = $args->{verbose};
18  
19 4 return $self;
20 }
21  
22 4 ▶sub inc {
Subroutine inc: called CC=3 SCAR=11.0
Pod documented
23 4 my $self = shift;
24 4 my $path = shift;
25 4 my $param = shift;
26
27 4 my $html = "";
28 4 eval {
29 4 $html = $self->{_context}->include($path, $param);
30 };
31 4 ▶ unless ($@) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($@) 2 2 4
32 2 return $html;
33 }
34 2 ▶ if ($self->{_verbose}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_verbose"}) 1 1 2
35 1 my $ret = sprintf "<!-- %s -->", $@;
36 1 return $ret;
37 }
38 }
39  
40 3 1; # Magic true value required at end of module
41 __END__
↑ Summary