Geoffrey/Template.pm

filter: Statementstmt 100% 44 / 44 Branchbran 75.0% 6 / 8 Conditioncond 85.7% 6 / 7 MC/DCmcdc 100% 3 / 3 Subroutinesub 100% 10 / 10 Podpod 100% 4 / 4 totaltotal 96.0% 73 / 76 CC 10 SCAR 9.6
CC
10
Cov
95%
template
4.1
_handle_template
4.0
templates
2.0
CRAP 2.6
« 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.000206';
9  
10 9 ▶sub _handle_template {
Subroutine _handle_template: called CC=4 SCAR=13.9
11 9 my ( $self, $hr_template ) = @_;
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 8 ▶sub _merge_templates {
Subroutine _merge_templates: called CC=2 SCAR=6.9
24 8 my ( $self, $s_destination_template, $s_source_template ) = @_;
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 2 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
33 2 my $class = shift;
34 2 my $self = {@_};
35 2 $self->{templates} = {};
36 2 return bless $self, $class;
37 }
38  
39 45 ▶sub template {
Subroutine template: called CC=4 SCAR=14.2
Pod documented
40 45 my ( $self, $s_template_name, $hr_template_value ) = @_;
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 // [];
Condition75%3/4
$self->templates->{$s_template_name} //= $hr_template_value // []
l!l
378
$hr_template_value // []
l!l
08
MC/DC100%1/1
$self->templates->{$s_template_name} //= $hr_template_value // []
$self->templates->{$s_template_name}
Truth table100%2/2
A
A= $self->templates->{$s_template_name}
Aresult
11
00
43 45 return $self->templates->{$s_template_name};
44  
45 }
46  
47 90 ▶sub templates {
Subroutine templates: called CC=2 SCAR=7.1
Pod documented
48 90 my ( $self, $hr_templates ) = @_;
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 3 ▶sub load_templates {
Subroutine load_templates: called CC=2 SCAR=6.9
Pod documented
54 3 my ( $self, $ar_templates ) = @_;
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 »