1 | <?php |
||
14 | class XEObject |
||
15 | { |
||
16 | |||
17 | /** |
||
18 | * Error code. If `0`, it is not an error. |
||
19 | * @var int |
||
20 | */ |
||
21 | var $error = 0; |
||
22 | |||
23 | /** |
||
24 | * Error message. If `success`, it is not an error. |
||
25 | * @var string |
||
26 | */ |
||
27 | var $message = 'success'; |
||
28 | |||
29 | /** |
||
30 | * An additional variable |
||
31 | * @var array |
||
32 | */ |
||
33 | var $variables = array(); |
||
34 | |||
35 | /** |
||
36 | * http status code. |
||
37 | * @var int |
||
38 | */ |
||
39 | var $httpStatusCode = NULL; |
||
40 | |||
41 | /** |
||
42 | * Constructor |
||
43 | * |
||
44 | * @param int $error Error code |
||
45 | * @param string $message Error message |
||
46 | * @return void |
||
|
|||
47 | */ |
||
48 | function __construct($error = 0, $message = 'success') |
||
53 | |||
54 | /** |
||
55 | * Setter to set error code |
||
56 | * |
||
57 | * @param int $error error code |
||
58 | * @return void |
||
59 | */ |
||
60 | function setError($error = 0) |
||
64 | |||
65 | /** |
||
66 | * Getter to retrieve error code |
||
67 | * |
||
68 | * @return int Returns an error code |
||
69 | */ |
||
70 | function getError() |
||
74 | |||
75 | /** |
||
76 | * Setter to set HTTP status code |
||
77 | * |
||
78 | * @param int $code HTTP status code. Default value is `200` that means successful |
||
79 | * @return void |
||
80 | */ |
||
81 | function setHttpStatusCode($code = '200') |
||
85 | |||
86 | /** |
||
87 | * Getter to retrieve HTTP status code |
||
88 | * |
||
89 | * @return int Returns HTTP status code |
||
90 | */ |
||
91 | function getHttpStatusCode() |
||
95 | |||
96 | /** |
||
97 | * Setter to set set the error message |
||
98 | * |
||
99 | * @param string $message Error message |
||
100 | * @return bool Alaways returns true. |
||
101 | */ |
||
102 | function setMessage($message = 'success', $type = NULL) |
||
116 | |||
117 | /** |
||
118 | * Getter to retrieve an error message |
||
119 | * |
||
120 | * @return string Returns message |
||
121 | */ |
||
122 | function getMessage() |
||
126 | |||
127 | /** |
||
128 | * Setter to set a key/value pair as an additional variable |
||
129 | * |
||
130 | * @param string $key A variable name |
||
131 | * @param mixed $val A value for the variable |
||
132 | * @return void |
||
133 | */ |
||
134 | function add($key, $val) |
||
138 | |||
139 | /** |
||
140 | * Method to set multiple key/value pairs as an additional variables |
||
141 | * |
||
142 | * @param Object|array $object Either object or array containg key/value pairs to be added |
||
143 | * @return void |
||
144 | */ |
||
145 | function adds($object) |
||
160 | |||
161 | /** |
||
162 | * Method to retrieve a corresponding value to a given key |
||
163 | * |
||
164 | * @param string $key |
||
165 | * @return string Returns value to a given key |
||
166 | */ |
||
167 | function get($key) |
||
171 | |||
172 | /** |
||
173 | * Method to retrieve an object containing a key/value pairs |
||
174 | * |
||
175 | * @return Object Returns an object containing key/value pairs |
||
176 | */ |
||
177 | function gets() |
||
187 | |||
188 | /** |
||
189 | * Method to retrieve an array of key/value pairs |
||
190 | * |
||
191 | * @return array |
||
192 | */ |
||
193 | function getVariables() |
||
197 | |||
198 | /** |
||
199 | * Method to retrieve an object of key/value pairs |
||
200 | * |
||
201 | * @return Object |
||
202 | */ |
||
203 | function getObjectVars() |
||
212 | |||
213 | /** |
||
214 | * Method to return either true or false depnding on the value in a 'error' variable |
||
215 | * |
||
216 | * @return bool Retruns true : error isn't 0 or false : otherwise. |
||
217 | */ |
||
218 | function toBool() |
||
223 | |||
224 | /** |
||
225 | * Method to return either true or false depnding on the value in a 'error' variable |
||
226 | * |
||
227 | * @return bool |
||
228 | */ |
||
229 | function toBoolean() |
||
233 | |||
234 | } |
||
235 | |||
243 |
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.