ButtonMaker/ClassContainer.pm

filter: Statementstmt 28.5% 10 / 35 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 28.5% 2 / 7 Podpod 0.0% 0 / 5 totaltotal 21.4% 12 / 56 CC 4 SCAR 17.2
CC
4
Cov
24%
add_class
12.0
new
6.0
lookup_class
2.0
CRAP 5.6
« ButtonMaker/Lexicon.pm ↑ Summary ButtonMaker/TemplateCanvas.pm »
1 package Image::ButtonMaker::ClassContainer;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Image::ButtonMaker::ButtonClass;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 #### Default values for class container
6 1 my @defaults = (
7 classes => undef,
8 error => 0,
9 errorstr => undef,
10 );
11  
12 1 our $error;
13 1 our $errorstr;
14  
15  
16 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
17 0 my $invocant = shift;
18 0 ▶ my $class = ref($invocant) || $invocant;
Condition0%0/3
ref $invocant || $invocant
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $invocant || $invocant
ref $invocant $invocant
Truth table0%0/3
A || B
A= ref $invocantB= $invocant
ABresult
1X1
011
000
19 0 my $object = { @defaults };
20  
21 0 bless $object, $invocant;
22 0 return $object;
23 }
24  
25 0 ▶sub lookup_class {
Subroutine lookup_class: not called CC=1 SCAR=6.9
Pod undocumented
26 0 my $self = shift;
27 0 my $name = shift;
28 0 return $self->{classes}{$name};
29 };
30  
31  
32 0 ▶sub add_class {
Subroutine add_class: not called CC=3 SCAR=24.8
Pod undocumented
33 0 my $self = shift;
34 0 my $class_obj = shift;
35  
36 0 my $name = $class_obj->lookup_name;
37 0 my $parent = $class_obj->lookup_parent;
38  
39 #### Can not add class to container if parent is not there
40 0 ▶ if(length($parent)) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $parent) 0 0 0
41 0 ▶ return $self->set_error(1000, "Parent '$parent' for class '$name' not found")
Branch: 1 branch
BranchTrueFalseTotal
unless $self->lookup_class($parent) 0 0 0
42 unless($self->lookup_class($parent));
43 }
44  
45 0 $self->{classes}{$name} = $class_obj;
46 0 $class_obj->set_container($self);
47 0 return 1;
48 }
49  
50  
51 0 ▶sub reset_error {
Subroutine reset_error: not called CC=1 SCAR=6.9
Pod undocumented
52 0 my $self = shift;
53 0 $self->{error} = 0;
54 0 $self->{errorstr} = '';
55 0 return;
56 }
57  
58 0 ▶sub set_error {
Subroutine set_error: not called CC=1 SCAR=6.9
Pod undocumented
59 0 my $self = shift;
60 0 $self->{error} = shift;
61 0 $self->{errorstr} = shift;
62 0 return shift;
63 }
64  
65 1 1;
« ButtonMaker/Lexicon.pm ↑ Summary ButtonMaker/TemplateCanvas.pm »