Geoffrey/Template.pm

filter: Statementstmt 100% 44 / 44 Branchbran 75.0% 6 / 8 Conditioncond 75.0% 6 / 8 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 10 / 10 Podpod 100% 4 / 4 totaltotal 92.3% 72 / 78 CC 10 SCAR 9.7
CC
10
Cov
93%
template
4.3
_handle_template
4.0
templates
2.0
CRAP 2.7
« Geoffrey/Converter/SQLite/Index.pm ↑ Summary Geoffrey/Exception/General.pm »
1 package Geoffrey::Template;
2  
3 4 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use 5.016;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 $Geoffrey::Template::VERSION = '0.000204';
9  
10 sub _handle_template {
11 9 ▶ my ( $self, $hr_template ) = @_;
Subroutine _handle_template: called CC=4 SCAR=13.9
12 9 ▶ if ( $hr_template->{template}
Branch: 1 branch
BranchTrueFalseTotal
if ($hr_template->{"template"} and scalar @{$self->template($hr_template->{"template"});} == 0) 1 8 9
Condition100%3/3
$hr_template->{"template"} and scalar @{$self->template($hr_template->{"template"});} == 0
!ll&&!rl&&r
351
MC/DC100%2/2
$hr_template->{"template"} and scalar @{$self->template($hr_template->{"template"});} == 0
$hr_template->{"template"} scalar @{$self->template($hr_template->{"template"});} == 0
Truth table100%3/3
A and B
A= $hr_template->{"template"}B= scalar @{$self->template($hr_template->{"template"});} == 0
ABresult
0X0
100
111
13 6 && scalar @{ $self->template( $hr_template->{template} ) } == 0 )
14 {
15 1 require Geoffrey::Exception::Template;
16 1 Geoffrey::Exception::Template::throw_template_not_found( $hr_template->{template} );
17 }
18 8 $self->_merge_templates( $hr_template->{name}, $hr_template->{template} );
19 8 push @{ $self->template( $hr_template->{name} ) }, $_ for @{ $hr_template->{columns} };
20 8 return 1;
21 }
22  
23 sub _merge_templates {
24 8 ▶ my ( $self, $s_destination_template, $s_source_template ) = @_;
Subroutine _merge_templates: called CC=2 SCAR=6.9
25 8 ▶ return if !$s_source_template;
Branch: 1 branch
BranchTrueFalseTotal
unless $s_source_template 3 5 8
26 push
27 5 @{ $self->template($s_destination_template) },
28 5 @{ $self->template($s_source_template) };
29 5 return 1;
30 }
31  
32 sub new {
33 2 ▶ my $class = shift;
Subroutine new: called CC=1 SCAR=0.0
Pod documented
34 2 my $self = {@_};
35 2 $self->{templates} = {};
36 2 return bless $self, $class;
37 }
38  
39 sub template {
40 45 ▶ my ( $self, $s_template_name, $hr_template_value ) = @_;
Subroutine template: called CC=4 SCAR=14.6
Pod documented
41 45 ▶ return unless $s_template_name;
Branch: 1 branch
BranchTrueFalseTotal
unless $s_template_name 0 45 45
42 45 ▶ $self->templates->{$s_template_name} //= $hr_template_value // [];
Condition60%3/5
$self->templates->{$s_template_name} //= $hr_template_value // []
l!l&&r!l&&!r
3780
$hr_template_value // []
l!l
08
MC/DC0%0/2
$self->templates->{$s_template_name} //= $hr_template_value // []
$self->templates->{$s_template_name} $hr_template_value
Truth table33%1/3
A //= B
A= $self->templates->{$s_template_name}B= $hr_template_value
ABresult
1X1
011
000
43 45 return $self->templates->{$s_template_name};
44  
45 }
46  
47 sub templates {
48 90 ▶ my ( $self, $hr_templates ) = @_;
Subroutine templates: called CC=2 SCAR=7.1
Pod documented
49 90 ▶ $self->{templates} = $hr_templates if $hr_templates;
Branch: 1 branch
BranchTrueFalseTotal
if $hr_templates 0 90 90
50 90 return $self->{templates};
51 }
52  
53 sub load_templates {
54 3 ▶ my ( $self, $ar_templates ) = @_;
Subroutine load_templates: called CC=2 SCAR=6.9
Pod documented
55 3 $self->_handle_template($_) foreach @{$ar_templates};
56 2 return $self;
57 }
58  
59 4 1;
60  
61 __END__
« Geoffrey/Converter/SQLite/Index.pm ↑ Summary Geoffrey/Exception/General.pm »