1 | <?php |
||
9 | class BaseObject |
||
10 | { |
||
11 | /** |
||
12 | * Error code. If `0`, it is not an error. |
||
13 | * @var int |
||
14 | */ |
||
15 | var $error = 0; |
||
16 | |||
17 | /** |
||
18 | * Error message. If `success`, it is not an error. |
||
19 | * @var string |
||
20 | */ |
||
21 | var $message = 'success'; |
||
22 | |||
23 | /** |
||
24 | * An additional variable |
||
25 | * @var array |
||
26 | */ |
||
27 | var $variables = array(); |
||
28 | |||
29 | /** |
||
30 | * http status code. |
||
31 | * @var int |
||
32 | */ |
||
33 | var $httpStatusCode = NULL; |
||
34 | |||
35 | /** |
||
36 | * Constructor |
||
37 | * |
||
38 | * @param int $error Error code |
||
39 | * @param string $message Error message |
||
40 | * @return void |
||
|
|||
41 | */ |
||
42 | function __construct($error = 0, $message = 'success') |
||
47 | |||
48 | /** |
||
49 | * Setter to set error code |
||
50 | * |
||
51 | * @param int $error error code |
||
52 | * @return void |
||
53 | */ |
||
54 | function setError($error = 0) |
||
58 | |||
59 | /** |
||
60 | * Getter to retrieve error code |
||
61 | * |
||
62 | * @return int Returns an error code |
||
63 | */ |
||
64 | function getError() |
||
68 | |||
69 | /** |
||
70 | * Setter to set HTTP status code |
||
71 | * |
||
72 | * @param int $code HTTP status code. Default value is `200` that means successful |
||
73 | * @return void |
||
74 | */ |
||
75 | function setHttpStatusCode($code = '200') |
||
79 | |||
80 | /** |
||
81 | * Getter to retrieve HTTP status code |
||
82 | * |
||
83 | * @return int Returns HTTP status code |
||
84 | */ |
||
85 | function getHttpStatusCode() |
||
89 | |||
90 | /** |
||
91 | * Setter to set set the error message |
||
92 | * |
||
93 | * @param string $message Error message |
||
94 | * @return bool Alaways returns true. |
||
95 | */ |
||
96 | function setMessage($message = 'success', $type = NULL) |
||
110 | |||
111 | /** |
||
112 | * Getter to retrieve an error message |
||
113 | * |
||
114 | * @return string Returns message |
||
115 | */ |
||
116 | function getMessage() |
||
120 | |||
121 | /** |
||
122 | * Setter to set a key/value pair as an additional variable |
||
123 | * |
||
124 | * @param string $key A variable name |
||
125 | * @param mixed $val A value for the variable |
||
126 | * @return void |
||
127 | */ |
||
128 | function add($key, $val) |
||
132 | |||
133 | /** |
||
134 | * Method to set multiple key/value pairs as an additional variables |
||
135 | * |
||
136 | * @param BaseObject|array $object Either object or array containg key/value pairs to be added |
||
137 | * @return void |
||
138 | */ |
||
139 | function adds($object) |
||
154 | |||
155 | /** |
||
156 | * Method to retrieve a corresponding value to a given key |
||
157 | * |
||
158 | * @param string $key |
||
159 | * @return string Returns value to a given key |
||
160 | */ |
||
161 | function get($key) |
||
165 | |||
166 | /** |
||
167 | * Method to retrieve an object containing a key/value pairs |
||
168 | * |
||
169 | * @return BaseObject Returns an object containing key/value pairs |
||
170 | */ |
||
171 | function gets() |
||
181 | |||
182 | /** |
||
183 | * Method to retrieve an array of key/value pairs |
||
184 | * |
||
185 | * @return array |
||
186 | */ |
||
187 | function getVariables() |
||
191 | |||
192 | /** |
||
193 | * Method to retrieve an object of key/value pairs |
||
194 | * |
||
195 | * @return BaseObject |
||
196 | */ |
||
197 | function getObjectVars() |
||
206 | |||
207 | /** |
||
208 | * Method to return either true or false depnding on the value in a 'error' variable |
||
209 | * |
||
210 | * @return bool Retruns true : error isn't 0 or false : otherwise. |
||
211 | */ |
||
212 | function toBool() |
||
217 | |||
218 | /** |
||
219 | * Method to return either true or false depnding on the value in a 'error' variable |
||
220 | * |
||
221 | * @return bool |
||
222 | */ |
||
223 | function toBoolean() |
||
227 | |||
228 | } |
||
229 | /* End of file BaseObject.class.php */ |
||
231 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.