Client/Item/Factory.pm

filter: Statementstmt 85.7% 174 / 203 Branchbran 66.6% 4 / 6 Conditioncond 36.6% 22 / 60 MC/DCmcdc 0.0% 0 / 31 Subroutinesub 87.2% 48 / 55 Podpod 7.1% 2 / 28 totaltotal 65.2% 250 / 383 CC 33 SCAR 9.8
CC
33
Cov
74%
newItem
6.8
genitem_break
6.0
genitem_option
6.0
CRAP 2.7
« Client/Device/Dummy.pm ↑ Summary Client/Engine/Component/Interpreter/JavaScript.pm »
1 package VoiceXML::Client::Item::Factory;
2  
3 3 ▶use VoiceXML::Client::Item::Form;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use VoiceXML::Client::Item::Prompt;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use VoiceXML::Client::Item::Field;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use VoiceXML::Client::Item::Break;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use VoiceXML::Client::Item::Option;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use VoiceXML::Client::Item::Filled;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use VoiceXML::Client::Item::If;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use VoiceXML::Client::Item::Elseif;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use VoiceXML::Client::Item::Else;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use VoiceXML::Client::Item::Goto;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 ▶use VoiceXML::Client::Item::Submit;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 3 ▶use VoiceXML::Client::Item::Disconnect;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 3 ▶use VoiceXML::Client::Item::Audio;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 3 ▶use VoiceXML::Client::Item::Record;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 3 ▶use VoiceXML::Client::Item::Var;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 3 ▶use VoiceXML::Client::Item::Clear;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 3 ▶use VoiceXML::Client::Item::Block;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 3 ▶use VoiceXML::Client::Item::NoInput;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 3 ▶use VoiceXML::Client::Item::NoMatch;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 3 ▶use VoiceXML::Client::Item::Reprompt;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 3 ▶use VoiceXML::Client::Item::Assign;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 3 ▶use VoiceXML::Client::Item::SubDialog;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 3 ▶use VoiceXML::Client::Item::Return;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 3 ▶use VoiceXML::Client::Item::Grammar;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 3 ▶use VoiceXML::Client::Item::Grammar::Rule;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30  
31 =head1 COPYRIGHT AND LICENSE
32  
33
34 Copyright (C) 2007,2008 by Pat Deegan.
35 All rights reserved
36 http://voicexml.psychogenic.com
37  
38 This library is released under the terms of the GNU GPL version 3, making it available only for
39 free programs ("free" here being used in the sense of the GPL, see http://www.gnu.org for more details).
40 Anyone wishing to use this library within a proprietary or otherwise non-GPLed program MUST contact psychogenic.com to
41 acquire a distinct license for their application. This approach encourages the use of free software
42 while allowing for proprietary solutions that support further development.
43  
44  
45 This file is part of VoiceXML::Client.
46  
47
48
49 VoiceXML::Client is free software: you can redistribute it and/or modify
50 it under the terms of the GNU General Public License as published by
51 the Free Software Foundation, either version 3 of the License, or
52 (at your option) any later version.
53  
54 VoiceXML::Client is distributed in the hope that it will be useful,
55 but WITHOUT ANY WARRANTY; without even the implied warranty of
56 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57 GNU General Public License for more details.
58  
59 You should have received a copy of the GNU General Public License
60 along with VoiceXML::Client. If not, see <http://www.gnu.org/licenses/>.
61  
62  
63 =cut
64  
65  
66  
67  
68 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
69  
70  
71 3 ▶use vars qw{
Subroutine BEGIN: called CC=1 SCAR=0.0
72 $VERSION
73 3 };
74  
75 3 $VERSION = $VoiceXML::Client::Item::VERSION;
76  
77  
78  
79 =head2 new
80  
81 =cut
82  
83 3 ▶sub new {
Subroutine new: called CC=2 SCAR=7.1
Pod documented
84 3 my $class = shift;
85 3 my $defaultItemParent = shift;
86
87 3 my $self = {};
88
89 3 ▶ bless $self, ref $class || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
030
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
90
91 3 $self->{'defaultItemParent'} = $defaultItemParent;
92
93 3 return $self;
94 }
95  
96  
97  
98  
99 =head2 newItem NAME XMLELEMENT
100  
101 Creates a new instance.
102  
103  
104 =cut
105  
106 62 ▶sub newItem {
Subroutine newItem: called CC=6 SCAR=19.2
Pod documented
107 62 my $class = shift;
108 62 my $name = shift;
109 62 ▶ my $xmlElement = shift || return VoiceXML::Client::Util::error("VoiceXML::Client::Item::Factory::newItem() Must pass an XML element to new.");
Condition50%1/2
shift() || (return VoiceXML::Client::Util::error('VoiceXML::Client::Item::Factory::newItem() Must pass an XML element to new.'))
l!l
620
MC/DC0%0/1
shift() || (return VoiceXML::Client::Util::error('VoiceXML::Client::Item::Factory::newItem() Must pass an XML element to new.'))
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
110 62 my $parent = shift ;
111
112 62 ▶ if (! $parent && ref $class)
Branch: 1 branch
BranchTrueFalseTotal
if (not $parent and ref $class) 0 62 62
Condition33%1/3
not $parent and ref $class
!ll&&!rl&&r
6200
MC/DC0%0/2
not $parent and ref $class
not $parent ref $class
Truth table33%1/3
not(A) and B
A= not $parentB= ref $class
ABresult
0X0
100
111
113 {
114 0 $parent = $class->{'defaultItemParent'};
115 }
116
117 62 ▶ return VoiceXML::Client::Util::error("VoiceXML::Client::Item::Factory::newItem() Must pass a name for form object to new.")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 0 62 62
118 unless (defined $name);
119
120
121 62 my $sub = "genitem_" . lc($name);
122
123 62 ▶ return $class->$sub($xmlElement, $parent) if ($class->can($sub));
Branch: 1 branch
BranchTrueFalseTotal
if $class->can($sub) 59 3 62
124
125 3 return undef;
126
127 }
128  
129 4 ▶sub genitem_prompt {
Subroutine genitem_prompt: called CC=2 SCAR=7.0
Pod undocumented
130 4 my $class = shift;
131 4 ▶ my $xmlElement = shift || return;
Condition50%1/2
shift() || (return)
l!l
40
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
132 4 my $parent = shift ;
133
134 4 return VoiceXML::Client::Item::Prompt->new($xmlElement, $parent);
135 }
136  
137  
138 1 ▶sub genitem_field {
Subroutine genitem_field: called CC=2 SCAR=7.0
Pod undocumented
139 1 my $class = shift;
140 1 ▶ my $xmlElement = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
141 1 my $parent = shift ;
142
143 1 return VoiceXML::Client::Item::Field->new($xmlElement, $parent);
144 }
145  
146 7 ▶sub genitem_form {
Subroutine genitem_form: called CC=2 SCAR=7.0
Pod undocumented
147 7 my $class = shift;
148 7 ▶ my $xmlElement = shift || return;
Condition50%1/2
shift() || (return)
l!l
70
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
149 7 my $parent = shift ;
150
151 7 return VoiceXML::Client::Item::Form->new($xmlElement, $parent);
152 }
153  
154 0 ▶sub genitem_break {
Subroutine genitem_break: not called CC=2 SCAR=17.9
Pod undocumented
155 0 my $class = shift;
156 0 ▶ my $xmlElement = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
157 0 my $parent = shift ;
158
159 0 return VoiceXML::Client::Item::->new($xmlElement, $parent);
160 }
161  
162 0 ▶sub genitem_option {
Subroutine genitem_option: not called CC=2 SCAR=17.9
Pod undocumented
163 0 my $class = shift;
164 0 ▶ my $xmlElement = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
165 0 my $parent = shift ;
166
167 0 return VoiceXML::Client::Item::Option->new($xmlElement, $parent);
168 }
169  
170 1 ▶sub genitem_filled {
Subroutine genitem_filled: called CC=2 SCAR=7.0
Pod undocumented
171 1 my $class = shift;
172 1 ▶ my $xmlElement = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
173 1 my $parent = shift ;
174
175 1 return VoiceXML::Client::Item::Filled->new($xmlElement, $parent);
176 }
177  
178  
179
180 1 ▶sub genitem_if {
Subroutine genitem_if: called CC=2 SCAR=7.0
Pod undocumented
181 1 my $class = shift;
182 1 ▶ my $xmlElement = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
183 1 my $parent = shift ;
184
185 1 return VoiceXML::Client::Item::If->new($xmlElement, $parent);
186 }
187  
188 5 ▶sub genitem_elseif {
Subroutine genitem_elseif: called CC=2 SCAR=7.0
Pod undocumented
189 5 my $class = shift;
190 5 ▶ my $xmlElement = shift || return;
Condition50%1/2
shift() || (return)
l!l
50
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
191 5 my $parent = shift ;
192
193 5 return VoiceXML::Client::Item::Elseif->new($xmlElement, $parent);
194 }
195  
196 1 ▶sub genitem_else {
Subroutine genitem_else: called CC=2 SCAR=7.0
Pod undocumented
197 1 my $class = shift;
198 1 ▶ my $xmlElement = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
199 1 my $parent = shift ;
200
201 1 return VoiceXML::Client::Item::Else->new($xmlElement, $parent);
202 }
203  
204 1 ▶sub genitem_goto {
Subroutine genitem_goto: called CC=2 SCAR=7.0
Pod undocumented
205 1 my $class = shift;
206 1 ▶ my $xmlElement = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
207 1 my $parent = shift ;
208
209 1 return VoiceXML::Client::Item::Goto->new($xmlElement, $parent);
210 }
211  
212 7 ▶sub genitem_audio {
Subroutine genitem_audio: called CC=2 SCAR=7.0
Pod undocumented
213 7 my $class = shift;
214 7 ▶ my $xmlElement = shift || return;
Condition50%1/2
shift() || (return)
l!l
70
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
215 7 my $parent = shift ;
216
217 7 return VoiceXML::Client::Item::Audio->new($xmlElement, $parent);
218 }
219  
220 0 ▶sub genitem_record {
Subroutine genitem_record: not called CC=2 SCAR=17.9
Pod undocumented
221 0 my $class = shift;
222 0 ▶ my $xmlElement = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
223 0 my $parent = shift ;
224
225 0 return VoiceXML::Client::Item::Record->new($xmlElement, $parent);
226 }
227  
228 6 ▶sub genitem_var {
Subroutine genitem_var: called CC=2 SCAR=7.0
Pod undocumented
229 6 my $class = shift;
230 6 ▶ my $xmlElement = shift || return;
Condition50%1/2
shift() || (return)
l!l
60
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
231 6 my $parent = shift ;
232
233 6 return VoiceXML::Client::Item::Var->new($xmlElement, $parent);
234 }
235  
236 0 ▶sub genitem_clear {
Subroutine genitem_clear: not called CC=2 SCAR=17.9
Pod undocumented
237 0 my $class = shift;
238 0 ▶ my $xmlElement = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
239 0 my $parent = shift ;
240
241 0 return VoiceXML::Client::Item::Clear->new($xmlElement, $parent);
242 }
243 3 ▶sub genitem_block {
Subroutine genitem_block: called CC=2 SCAR=7.0
Pod undocumented
244 3 my $class = shift;
245 3 ▶ my $xmlElement = shift || return;
Condition50%1/2
shift() || (return)
l!l
30
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
246 3 my $parent = shift ;
247
248 3 return VoiceXML::Client::Item::Block->new($xmlElement, $parent);
249 }
250  
251 2 ▶sub genitem_submit {
Subroutine genitem_submit: called CC=2 SCAR=7.0
Pod undocumented
252 2 my $class = shift;
253 2 ▶ my $xmlElement = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
254 2 my $parent = shift ;
255
256 2 return VoiceXML::Client::Item::Submit->new($xmlElement, $parent);
257 }
258  
259 2 ▶sub genitem_noinput {
Subroutine genitem_noinput: called CC=2 SCAR=7.0
Pod undocumented
260 2 my $class = shift;
261 2 ▶ my $xmlElement = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
262 2 my $parent = shift ;
263
264 2 return VoiceXML::Client::Item::NoInput->new($xmlElement, $parent);
265 }
266  
267  
268 2 ▶sub genitem_reprompt {
Subroutine genitem_reprompt: called CC=2 SCAR=7.0
Pod undocumented
269 2 my $class = shift;
270 2 ▶ my $xmlElement = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
271 2 my $parent = shift ;
272
273 2 return VoiceXML::Client::Item::Reprompt->new($xmlElement, $parent);
274 }
275  
276 10 ▶sub genitem_assign {
Subroutine genitem_assign: called CC=2 SCAR=7.0
Pod undocumented
277 10 my $class = shift;
278 10 ▶ my $xmlElement = shift || return;
Condition50%1/2
shift() || (return)
l!l
100
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
279 10 my $parent = shift ;
280
281 10 return VoiceXML::Client::Item::Assign->new($xmlElement, $parent);
282 }
283  
284  
285 0 ▶sub genitem_grammar {
Subroutine genitem_grammar: not called CC=2 SCAR=17.9
Pod undocumented
286 0 my $class = shift;
287 0 ▶ my $xmlElement = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
288 0 my $parent = shift ;
289
290 0 return VoiceXML::Client::Item::Grammar->new($xmlElement, $parent);
291 }
292  
293  
294 0 ▶sub genitem_rule {
Subroutine genitem_rule: not called CC=2 SCAR=17.9
Pod undocumented
295 0 my $class = shift;
296 0 ▶ my $xmlElement = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
297 0 my $parent = shift ;
298
299 0 return VoiceXML::Client::Item::Grammar::Rule->new($xmlElement, $parent);
300 }
301  
302  
303  
304 0 ▶sub genitem_nomatch {
Subroutine genitem_nomatch: not called CC=2 SCAR=17.9
Pod undocumented
305 0 my $class = shift;
306 0 ▶ my $xmlElement = shift || return;
Condition0%0/2
shift() || (return)
l!l
00
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
307 0 my $parent = shift ;
308
309 0 return VoiceXML::Client::Item::NoMatch->new($xmlElement, $parent);
310 }
311  
312  
313 1 ▶sub genitem_subdialog {
Subroutine genitem_subdialog: called CC=2 SCAR=7.0
Pod undocumented
314 1 my $class = shift;
315 1 ▶ my $xmlElement = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
316 1 my $parent = shift ;
317
318 1 return VoiceXML::Client::Item::SubDialog->new($xmlElement, $parent);
319 }
320  
321  
322  
323 1 ▶sub genitem_return {
Subroutine genitem_return: called CC=2 SCAR=7.0
Pod undocumented
324 1 my $class = shift;
325 1 ▶ my $xmlElement = shift || return;
Condition50%1/2
shift() || (return)
l!l
10
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
326 1 my $parent = shift ;
327
328 1 return VoiceXML::Client::Item::Return->new($xmlElement, $parent);
329 }
330  
331  
332  
333  
334  
335  
336 4 ▶sub genitem_disconnect {
Subroutine genitem_disconnect: called CC=2 SCAR=7.0
Pod undocumented
337 4 my $class = shift;
338 4 ▶ my $xmlElement = shift || return;
Condition50%1/2
shift() || (return)
l!l
40
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
339 4 my $parent = shift ;
340
341 4 return VoiceXML::Client::Item::Disconnect->new($xmlElement, $parent);
342 }
343  
344  
345 2 ▶sub genitem_exit {
Subroutine genitem_exit: called CC=2 SCAR=7.0
Pod undocumented
346 2 my $class = shift;
347 2 ▶ my $xmlElement = shift || return;
Condition50%1/2
shift() || (return)
l!l
20
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
348 2 my $parent = shift ;
349
350 2 return $class->genitem_disconnect($xmlElement, $parent);
351 }
352  
353  
354  
355 3 1;
« Client/Device/Dummy.pm ↑ Summary Client/Engine/Component/Interpreter/JavaScript.pm »