| Conditions | 77 |
| Paths | 77 |
| Total Lines | 80 |
| 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 |
||
| 207 | function mapi_strerror($e) |
||
| 208 | { |
||
| 209 | switch ($e) { |
||
| 210 | case S_OK: return "success"; |
||
| 211 | case MAPI_E_CALL_FAILED: return "An error of unexpected or unknown origin occurred"; |
||
| 212 | case MAPI_E_NOT_ENOUGH_MEMORY: return "Not enough memory was available to complete the operation"; |
||
| 213 | case MAPI_E_INVALID_PARAMETER: return "An invalid parameter was passed to a function or remote procedure call"; |
||
| 214 | case MAPI_E_INTERFACE_NOT_SUPPORTED: return "MAPI interface not supported"; |
||
| 215 | case MAPI_E_NO_ACCESS: return "An attempt was made to access a message store or object for which the user has insufficient permissions"; |
||
| 216 | case MAPI_E_NO_SUPPORT: return "Function is not implemented"; |
||
| 217 | case MAPI_E_BAD_CHARWIDTH: return "An incompatibility exists in the character sets supported by the caller and the implementation"; |
||
| 218 | case MAPI_E_STRING_TOO_LONG: return "In the context of this method call, a string exceeds the maximum permitted length"; |
||
| 219 | case MAPI_E_UNKNOWN_FLAGS: return "One or more values for a flags parameter were not valid"; |
||
| 220 | case MAPI_E_INVALID_ENTRYID: return "invalid entryid"; |
||
| 221 | 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"; |
||
| 222 | case MAPI_E_OBJECT_CHANGED: return "An attempt to commit changes failed because the object was changed separately"; |
||
| 223 | case MAPI_E_OBJECT_DELETED: return "An operation failed because the object was deleted separately"; |
||
| 224 | case MAPI_E_BUSY: return "A table operation failed because a separate operation was in progress at the same time"; |
||
| 225 | case MAPI_E_NOT_ENOUGH_DISK: return "Not enough disk space was available to complete the operation"; |
||
| 226 | case MAPI_E_NOT_ENOUGH_RESOURCES: return "Not enough system resources were available to complete the operation"; |
||
| 227 | case MAPI_E_NOT_FOUND: return "The requested object could not be found at the server"; |
||
| 228 | case MAPI_E_VERSION: return "Client and server versions are not compatible"; |
||
| 229 | case MAPI_E_LOGON_FAILED: return "A client was unable to log on to the server"; |
||
| 230 | case MAPI_E_SESSION_LIMIT: return "A server or service is unable to create any more sessions"; |
||
| 231 | case MAPI_E_USER_CANCEL: return "An operation failed because a user cancelled it"; |
||
| 232 | case MAPI_E_UNABLE_TO_ABORT: return "A ropAbort or ropAbortSubmit ROP request was unsuccessful"; |
||
| 233 | case MAPI_E_NETWORK_ERROR: return "An operation was unsuccessful because of a problem with network operations or services"; |
||
| 234 | case MAPI_E_DISK_ERROR: return "There was a problem writing to or reading from disk"; |
||
| 235 | case MAPI_E_TOO_COMPLEX: return "The operation requested is too complex for the server to handle (often w.r.t. restrictions)"; |
||
| 236 | case MAPI_E_BAD_COLUMN: return "The column requested is not allowed in this type of table"; |
||
| 237 | case MAPI_E_EXTENDED_ERROR: return "extended error"; |
||
| 238 | case MAPI_E_COMPUTED: return "A property cannot be updated because it is read-only, computed by the server"; |
||
| 239 | case MAPI_E_CORRUPT_DATA: return "There is an internal inconsistency in a database, or in a complex property value"; |
||
| 240 | case MAPI_E_UNCONFIGURED: return "unconfigured"; |
||
| 241 | case MAPI_E_FAILONEPROVIDER: return "failoneprovider"; |
||
| 242 | case MAPI_E_UNKNOWN_CPID: return "The server is not configured to support the code page requested by the client"; |
||
| 243 | case MAPI_E_UNKNOWN_LCID: return "The server is not configured to support the locale requested by the client"; |
||
| 244 | case MAPI_E_PASSWORD_CHANGE_REQUIRED: return "password change required"; |
||
| 245 | case MAPI_E_PASSWORD_EXPIRED: return "password expired"; |
||
| 246 | case MAPI_E_INVALID_WORKSTATION_ACCOUNT: return "invalid workstation account"; |
||
| 247 | case MAPI_E_INVALID_ACCESS_TIME: return "The operation failed due to clock skew between servers"; |
||
| 248 | case MAPI_E_ACCOUNT_DISABLED: return "account disabled"; |
||
| 249 | case MAPI_E_END_OF_SESSION: return "The server session has been destroyed, possibly by a server restart"; |
||
| 250 | case MAPI_E_UNKNOWN_ENTRYID: return "The EntryID passed to OpenEntry was created by a different MAPI provider"; |
||
| 251 | case MAPI_E_MISSING_REQUIRED_COLUMN: return "missing required column"; |
||
| 252 | case MAPI_W_NO_SERVICE: return "no service"; |
||
| 253 | case MAPI_E_BAD_VALUE: return "bad value"; |
||
| 254 | case MAPI_E_INVALID_TYPE: return "invalid type"; |
||
| 255 | case MAPI_E_TYPE_NO_SUPPORT: return "type no support"; |
||
| 256 | case MAPI_E_UNEXPECTED_TYPE: return "unexpected_type"; |
||
| 257 | case MAPI_E_TOO_BIG: return "The table is too big for the requested operation to complete"; |
||
| 258 | 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"; |
||
| 259 | case MAPI_E_UNEXPECTED_ID: return "unexpected id"; |
||
| 260 | case MAPI_W_ERRORS_RETURNED: return "The call succeeded, but the message store provider has error information available"; |
||
| 261 | case MAPI_E_UNABLE_TO_COMPLETE: return "A complex operation such as building a table row set could not be completed"; |
||
| 262 | case MAPI_E_TIMEOUT: return "An asynchronous operation did not succeed within the specified time-out"; |
||
| 263 | case MAPI_E_TABLE_EMPTY: return "A table essential to the operation is empty"; |
||
| 264 | case MAPI_E_TABLE_TOO_BIG: return "The table is too big for the requested operation to complete"; |
||
| 265 | case MAPI_E_INVALID_BOOKMARK: return "The bookmark passed to a table operation was not created on the same table"; |
||
| 266 | case MAPI_W_POSITION_CHANGED: return "position changed"; |
||
| 267 | case MAPI_W_APPROX_COUNT: return "approx count"; |
||
| 268 | case MAPI_E_WAIT: return "A wait time-out has expired"; |
||
| 269 | case MAPI_E_CANCEL: return "The operation had to be canceled"; |
||
| 270 | case MAPI_E_NOT_ME: return "not me"; |
||
| 271 | case MAPI_W_CANCEL_MESSAGE: return "cancel message"; |
||
| 272 | case MAPI_E_CORRUPT_STORE: return "corrupt store"; |
||
| 273 | case MAPI_E_NOT_IN_QUEUE: return "not in queue"; |
||
| 274 | case MAPI_E_NO_SUPPRESS: return "The server does not support the suppression of read receipts"; |
||
| 275 | case MAPI_E_COLLISION: return "A folder or item cannot be created because one with the same name or other criteria already exists"; |
||
| 276 | case MAPI_E_NOT_INITIALIZED: return "The subsystem is not ready"; |
||
| 277 | case MAPI_E_NON_STANDARD: return "non standard"; |
||
| 278 | case MAPI_E_NO_RECIPIENTS: return "A message cannot be sent because it has no recipients"; |
||
| 279 | case MAPI_E_SUBMITTED: return "A message cannot be opened for modification because it has already been sent"; |
||
| 280 | case MAPI_E_HAS_FOLDERS: return "A folder cannot be deleted because it still contains subfolders"; |
||
| 281 | case MAPI_E_HAS_MESSAGES: return "A folder cannot be deleted because it still contains messages"; |
||
| 282 | case MAPI_E_FOLDER_CYCLE: return "A folder move or copy operation would create a cycle"; |
||
| 283 | case MAPI_W_PARTIAL_COMPLETION: return "The call succeeded, but not all entries were successfully operated on"; |
||
| 284 | case MAPI_E_AMBIGUOUS_RECIP: return "An unresolved recipient matches more than one directory entry"; |
||
| 285 | case MAPI_E_STORE_FULL: return "Store full"; |
||
| 286 | default: return sprintf("%xh", $e); |
||
| 287 | } |
||
| 292 |
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.