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