OOP/_getArgs.pm

filter: Statementstmt 93.7% 164 / 175 Branchbran 80.5% 87 / 108 Conditioncond 61.9% 83 / 134 MC/DCmcdc 32.0% 24 / 75 Subroutinesub 92.3% 12 / 13 Podpod n/a totaltotal 73.2% 370 / 505 CC 103 SCAR 35.1
CC
103
Cov
80%
_checkAttributes
51.2
STORE
38.6
_checkParameter
27.8
CRAP 33.6
↑ Summary OOP.pm »
1 package OOP::_getArgs;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 0 ▶sub EXISTS {
Subroutine EXISTS: not called CC=1 SCAR=6.9
7  
8 0 my ($self,$key) = @_;
9  
10 0 my $value = $self->{ARGS};
11
12 0 return (exists $value->{$key});
13  
14 }
15 63 ▶sub TIEHASH {
Subroutine TIEHASH: called CC=3 SCAR=11.2
16  
17 63 my ($class, $ARGS) = @_;
18  
19 63 $ARGS->{_INDEX} = {};
20
21 63 ▶ my $arguments = $ARGS->{ARGS} || croak "No arguments were passed to the prototype!";
Condition50%1/2
$ARGS->{'ARGS'} || croak('No arguments were passed to the prototype!')
l!l
630
MC/DC0%0/1
$ARGS->{'ARGS'} || croak('No arguments were passed to the prototype!')
$ARGS->{'ARGS'}
Truth table50%1/2
A
A= $ARGS->{'ARGS'}
Aresult
11
00
22 63 ▶ my $prototype = $ARGS->{PROTOTYPE} || croak "No prototype was passed to the prototype!";
Condition50%1/2
$ARGS->{'PROTOTYPE'} || croak('No prototype was passed to the prototype!')
l!l
630
MC/DC0%0/1
$ARGS->{'PROTOTYPE'} || croak('No prototype was passed to the prototype!')
$ARGS->{'PROTOTYPE'}
Truth table50%1/2
A
A= $ARGS->{'PROTOTYPE'}
Aresult
11
00
23  
24 63 my $self = $ARGS;
25  
26 63 return bless $self, $class;
27
28 }
29 21 ▶sub STORE {
Subroutine STORE: called CC=33 SCAR=36.5
30  
31 21 my ($self, $key, $val) = @_;
32  
33 21 my $value = $self->{ARGS};
34 21 my $myProto = $self->{PROTOTYPE};
35  
36 21 ▶ my $_mainobj = $self->{_MAIN} || $self;
Condition66%2/3
$self->{'_MAIN'} || $self
l!l&&r!l&&!r
2010
MC/DC0%0/2
$self->{'_MAIN'} || $self
$self->{'_MAIN'} $self
Truth table66%2/3
A || B
A= $self->{'_MAIN'}B= $self
ABresult
1X1
011
000
37  
38 21 my $_parent = $_mainobj->{_INDEX}->{$value}->{parent};
39 21 my $_parentkey = $_mainobj->{_INDEX}->{$value}->{parentkey};
40 21 my $_parentPrototype = $_parent->{proto}->{$_parentkey};
41  
42 21 my $_currPrototype;
43  
44 21 ▶ if (exists($value->{$key}) &&
Branch: 2 branches
BranchTrueFalseTotal
if (exists $value->{$key} and exists $myProto->{$key} and ref $myProto->{$key} eq 'HASH' and ref $_parentPrototype eq 'HASH' and not exists $myProto->{$key}{'dataType'}) { } 2 19 21
elsif (ref $myProto->{$key} eq 'HASH' and exists $myProto->{$key}{'dataType'}) { } 8 11 19
Condition100%12/12
exists $value->{$key} and exists $myProto->{$key} and ref $myProto->{$key} eq "HASH" and ref $_parentPrototype eq "HASH" and not exists $myProto->{$key}{"dataType"}
!ll&&!rl&&r
1542
exists $value->{$key} and exists $myProto->{$key} and ref $myProto->{$key} eq "HASH" and ref $_parentPrototype eq "HASH"
!ll&&!rl&&r
1236
exists $value->{$key} and exists $myProto->{$key} and ref $myProto->{$key} eq "HASH"
!ll&&!rl&&r
939
exists $value->{$key} and exists $myProto->{$key}
!ll&&!rl&&r
8112
MC/DC100%5/5
exists $value->{$key} and exists $myProto->{$key} and ref $myProto->{$key} eq "HASH" and ref $_parentPrototype eq "HASH" and not exists $myProto->{$key}{"dataType"}
exists $value->{$key} exists $myProto->{$key} ref $myProto->{$key} eq "HASH" ref $_parentPrototype eq "HASH" not exists $myProto->{$key}{"dataType"}
Truth table100%6/6
A and B and C and D and not(E)
A= exists $value->{$key}B= exists $myProto->{$key}C= ref $myProto->{$key} eq "HASH"D= ref $_parentPrototype eq "HASH"E= not exists $myProto->{$key}{"dataType"}
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
45 exists($myProto->{$key}) &&
46 ref $myProto->{$key} eq 'HASH' &&
47 ref $_parentPrototype eq 'HASH' &&
48 !exists($myProto->{$key}->{dataType})
49 )
50 {
51 2 $_currPrototype = $_parentPrototype;
52 }
53 ▶ elsif ((ref $myProto->{$key} eq 'HASH') && exists($myProto->{$key}->{dataType}))
Condition100%3/3
ref $myProto->{$key} eq "HASH" and exists $myProto->{$key}{"dataType"}
!ll&&!rl&&r
1018
MC/DC100%2/2
ref $myProto->{$key} eq "HASH" and exists $myProto->{$key}{"dataType"}
ref $myProto->{$key} eq "HASH" exists $myProto->{$key}{"dataType"}
Truth table100%3/3
A and B
A= ref $myProto->{$key} eq "HASH"B= exists $myProto->{$key}{"dataType"}
ABresult
0X0
100
111
54 {
55 8 $_currPrototype = $myProto->{$key};
56 }
57 else
58 {
59 11 my $protoVal = $myProto->{$key};
60 11 ▶ my $dataType = exists($myProto->{$key}) ? ($myProto->{$key} ne '' ? ref($myProto->{$key}) : 'scalar') : (ref $val || 'scalar');
Branch: 2 branches
BranchTrueFalseTotal
exists $myProto->{$key} ? : 4 7 11
$myProto->{$key} ne '' ? : 2 2 4
Condition100%2/2
ref $val or "scalar"
l!l
25
MC/DC100%1/1
ref $val or "scalar"
ref $val
Truth table100%2/2
A
A= ref $val
Aresult
11
00
61 0 ▶ if ((ref $myProto->{$key} eq 'ARRAY') && (scalar @{$myProto->{$key}} == 0))
Branch: 3 branches
BranchTrueFalseTotal
if (ref $myProto->{$key} eq 'ARRAY' and scalar @{$myProto->{$key};} == 0) { } 0 11 11
elsif (ref $myProto->{$key} eq 'HASH' and scalar %{$myProto->{$key};} == 0) { } 1 10 11
elsif (ref $myProto->{$key} eq '' and scalar $myProto->{$key} <= 0) { } 9 1 10
Condition33%1/3
ref $myProto->{$key} eq "ARRAY" and scalar @{$myProto->{$key};} == 0
!ll&&!rl&&r
1100
MC/DC0%0/2
ref $myProto->{$key} eq "ARRAY" and scalar @{$myProto->{$key};} == 0
ref $myProto->{$key} eq "ARRAY" scalar @{$myProto->{$key};} == 0
Truth table33%1/3
A and B
A= ref $myProto->{$key} eq "ARRAY"B= scalar @{$myProto->{$key};} == 0
ABresult
0X0
100
111
62 {
63 0 $protoVal = '';
64 }
65 1 ▶ elsif((ref $myProto->{$key} eq 'HASH') && (scalar %{$myProto->{$key}} == 0))
Condition66%2/3
ref $myProto->{$key} eq "HASH" and scalar %{$myProto->{$key};} == 0
!ll&&!rl&&r
1001
MC/DC50%1/2
ref $myProto->{$key} eq "HASH" and scalar %{$myProto->{$key};} == 0
ref $myProto->{$key} eq "HASH" scalar %{$myProto->{$key};} == 0
Truth table66%2/3
A and B
A= ref $myProto->{$key} eq "HASH"B= scalar %{$myProto->{$key};} == 0
ABresult
0X0
100
111
66 {
67 1 $protoVal = '';
68 }
69 ▶ elsif ((ref $myProto->{$key} eq '') && (scalar $myProto->{$key} <= 0))
Condition66%2/3
ref $myProto->{$key} eq "" and scalar $myProto->{$key} <= 0
!ll&&!rl&&r
019
MC/DC50%1/2
ref $myProto->{$key} eq "" and scalar $myProto->{$key} <= 0
ref $myProto->{$key} eq "" scalar $myProto->{$key} <= 0
Truth table66%2/3
A and B
A= ref $myProto->{$key} eq ""B= scalar $myProto->{$key} <= 0
ABresult
0X0
100
111
70 {
71 9 $protoVal = '';
72 }
73 11 $_currPrototype->{dataType} = $dataType;
74 11 ▶ $_currPrototype->{writeAccess} = $protoVal eq '' ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$protoVal eq '' ? : 10 1 11
75 11 $_currPrototype->{readAccess} = 1;
76 11 ▶ $_currPrototype->{allowEmpty} = $protoVal ne '' ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$protoVal ne '' ? : 1 10 11
77 11 $_currPrototype->{locked} = 0;
78 11 $_currPrototype->{required} = 1;
79 11 ▶ $_currPrototype->{minLength} = $_currPrototype->{maxLength} = length($protoVal) if $protoVal ne '' ;
Branch: 1 branch
BranchTrueFalseTotal
if $protoVal ne "" 1 10 11
80 11 $_currPrototype->{value} = $myProto->{$key};
81 }
82
83 21 ▶ if (uc($_currPrototype->{dataType}) eq 'HASH')
Branch: 1 branch
BranchTrueFalseTotal
if (uc $_currPrototype->{'dataType'} eq 'HASH') { } 5 16 21
84 {
85 ! (exists($_currPrototype->{writeAccess}) && ($_currPrototype->{writeAccess} <= 0)) ||
86 5 ▶ ( exists($value->{$key}) || croak "'$key' is an invalid key according to constructor!" );
Branch: 1 branch
BranchTrueFalseTotal
(exists $_currPrototype->{"writeAccess"} and $_currPrototype->{"writeAccess"} <= 0) and exists $value->{$key} || croak("'${key}' is an invalid key according to constructor!") 0 5 5
Condition28%2/7
(exists $_currPrototype->{'writeAccess'} && $_currPrototype->{'writeAccess'} <= 0) && (exists $value->{$key} || croak("'${key}' is an invalid key according to constructor!"))
!ll
50
exists $_currPrototype->{"writeAccess"} and $_currPrototype->{"writeAccess"} <= 0
!ll&&!rl&&r
050
exists $value->{$key} or croak("'${key}' is an invalid key according to constructor!")
l!l
00
MC/DC0%0/3
(exists $_currPrototype->{'writeAccess'} && $_currPrototype->{'writeAccess'} <= 0) && (exists $value->{$key} || croak("'${key}' is an invalid key according to constructor!"))
exists $_currPrototype->{"writeAccess"} $_currPrototype->{"writeAccess"} <= 0 exists $value->{$key}
Truth table25%1/4
A and B && C
A= exists $_currPrototype->{"writeAccess"}B= $_currPrototype->{"writeAccess"} <= 0C= exists $value->{$key}
ABCresult
0XX0
10X0
1100
1111
87  
88 5 ▶ ref $val eq 'HASH' || croak "Attempt to pass improper data type to '$key'!";
Branch: 1 branch
BranchTrueFalseTotal
ref $val eq "HASH" or croak("Attempt to pass improper data type to '${key}'!") 1 4 5
89 }
90 else
91 {
92 !(exists($_currPrototype->{writeAccess}) &&
93 16 ▶ ($_currPrototype->{writeAccess} == 0)) ||
Branch: 1 branch
BranchTrueFalseTotal
(exists $_currPrototype->{"writeAccess"} and $_currPrototype->{"writeAccess"} == 0) and croak("'${key}' is read-only according to constructor!") 2 14 16
Condition66%2/3
exists $_currPrototype->{"writeAccess"} and $_currPrototype->{"writeAccess"} == 0
!ll&&!rl&&r
0142
MC/DC50%1/2
exists $_currPrototype->{"writeAccess"} and $_currPrototype->{"writeAccess"} == 0
exists $_currPrototype->{"writeAccess"} $_currPrototype->{"writeAccess"} == 0
Truth table66%2/3
A and B
A= exists $_currPrototype->{"writeAccess"}B= $_currPrototype->{"writeAccess"} == 0
ABresult
0X0
100
111
94 croak "'$key' is read-only according to constructor!";
95  
96 !(exists($_currPrototype->{writeAccess}) &&
97 ($_currPrototype->{writeAccess} == -1) &&
98 14 ▶ (exists($value->{$key}))) ||
Branch: 1 branch
BranchTrueFalseTotal
(exists $_currPrototype->{"writeAccess"} and $_currPrototype->{"writeAccess"} == -1 and exists $value->{$key}) and croak("'${key}' is read-only according to constructor!") 0 14 14
Condition33%2/6
exists $_currPrototype->{"writeAccess"} and $_currPrototype->{"writeAccess"} == -1 and exists $value->{$key}
!ll&&!rl&&r
1400
exists $_currPrototype->{"writeAccess"} and $_currPrototype->{"writeAccess"} == -1
!ll&&!rl&&r
0140
MC/DC0%0/3
exists $_currPrototype->{"writeAccess"} and $_currPrototype->{"writeAccess"} == -1 and exists $value->{$key}
exists $_currPrototype->{"writeAccess"} $_currPrototype->{"writeAccess"} == -1 exists $value->{$key}
Truth table25%1/4
A and B and C
A= exists $_currPrototype->{"writeAccess"}B= $_currPrototype->{"writeAccess"} == -1C= exists $value->{$key}
ABCresult
0XX0
10X0
1100
1111
99 croak "'$key' is read-only according to constructor!";
100
101 14 ▶ my $valType = ref($val) || 'scalar';
Condition100%2/2
ref $val || 'scalar'
l!l
59
MC/DC100%1/1
ref $val || 'scalar'
ref $val
Truth table100%2/2
A
A= ref $val
Aresult
11
00
102 14 $valType = uc($valType);
103
104 14 ▶ uc($_currPrototype->{dataType}) eq $valType || croak "Attempt to pass improper data type to '$key'!";
Branch: 1 branch
BranchTrueFalseTotal
uc $_currPrototype->{"dataType"} eq $valType or croak("Attempt to pass improper data type to '${key}'!") 11 3 14
105 }
106  
107 12 $self->_checkArgs({
108 key => $key,
109 action => 'store',
110 value => $val,
111 argsRef => $value,
112 hashRef => $myProto
113 });
114  
115 8 $value->{$key} = $val;
116
117 }
118 4 ▶sub DELETE {
Subroutine DELETE: called CC=5 SCAR=16.2
119  
120 4 my ($self, $key) = @_;
121  
122 4 my $value = $self->{ARGS};
123
124 4 ▶ return unless exists $value->{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $value->{$key} 1 3 4
125
126 3 my $myProto = $self->{PROTOTYPE};
127 3 my $_currPrototype = $myProto->{$key};
128
129 ref $_currPrototype eq 'HASH' && exists($_currPrototype->{locked}) && ($_currPrototype->{locked} == 1) ?
130 croak "'$key' may not be removed according to constructor!" :
131 3 ▶ delete $value->{$key};
Branch: 1 branch
BranchTrueFalseTotal
ref $_currPrototype eq 'HASH' && exists $_currPrototype->{'locked'} && $_currPrototype->{'locked'} == 1 ? : 2 1 3
Condition66%4/6
ref $_currPrototype eq "HASH" and exists $_currPrototype->{"locked"} and $_currPrototype->{"locked"} == 1
!ll&&!rl&&r
102
ref $_currPrototype eq "HASH" and exists $_currPrototype->{"locked"}
!ll&&!rl&&r
102
MC/DC33%1/3
ref $_currPrototype eq "HASH" and exists $_currPrototype->{"locked"} and $_currPrototype->{"locked"} == 1
ref $_currPrototype eq "HASH" exists $_currPrototype->{"locked"} $_currPrototype->{"locked"} == 1
Truth table50%2/4
A and B and C
A= ref $_currPrototype eq "HASH"B= exists $_currPrototype->{"locked"}C= $_currPrototype->{"locked"} == 1
ABCresult
0XX0
10X0
1100
1111
132
133 }
134  
135 1 ▶sub CLEAR {
Subroutine CLEAR: called CC=3 SCAR=11.7
136  
137 1 my $self = shift;
138  
139 1 ▶ my $_mainobj = $self->{_MAIN} || $self;
Condition33%1/3
$self->{'_MAIN'} || $self
l!l&&r!l&&!r
010
MC/DC0%0/2
$self->{'_MAIN'} || $self
$self->{'_MAIN'} $self
Truth table33%1/3
A || B
A= $self->{'_MAIN'}B= $self
ABresult
1X1
011
000
140  
141 1 $self->{ARGS}->{$_} = undef foreach keys %{$self->{ARGS}};
142
143 }
144 65 ▶sub FETCH {
Subroutine FETCH: called CC=7 SCAR=19.5
145  
146 65 my ($self, $key) = @_;
147  
148 65 ▶ my $_mainobj = $self->{_MAIN} || $self;
Condition66%2/3
$self->{'_MAIN'} || $self
l!l&&r!l&&!r
34310
MC/DC0%0/2
$self->{'_MAIN'} || $self
$self->{'_MAIN'} $self
Truth table66%2/3
A || B
A= $self->{'_MAIN'}B= $self
ABresult
1X1
011
000
149 65 my $_parent = $self->{PARENT};
150 65 my $_parentkey = $self->{PARENTKEY};
151 65 my $value = $self->{ARGS};
152 65 my $myProto = $self->{PROTOTYPE};
153  
154 65 $self->_checkArgs({
155 key => $key,
156 action => 'fetch',
157 argsRef => $value,
158 hashRef => $myProto
159 });
160  
161 63 ▶ if (ref $myProto eq 'HASH')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $myProto eq "HASH") 63 0 63
162 {
163 my $protoType = ((ref $myProto->{$key} eq 'HASH') &&
164 (exists($myProto->{$key}->{dataType})) &&
165 (uc($myProto->{$key}->{dataType}) eq 'HASH')) ?
166 $myProto->{$key}->{value}:
167 63 ▶ $myProto->{$key};
Branch: 1 branch
BranchTrueFalseTotal
ref $myProto->{$key} eq 'HASH' && exists $myProto->{$key}{'dataType'} && uc $myProto->{$key}{'dataType'} eq 'HASH' ? : 27 36 63
Condition83%5/6
ref $myProto->{$key} eq "HASH" and exists $myProto->{$key}{"dataType"} and uc $myProto->{$key}{"dataType"} eq "HASH"
!ll&&!rl&&r
36027
ref $myProto->{$key} eq "HASH" and exists $myProto->{$key}{"dataType"}
!ll&&!rl&&r
43227
MC/DC66%2/3
ref $myProto->{$key} eq "HASH" and exists $myProto->{$key}{"dataType"} and uc $myProto->{$key}{"dataType"} eq "HASH"
ref $myProto->{$key} eq "HASH" exists $myProto->{$key}{"dataType"} uc $myProto->{$key}{"dataType"} eq "HASH"
Truth table75%3/4
A and B and C
A= ref $myProto->{$key} eq "HASH"B= exists $myProto->{$key}{"dataType"}C= uc $myProto->{$key}{"dataType"} eq "HASH"
ABCresult
0XX0
10X0
1100
1111
168  
169 63 $_mainobj->{_INDEX}->{$value} = {
170 parent => $_parent,
171 parentkey => $_parentkey
172 };
173
174 63 ▶ if (ref($value->{$key}) eq 'HASH')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value->{$key} eq "HASH") 59 4 63
175 {
176 my $obj = tie(my %test, 'OOP::_getArgs', {
177 _MAIN => $_mainobj,
178 PARENT => {
179 args => $value,
180 proto => $myProto
181 },
182 PARENTKEY => $key,
183 59 ARGS => $value->{$key},
184 PROTOTYPE => $protoType
185 });
186
187 59 return (\%test);
188 }
189 }
190
191 4 return $value->{$key};
192  
193 }
194  
195 2 ▶sub FIRSTKEY {
Subroutine FIRSTKEY: called CC=1 SCAR=0.0
196  
197 2 my ($self) = @_;
198  
199 2 my $temp = keys %{$self->{ARGS}};
200  
201 2 return scalar each %{$self->{ARGS}};
202
203 }
204  
205 2 ▶sub NEXTKEY {
Subroutine NEXTKEY: called CC=1 SCAR=0.0
206
207 2 my ($self) = @_;
208
209 2 return each %{$self->{ARGS}};
210  
211 }
212  
213 77 ▶sub _checkArgs {
Subroutine _checkArgs: called CC=5 SCAR=16.2
214  
215 77 my ($self, $ARGS) = @_;
216  
217 77 my $action = $ARGS->{action};
218 77 my $accessKey = $ARGS->{key};
219 77 my $storeVal = $ARGS->{value};
220 77 my $argsRef = $ARGS->{argsRef};
221 77 my $hashRef = $ARGS->{hashRef};
222  
223 77 ▶ if (exists($hashRef->{$accessKey}))
Branch: 1 branch
BranchTrueFalseTotal
if (exists $hashRef->{$accessKey}) { } 69 8 77
224 {
225 69 my $value = $hashRef->{$accessKey};
226  
227 69 $ARGS->{_prototype} = $value;
228 69 $self->_checkParameter($ARGS);
229 }
230 else
231 {
232 8 ▶ my $_mainobj = $self->{_MAIN} || $self;
Condition33%1/3
$self->{'_MAIN'} || $self
l!l&&r!l&&!r
800
MC/DC0%0/2
$self->{'_MAIN'} || $self
$self->{'_MAIN'} $self
Truth table33%1/3
A || B
A= $self->{'_MAIN'}B= $self
ABresult
1X1
011
000
233
234 8 ▶ my $_parent = $_mainobj->{_INDEX}->{$argsRef}->{parent} || $self->{PARENT};
Condition66%2/3
$_mainobj->{'_INDEX'}{$argsRef}{'parent'} || $self->{'PARENT'}
l!l&&r!l&&!r
710
MC/DC0%0/2
$_mainobj->{'_INDEX'}{$argsRef}{'parent'} || $self->{'PARENT'}
$_mainobj->{'_INDEX'}{$argsRef}{'parent'} $self->{'PARENT'}
Truth table66%2/3
A || B
A= $_mainobj->{'_INDEX'}{$argsRef}{'parent'}B= $self->{'PARENT'}
ABresult
1X1
011
000
235 8 ▶ my $_parentkey = $_mainobj->{_INDEX}->{$argsRef}->{parentkey} || $self->{PARENTKEY};
Condition66%2/3
$_mainobj->{'_INDEX'}{$argsRef}{'parentkey'} || $self->{'PARENTKEY'}
l!l&&r!l&&!r
710
MC/DC0%0/2
$_mainobj->{'_INDEX'}{$argsRef}{'parentkey'} || $self->{'PARENTKEY'}
$_mainobj->{'_INDEX'}{$argsRef}{'parentkey'} $self->{'PARENTKEY'}
Truth table66%2/3
A || B
A= $_mainobj->{'_INDEX'}{$argsRef}{'parentkey'}B= $self->{'PARENTKEY'}
ABresult
1X1
011
000
236 8 my $_parentPrototype = $_parent->{proto}->{$_parentkey};
237  
238 8 $ARGS->{_prototype} = $_parentPrototype;
239 8 $self->_checkParameter($ARGS);
240 }
241
242 71 return ();
243
244 }
245 77 ▶sub _checkParameter {
Subroutine _checkParameter: called CC=13 SCAR=33.3
246  
247 77 my ($self, $ARGS) = @_;
248  
249 77 my $action = $ARGS->{action};
250 77 my $accessKey = $ARGS->{key};
251 77 my $storeVal = $ARGS->{value};
252 77 my $argsRef = $ARGS->{argsRef};
253 77 my $hashRef = $ARGS->{hashRef};
254 77 my $_prototype = $ARGS->{_prototype};
255  
256 77 ▶ if ((ref($_prototype) eq 'HASH') && exists($_prototype->{dataType}))
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_prototype eq 'HASH' and exists $_prototype->{'dataType'}) { } 40 37 77
Condition100%3/3
ref $_prototype eq "HASH" and exists $_prototype->{"dataType"}
!ll&&!rl&&r
43340
MC/DC100%2/2
ref $_prototype eq "HASH" and exists $_prototype->{"dataType"}
ref $_prototype eq "HASH" exists $_prototype->{"dataType"}
Truth table100%3/3
A and B
A= ref $_prototype eq "HASH"B= exists $_prototype->{"dataType"}
ABresult
0X0
100
111
257 {
258 40 $self->_checkAttributes({
259 action => $action,
260 value => $storeVal,
261 attributes => $_prototype,
262 key => $accessKey,
263 argsRef => $argsRef
264 });
265 }
266 else
267 {
268 37 ▶ if ((!exists($argsRef->{$accessKey})) && exists($hashRef->{$accessKey}))
Branch: 3 branches
BranchTrueFalseTotal
if (not exists $argsRef->{$accessKey} and exists $hashRef->{$accessKey}) { } 1 36 37
elsif (exists $argsRef->{$accessKey} and not exists $hashRef->{$accessKey}) { } 0 36 36
elsif (not exists $argsRef->{$accessKey} || exists $hashRef->{$accessKey}) { } 0 36 36
Condition66%2/3
not exists $argsRef->{$accessKey} and exists $hashRef->{$accessKey}
!ll&&!rl&&r
3601
MC/DC50%1/2
not exists $argsRef->{$accessKey} and exists $hashRef->{$accessKey}
not exists $argsRef->{$accessKey} exists $hashRef->{$accessKey}
Truth table66%2/3
not(A) and B
A= not exists $argsRef->{$accessKey}B= exists $hashRef->{$accessKey}
ABresult
0X0
100
111
269 {
270 1 ▶ if (uc($action) ne 'STORE')
Branch: 1 branch
BranchTrueFalseTotal
if (uc $action ne "STORE") 0 1 1
271 {
272 0 croak "Parameter '$accessKey' was not passed to the constructor!";
273 }
274 }
275 ▶ elsif (exists($argsRef->{$accessKey}) && (!exists($hashRef->{$accessKey})))
Condition33%1/3
exists $argsRef->{$accessKey} and not exists $hashRef->{$accessKey}
!ll&&!rl&&r
0360
MC/DC0%0/2
exists $argsRef->{$accessKey} and not exists $hashRef->{$accessKey}
exists $argsRef->{$accessKey} not exists $hashRef->{$accessKey}
Truth table33%1/3
A and not(B)
A= exists $argsRef->{$accessKey}B= not exists $hashRef->{$accessKey}
ABresult
0X0
100
111
276 {
277 0 croak "Parameter '$accessKey' is not permitted!";
278 }
279 ▶ elsif (!exists($argsRef->{$accessKey}) && (!exists($hashRef->{$accessKey})))
Condition33%1/3
exists $argsRef->{$accessKey} || exists $hashRef->{$accessKey}
l!l&&r!l&&!r
3600
MC/DC0%0/2
exists $argsRef->{$accessKey} || exists $hashRef->{$accessKey}
exists $argsRef->{$accessKey} exists $hashRef->{$accessKey}
Truth table33%1/3
A || B
A= exists $argsRef->{$accessKey}B= exists $hashRef->{$accessKey}
ABresult
1X1
011
000
280 {
281 0 ▶ if (((uc($action) ne 'STORE') && (uc($_prototype->{dataType}) eq 'HASH')) ||
Branch: 1 branch
BranchTrueFalseTotal
if (uc $action ne "STORE" and uc $_prototype->{"dataType"} eq "HASH" or uc $_prototype->{"dataType"} ne "HASH") 0 0 0
Condition0%0/6
uc $action ne "STORE" and uc $_prototype->{"dataType"} eq "HASH" or uc $_prototype->{"dataType"} ne "HASH"
l!l&&r!l&&!r
000
uc $action ne "STORE" and uc $_prototype->{"dataType"} eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/3
uc $action ne "STORE" and uc $_prototype->{"dataType"} eq "HASH" or uc $_prototype->{"dataType"} ne "HASH"
uc $action ne "STORE" uc $_prototype->{"dataType"} eq "HASH" uc $_prototype->{"dataType"} ne "HASH"
Truth table0%0/5
A and B or C
A= uc $action ne "STORE"B= uc $_prototype->{"dataType"} eq "HASH"C= uc $_prototype->{"dataType"} ne "HASH"
ABCresult
11X1
0X11
1011
0X00
1000
282 (uc($_prototype->{dataType}) ne 'HASH')
283 )
284 {
285 0 croak "Parameter '$accessKey' is not a defined key!";
286 }
287 }
288 }
289  
290 }
291 40 ▶sub _checkAttributes {
Subroutine _checkAttributes: called CC=41 SCAR=39.4
292  
293 40 my ($self, $ARGS) = @_;
294
295 40 my $attribute = $ARGS->{attributes}; # prototype
296 40 my $argsRef = $ARGS->{argsRef};
297 40 my $action = uc($ARGS->{action});
298 40 my $storeVal = $ARGS->{value};
299 40 my $key = $ARGS->{key};
300 40 my $_countUp = 0;
301  
302 40 ▶ my $_mainobj = $self->{_MAIN} || $self;
Condition33%1/3
$self->{'_MAIN'} || $self
l!l&&r!l&&!r
4000
MC/DC0%0/2
$self->{'_MAIN'} || $self
$self->{'_MAIN'} $self
Truth table33%1/3
A || B
A= $self->{'_MAIN'}B= $self
ABresult
1X1
011
000
303
304 40 ▶ my $_parent = $_mainobj->{_INDEX}->{$argsRef}->{parent} || $self->{PARENT};
Condition66%2/3
$_mainobj->{'_INDEX'}{$argsRef}{'parent'} || $self->{'PARENT'}
l!l&&r!l&&!r
3280
MC/DC0%0/2
$_mainobj->{'_INDEX'}{$argsRef}{'parent'} || $self->{'PARENT'}
$_mainobj->{'_INDEX'}{$argsRef}{'parent'} $self->{'PARENT'}
Truth table66%2/3
A || B
A= $_mainobj->{'_INDEX'}{$argsRef}{'parent'}B= $self->{'PARENT'}
ABresult
1X1
011
000
305 40 ▶ my $_parentkey = $_mainobj->{_INDEX}->{$argsRef}->{parentkey} || $self->{PARENTKEY};
Condition66%2/3
$_mainobj->{'_INDEX'}{$argsRef}{'parentkey'} || $self->{'PARENTKEY'}
l!l&&r!l&&!r
3280
MC/DC0%0/2
$_mainobj->{'_INDEX'}{$argsRef}{'parentkey'} || $self->{'PARENTKEY'}
$_mainobj->{'_INDEX'}{$argsRef}{'parentkey'} $self->{'PARENTKEY'}
Truth table66%2/3
A || B
A= $_mainobj->{'_INDEX'}{$argsRef}{'parentkey'}B= $self->{'PARENTKEY'}
ABresult
1X1
011
000
306 # my $_parent = $_mainobj->{_INDEX}->{$argsRef}->{parent};
307 # my $_parentkey = $_mainobj->{_INDEX}->{$argsRef}->{parentkey};
308 40 my $_parentArgs = $_parent->{args}->{$_parentkey};
309 40 my $_parentPrototype = $_parent->{proto}->{$_parentkey};
310  
311 40 my ($verbIs, $verbAre);
312
313 40 for (qw( allowEmpty dataType maxLength minLength readAccess required value writeAccess ))
314 {
315 320 ▶ exists $attribute->{$_} || croak "'$key' is missing the $_ attribute!";
Branch: 1 branch
BranchTrueFalseTotal
exists $attribute->{$_} or croak("'${key}' is missing the $_ attribute!") 320 0 320
316 }
317  
318 40 ▶ my $_isChild = ($_parentPrototype eq $attribute) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$_parentPrototype eq $attribute ? : 8 32 40
319
320 40 ▶ my $xvalue = (uc($action) eq 'STORE') || (uc($action) eq 'FETCH' && $_isChild ) ? $argsRef : $argsRef->{$key} ;
Branch: 1 branch
BranchTrueFalseTotal
uc $action eq 'STORE' || uc $action eq 'FETCH' && $_isChild ? : 11 29 40
Condition83%5/6
uc $action eq "STORE" or uc $action eq "FETCH" and $_isChild
l!l&&r!l&&!r
10129
uc $action eq "FETCH" and $_isChild
!ll&&!rl&&r
0291
MC/DC66%2/3
uc $action eq "STORE" or uc $action eq "FETCH" and $_isChild
uc $action eq "STORE" uc $action eq "FETCH" $_isChild
Truth table75%3/4
A or B and C
A= uc $action eq "STORE"B= uc $action eq "FETCH"C= $_isChild
ABCresult
1XX1
0111
00X0
0100
321  
322 40 ▶ if (ref($attribute->{value}) eq 'HASH')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $attribute->{"value"} eq "HASH") 36 4 40
323 {
324 36 for (keys(%{$attribute->{value}}))
325 {
326 72 my($_key, $_value) = ($_, $attribute->{value}->{$_});
327
328 72 ▶ if ((ref $_value eq 'HASH') && ($_value->{required}) && (!exists $xvalue->{$_key}))
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_value eq "HASH" and $_value->{"required"} and not exists $xvalue->{$_key}) 1 71 72
Condition100%6/6
ref $_value eq "HASH" and $_value->{"required"} and not exists $xvalue->{$_key}
!ll&&!rl&&r
52191
ref $_value eq "HASH" and $_value->{"required"}
!ll&&!rl&&r
173520
MC/DC100%3/3
ref $_value eq "HASH" and $_value->{"required"} and not exists $xvalue->{$_key}
ref $_value eq "HASH" $_value->{"required"} not exists $xvalue->{$_key}
Truth table100%4/4
A and B and not(C)
A= ref $_value eq "HASH"B= $_value->{"required"}C= not exists $xvalue->{$_key}
ABCresult
0XX0
10X0
1100
1111
329 {
330 1 croak "The required key '$_key' was not passed to the constructor!";
331 }
332 }
333 }
334  
335 39 my $value = $argsRef->{$key};
336  
337 39 ▶ if ($action eq 'STORE')
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq 'STORE') { } 10 29 39
338 {
339 10 $verbIs = $verbAre = 'would be';
340 10 $_countUp = 1;
341
342 10 ▶ if ($attribute->{writeAccess} <= 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($attribute->{"writeAccess"} <= 0) 1 9 10
343 {
344 1 ▶ $key = $_isChild ? $_parentkey : $key;
Branch: 1 branch
BranchTrueFalseTotal
$_isChild ? : 1 0 1
345 1 croak "The '$key' structure is write protected!";
346 }
347 }
348 else
349 {
350 29 $verbIs = 'is';
351 29 $verbAre = 'are';
352 }
353
354 38 (my $str = (caller(4))[3]) =~ s/(.|\n)/sprintf("%02lx", ord $1)/eg;
355 38 ▶ if (uc($attribute->{dataType}) eq 'SCALAR')
Branch: 2 branches
BranchTrueFalseTotal
if (uc $attribute->{'dataType'} eq 'SCALAR') { } 4 34 38
elsif (uc $attribute->{'dataType'} eq 'HASH') { } 34 0 34
356 {
357 4 ▶ $attribute->{readAccess} <= 0 and $str =~ /4f4f503a3a4163636573736f723a3a67657450726f7065727479/ ||
Branch: 1 branch
BranchTrueFalseTotal
$attribute->{"readAccess"} <= 0 and $str =~ /4f4f503a3a4163636573736f723a3a67657450726f7065727479/ || croak("Direct read access to '${key}' is prohibited!") 1 3 4
Condition75%3/4
$attribute->{'readAccess'} <= 0 && ($str =~ /4f4f503a3a4163636573736f723a3a67657450726f7065727479/ || croak("Direct read access to '${key}' is prohibited!"))
!ll
31
$str =~ /4f4f503a3a4163636573736f723a3a67657450726f7065727479/ or croak("Direct read access to '${key}' is prohibited!")
l!l
01
MC/DC0%0/2
$attribute->{'readAccess'} <= 0 && ($str =~ /4f4f503a3a4163636573736f723a3a67657450726f7065727479/ || croak("Direct read access to '${key}' is prohibited!"))
$attribute->{'readAccess'} <= 0 $str =~ /4f4f503a3a4163636573736f723a3a67657450726f7065727479/
Truth table66%2/3
A && B
A= $attribute->{'readAccess'} <= 0B= $str =~ /4f4f503a3a4163636573736f723a3a67657450726f7065727479/
ABresult
0X0
100
111
358 croak "Direct read access to '$key' is prohibited!";
359
360 3 ▶ !(uc($action) eq 'STORE') or $value = $storeVal;
Branch: 1 branch
BranchTrueFalseTotal
uc $action eq "STORE" and $value = $storeVal 3 0 3
361
362 3 ▶ !(($attribute->{allowEmpty} <= 0) && ($value eq '')) ||
Branch: 1 branch
BranchTrueFalseTotal
($attribute->{"allowEmpty"} <= 0 and $value eq "") and croak("'${key}' $verbIs empty in violation of constructor's definition!") 0 3 3
Condition33%1/3
$attribute->{"allowEmpty"} <= 0 and $value eq ""
!ll&&!rl&&r
300
MC/DC0%0/2
$attribute->{"allowEmpty"} <= 0 and $value eq ""
$attribute->{"allowEmpty"} <= 0 $value eq ""
Truth table33%1/3
A and B
A= $attribute->{"allowEmpty"} <= 0B= $value eq ""
ABresult
0X0
100
111
363 croak "'$key' $verbIs empty in violation of constructor's definition!";
364
365 3 ▶ if ((length($value) >= $attribute->{maxLength}))
Branch: 2 branches
BranchTrueFalseTotal
if (length $value >= $attribute->{'maxLength'}) { } 1 2 3
elsif (length $value <= $attribute->{'minLength'} and ($value ne '' and $attribute->{'allowEmpty'} > 0)) { } 1 2 3
366 {
367 1 croak "'$key' $verbIs too long, in violation of constructor's definition!";
368 }
369 ▶ elsif ((length($value) <= $attribute->{minLength}) && (($value ne '') && ($attribute->{allowEmpty} > 0)))
Condition66%4/6
length $value <= $attribute->{"minLength"} and ($value ne "" and $attribute->{"allowEmpty"} > 0)
!ll&&!rl&&r
011
$value ne "" and $attribute->{"allowEmpty"} > 0
!ll&&!rl&&r
101
MC/DC33%1/3
length $value <= $attribute->{"minLength"} and ($value ne "" and $attribute->{"allowEmpty"} > 0)
length $value <= $attribute->{"minLength"} $value ne "" $attribute->{"allowEmpty"} > 0
Truth table50%2/4
A and B and C
A= length $value <= $attribute->{"minLength"}B= $value ne ""C= $attribute->{"allowEmpty"} > 0
ABCresult
0XX0
10X0
1100
1111
370 {
371 1 croak "'$key' $verbIs shorter in violation of constructor's definition!";
372 }
373 }
374 elsif (uc($attribute->{dataType}) eq 'HASH')
375 {
376 34 ▶ if ($_isChild)
Branch: 1 branch
BranchTrueFalseTotal
if ($_isChild) 7 27 34
377 {
378 7 $value = $_parentArgs;
379  
380 7 ▶ if (uc($action) eq 'FETCH')
Branch: 2 branches
BranchTrueFalseTotal
if (uc $action eq 'FETCH') { } 1 6 7
elsif (uc $action eq 'STORE') { } 6 0 6
381 {
382 1 ▶ exists($value->{$key}) || croak "The key '$key' does not exist and thus cannot be read!";
Branch: 1 branch
BranchTrueFalseTotal
exists $value->{$key} or croak("The key '${key}' does not exist and thus cannot be read!") 1 0 1
383 }
384 elsif(uc($action) eq 'STORE')
385 {
386 6 ▶ !exists($value->{$key}) || ($_countUp = 0);
Branch: 1 branch
BranchTrueFalseTotal
exists $value->{$key} and $_countUp = 0 1 5 6
387 }
388 }
389  
390 34 ▶ if (uc($action) eq 'STORE')
Branch: 1 branch
BranchTrueFalseTotal
if (uc $action eq 'STORE') { } 6 28 34
391 {
392 6 $key = $_parentkey;
393 6 $value = $_parentArgs;
394 }
395 else
396 {
397 28 ▶ $attribute->{readAccess} <= 0 and $str =~ /4f4f503a3a4163636573736f723a3a67657450726f7065727479/ ||
Branch: 1 branch
BranchTrueFalseTotal
$attribute->{"readAccess"} <= 0 and $str =~ /4f4f503a3a4163636573736f723a3a67657450726f7065727479/ || croak("Direct read access to '${key}' is prohibited!") 0 28 28
Condition25%1/4
$attribute->{'readAccess'} <= 0 && ($str =~ /4f4f503a3a4163636573736f723a3a67657450726f7065727479/ || croak("Direct read access to '${key}' is prohibited!"))
!ll
280
$str =~ /4f4f503a3a4163636573736f723a3a67657450726f7065727479/ or croak("Direct read access to '${key}' is prohibited!")
l!l
00
MC/DC0%0/2
$attribute->{'readAccess'} <= 0 && ($str =~ /4f4f503a3a4163636573736f723a3a67657450726f7065727479/ || croak("Direct read access to '${key}' is prohibited!"))
$attribute->{'readAccess'} <= 0 $str =~ /4f4f503a3a4163636573736f723a3a67657450726f7065727479/
Truth table33%1/3
A && B
A= $attribute->{'readAccess'} <= 0B= $str =~ /4f4f503a3a4163636573736f723a3a67657450726f7065727479/
ABresult
0X0
100
111
398 croak "Direct read access to '$key' is prohibited!";
399 }
400
401 34 my $keys = keys(%{$value}) + $_countUp;
402
403 34 ▶ if ($attribute->{allowEmpty} <= 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($attribute->{"allowEmpty"} <= 0) 0 34 34
404 {
405 0 ▶ !($keys <= 0) || croak "'$key' $verbIs empty in violation of constructor's definition!";
Branch: 1 branch
BranchTrueFalseTotal
$keys <= 0 and croak("'${key}' $verbIs empty in violation of constructor's definition!") 0 0 0
406 }
407
408 34 ▶ if (($keys > $attribute->{maxLength}))
Branch: 2 branches
BranchTrueFalseTotal
if ($keys > $attribute->{'maxLength'}) { } 1 33 34
elsif ($keys < $attribute->{'minLength'}) { } 0 33 33
409 {
410 1 croak "There $verbAre more items in '$key' structure than permitted!";
411 }
412 elsif (($keys < $attribute->{minLength}))
413 {
414 0 croak "There $verbAre fewer items in '$key' structure than permitted!";
415 }
416
417 }
418
419
420 34 return();
421
422 }
423  
424 1 1;
425  
↑ Summary OOP.pm »