Documentation is available at RSDEngineFunction.php
1 <?php
2 // RSDEngine: The Rapid and Secure Development Engine
3 // Copyright (C) 2003 Lukas Feiler
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 /**Contains just the class RSDEngineFunction.
20 *
21 * @package RSDEngine
22 * @author Lukas Feiler <lukas.feiler@chello.at>
23 * @copyright Lukas Feiler 2003
24 * @filesource
25 */
26
27 /**Helper class for generating a function.
28 *
29 * There are two ways of using this class.
30 * The first one is to extend it and to overwrite the methods getFunctionName,
31 * and getCode. This is recommendable if the function you want to generate
32 * is rather complex. You would call the constructor with only one argument:
33 * <code>
34 *new RSDEngineFunctionChildClass($config);
35 * </code>
36 * The second way to use this class makes only sense if $config is not needed
37 * for generating your class. Call the constructor like this:
38 * <code>
39 *new RSDEngineClass(false, "myFunction", $functionBodyCode);
40 * </code>
41 * and use the methods getCode/toRSDFile.
42 *
43 * @author Lukas Feiler <lukas.feiler@chello.at>
44 * @version 0.1.9
45 * @copyright Lukas Feiler 2003
46 * @package RSDEngine
47 */
48 class RSDEngineFunction{
49
50 /**An associative array containing all configuration options. Gets set inside the constructor method.
51 * @var Array
52 */
53 var $config = array();
54
55 /**The name of the function to generate. Gets optionally set inside the constructor method.
56 * @var mixed
57 */
58 var $functionName = false;
59
60 /**The body of the function to generate. Gets optionally set inside the constructor method.
61 * @var mixed
62 */
63 var $code = false;
64
65 /**Constructor that does the initialization.
66 *
67 * @see config
68 * @see functionName
69 * @see code
70 *
71 * @param Array $config An associative array containing all configuration options.
72 * @param String $functionName The name of the function to generate.
73 * Passing this argument makes only sense if the method getFunctionName
74 * does not get overwritten. This argument is optional. The default is false.
75 * @param String $code The code of the file to generate.
76 * Passing this argument makes only sense if the method getCode
77 * does not get overwritten. This argument is optional. The default is false.
78 */
79 function RSDEngineFunction($config, $functionName = false, $code = false)
80 {
81 $this->config = $config;
82 $this->functionName = $functionName;
83 $this->code = $code;
84 }
85
86 /**Returns the function name.
87 * @see functionName
88 * @return String $this->functionName is returned.
89 */
90 function getFunctionName()
91 {
92 return $this->functionName;
93 }
94
95 /**Returns the code for this function.
96 * @see code
97 * @return String $this->code is returned.
98 */
99 function getCode()
100 {
101 return $this->code;
102 }
103
104 /**Returns a new instance of RSDEngineFile.
105 * @return RSDEngineFile Contains just this function.
106 */
107 function toRSDFile()
108 {
109 return new RSDEngineFile(array(), $this->getFunctionName() . ".php", "<?php\n" . $this->getCode() . "\n?>");
110 }
111 }
112 ?>
Documentation generated on Mon, 8 Dec 2003 13:12:48 +0100 by phpDocumentor 1.2.3