Conditions | 77 |
Paths | 77 |
Total Lines | 155 |
Code Lines | 78 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
212 | function mapi_strerror($e) { |
||
213 | switch ($e) { |
||
214 | case S_OK: return "success"; |
||
215 | |||
216 | case MAPI_E_CALL_FAILED: return "An error of unexpected or unknown origin occurred"; |
||
217 | |||
218 | case MAPI_E_NOT_ENOUGH_MEMORY: return "Not enough memory was available to complete the operation"; |
||
219 | |||
220 | case MAPI_E_INVALID_PARAMETER: return "An invalid parameter was passed to a function or remote procedure call"; |
||
221 | |||
222 | case MAPI_E_INTERFACE_NOT_SUPPORTED: return "MAPI interface not supported"; |
||
223 | |||
224 | case MAPI_E_NO_ACCESS: return "An attempt was made to access a message store or object for which the user has insufficient permissions"; |
||
225 | |||
226 | case MAPI_E_NO_SUPPORT: return "Function is not implemented"; |
||
227 | |||
228 | case MAPI_E_BAD_CHARWIDTH: return "An incompatibility exists in the character sets supported by the caller and the implementation"; |
||
229 | |||
230 | case MAPI_E_STRING_TOO_LONG: return "In the context of this method call, a string exceeds the maximum permitted length"; |
||
231 | |||
232 | case MAPI_E_UNKNOWN_FLAGS: return "One or more values for a flags parameter were not valid"; |
||
233 | |||
234 | case MAPI_E_INVALID_ENTRYID: return "invalid entryid"; |
||
235 | |||
236 | case MAPI_E_INVALID_OBJECT: return "A method call was made using a reference to an object that has been destroyed or is not in a viable state"; |
||
237 | |||
238 | case MAPI_E_OBJECT_CHANGED: return "An attempt to commit changes failed because the object was changed separately"; |
||
239 | |||
240 | case MAPI_E_OBJECT_DELETED: return "An operation failed because the object was deleted separately"; |
||
241 | |||
242 | case MAPI_E_BUSY: return "A table operation failed because a separate operation was in progress at the same time"; |
||
243 | |||
244 | case MAPI_E_NOT_ENOUGH_DISK: return "Not enough disk space was available to complete the operation"; |
||
245 | |||
246 | case MAPI_E_NOT_ENOUGH_RESOURCES: return "Not enough system resources were available to complete the operation"; |
||
247 | |||
248 | case MAPI_E_NOT_FOUND: return "The requested object could not be found at the server"; |
||
249 | |||
250 | case MAPI_E_VERSION: return "Client and server versions are not compatible"; |
||
251 | |||
252 | case MAPI_E_LOGON_FAILED: return "A client was unable to log on to the server"; |
||
253 | |||
254 | case MAPI_E_SESSION_LIMIT: return "A server or service is unable to create any more sessions"; |
||
255 | |||
256 | case MAPI_E_USER_CANCEL: return "An operation failed because a user cancelled it"; |
||
257 | |||
258 | case MAPI_E_UNABLE_TO_ABORT: return "A ropAbort or ropAbortSubmit ROP request was unsuccessful"; |
||
259 | |||
260 | case MAPI_E_NETWORK_ERROR: return "An operation was unsuccessful because of a problem with network operations or services"; |
||
261 | |||
262 | case MAPI_E_DISK_ERROR: return "There was a problem writing to or reading from disk"; |
||
263 | |||
264 | case MAPI_E_TOO_COMPLEX: return "The operation requested is too complex for the server to handle (often w.r.t. restrictions)"; |
||
265 | |||
266 | case MAPI_E_BAD_COLUMN: return "The column requested is not allowed in this type of table"; |
||
267 | |||
268 | case MAPI_E_EXTENDED_ERROR: return "extended error"; |
||
269 | |||
270 | case MAPI_E_COMPUTED: return "A property cannot be updated because it is read-only, computed by the server"; |
||
271 | |||
272 | case MAPI_E_CORRUPT_DATA: return "There is an internal inconsistency in a database, or in a complex property value"; |
||
273 | |||
274 | case MAPI_E_UNCONFIGURED: return "unconfigured"; |
||
275 | |||
276 | case MAPI_E_FAILONEPROVIDER: return "failoneprovider"; |
||
277 | |||
278 | case MAPI_E_UNKNOWN_CPID: return "The server is not configured to support the code page requested by the client"; |
||
279 | |||
280 | case MAPI_E_UNKNOWN_LCID: return "The server is not configured to support the locale requested by the client"; |
||
281 | |||
282 | case MAPI_E_PASSWORD_CHANGE_REQUIRED: return "password change required"; |
||
283 | |||
284 | case MAPI_E_PASSWORD_EXPIRED: return "password expired"; |
||
285 | |||
286 | case MAPI_E_INVALID_WORKSTATION_ACCOUNT: return "invalid workstation account"; |
||
287 | |||
288 | case MAPI_E_INVALID_ACCESS_TIME: return "The operation failed due to clock skew between servers"; |
||
289 | |||
290 | case MAPI_E_ACCOUNT_DISABLED: return "account disabled"; |
||
291 | |||
292 | case MAPI_E_END_OF_SESSION: return "The server session has been destroyed, possibly by a server restart"; |
||
293 | |||
294 | case MAPI_E_UNKNOWN_ENTRYID: return "The EntryID passed to OpenEntry was created by a different MAPI provider"; |
||
295 | |||
296 | case MAPI_E_MISSING_REQUIRED_COLUMN: return "missing required column"; |
||
297 | |||
298 | case MAPI_W_NO_SERVICE: return "no service"; |
||
299 | |||
300 | case MAPI_E_BAD_VALUE: return "bad value"; |
||
301 | |||
302 | case MAPI_E_INVALID_TYPE: return "invalid type"; |
||
303 | |||
304 | case MAPI_E_TYPE_NO_SUPPORT: return "type no support"; |
||
305 | |||
306 | case MAPI_E_UNEXPECTED_TYPE: return "unexpected_type"; |
||
307 | |||
308 | case MAPI_E_TOO_BIG: return "The table is too big for the requested operation to complete"; |
||
309 | |||
310 | case MAPI_E_DECLINE_COPY: return "The provider implements this method by calling a support object method, and the caller has passed the MAPI_DECLINE_OK flag"; |
||
311 | |||
312 | case MAPI_E_UNEXPECTED_ID: return "unexpected id"; |
||
313 | |||
314 | case MAPI_W_ERRORS_RETURNED: return "The call succeeded, but the message store provider has error information available"; |
||
315 | |||
316 | case MAPI_E_UNABLE_TO_COMPLETE: return "A complex operation such as building a table row set could not be completed"; |
||
317 | |||
318 | case MAPI_E_TIMEOUT: return "An asynchronous operation did not succeed within the specified time-out"; |
||
319 | |||
320 | case MAPI_E_TABLE_EMPTY: return "A table essential to the operation is empty"; |
||
321 | |||
322 | case MAPI_E_TABLE_TOO_BIG: return "The table is too big for the requested operation to complete"; |
||
323 | |||
324 | case MAPI_E_INVALID_BOOKMARK: return "The bookmark passed to a table operation was not created on the same table"; |
||
325 | |||
326 | case MAPI_W_POSITION_CHANGED: return "position changed"; |
||
327 | |||
328 | case MAPI_W_APPROX_COUNT: return "approx count"; |
||
329 | |||
330 | case MAPI_E_WAIT: return "A wait time-out has expired"; |
||
331 | |||
332 | case MAPI_E_CANCEL: return "The operation had to be canceled"; |
||
333 | |||
334 | case MAPI_E_NOT_ME: return "not me"; |
||
335 | |||
336 | case MAPI_W_CANCEL_MESSAGE: return "cancel message"; |
||
337 | |||
338 | case MAPI_E_CORRUPT_STORE: return "corrupt store"; |
||
339 | |||
340 | case MAPI_E_NOT_IN_QUEUE: return "not in queue"; |
||
341 | |||
342 | case MAPI_E_NO_SUPPRESS: return "The server does not support the suppression of read receipts"; |
||
343 | |||
344 | case MAPI_E_COLLISION: return "A folder or item cannot be created because one with the same name or other criteria already exists"; |
||
345 | |||
346 | case MAPI_E_NOT_INITIALIZED: return "The subsystem is not ready"; |
||
347 | |||
348 | case MAPI_E_NON_STANDARD: return "non standard"; |
||
349 | |||
350 | case MAPI_E_NO_RECIPIENTS: return "A message cannot be sent because it has no recipients"; |
||
351 | |||
352 | case MAPI_E_SUBMITTED: return "A message cannot be opened for modification because it has already been sent"; |
||
353 | |||
354 | case MAPI_E_HAS_FOLDERS: return "A folder cannot be deleted because it still contains subfolders"; |
||
355 | |||
356 | case MAPI_E_HAS_MESSAGES: return "A folder cannot be deleted because it still contains messages"; |
||
357 | |||
358 | case MAPI_E_FOLDER_CYCLE: return "A folder move or copy operation would create a cycle"; |
||
359 | |||
360 | case MAPI_W_PARTIAL_COMPLETION: return "The call succeeded, but not all entries were successfully operated on"; |
||
361 | |||
362 | case MAPI_E_AMBIGUOUS_RECIP: return "An unresolved recipient matches more than one directory entry"; |
||
363 | |||
364 | case MAPI_E_STORE_FULL: return "Store full"; |
||
365 | |||
366 | default: return sprintf("%xh", $e); |
||
367 | } |
||
369 |