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