| Conditions | 21 |
| Paths | 21 |
| Total Lines | 37 |
| Code Lines | 31 |
| 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 |
||
| 16 | public function getDisplayMessage() |
||
| 17 | { |
||
| 18 | if(!empty($this->displayMessage)) |
||
| 19 | return $this->displayMessage; |
||
| 20 | |||
| 21 | switch($this->getCode()) |
||
| 22 | { |
||
| 23 | /* see also class.webappauthentication.php:getErrorMessage for more instances */ |
||
| 24 | |||
| 25 | case MAPI_E_NO_ACCESS: |
||
| 26 | return dgettext("zarafa","You have insufficient privileges to open this object."); |
||
| 27 | case ecUnknownUser: |
||
| 28 | case MAPI_E_LOGON_FAILED: |
||
| 29 | case MAPI_E_UNCONFIGURED: |
||
| 30 | return dgettext("zarafa","Logon Failed. Please check your name/password."); |
||
| 31 | case MAPI_E_NETWORK_ERROR: |
||
| 32 | return dgettext("zarafa","Can not connect to Gromox."); |
||
| 33 | case MAPI_E_UNKNOWN_ENTRYID: |
||
| 34 | return dgettext("zarafa","Can not open object with provided id."); |
||
| 35 | case MAPI_E_NO_RECIPIENTS: |
||
| 36 | return dgettext("zarafa","There are no recipients in the message."); |
||
| 37 | case MAPI_E_NOT_FOUND: |
||
| 38 | return dgettext("zarafa","Can not find object."); |
||
| 39 | case MAPI_E_NOT_ENOUGH_MEMORY: |
||
| 40 | return dgettext("zarafa","Operation failed: Server does not have enough memory."); |
||
| 41 | case MAPI_E_INTERFACE_NOT_SUPPORTED: |
||
| 42 | case MAPI_E_INVALID_PARAMETER: |
||
| 43 | case MAPI_E_INVALID_ENTRYID: |
||
| 44 | case MAPI_E_INVALID_OBJECT: |
||
| 45 | case MAPI_E_TOO_COMPLEX: |
||
| 46 | case MAPI_E_CORRUPT_DATA: |
||
| 47 | case MAPI_E_END_OF_SESSION: |
||
| 48 | case MAPI_E_AMBIGUOUS_RECIP: |
||
| 49 | case MAPI_E_COLLISION: |
||
| 50 | case MAPI_E_UNCONFIGURED: |
||
| 51 | default : |
||
| 52 | return sprintf(dgettext("zarafa","Unknown MAPI Error: %s"), get_mapi_error_name($this->getCode())); |
||
| 53 | } |
||
| 62 |
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.