Conditions | 1 |
Paths | 1 |
Total Lines | 62 |
Code Lines | 46 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
10 | protected function getMessages(): array |
||
11 | { |
||
12 | return [ |
||
13 | 'invalid_request' => __( |
||
14 | 'invalid_request', |
||
15 | 'Invalid request. Please try again.' |
||
16 | ), |
||
17 | 'validation_failed' => __( |
||
18 | 'validation_failed', |
||
19 | 'Data validation failed. Please check your input.' |
||
20 | ), |
||
21 | 'upload_success' => __( |
||
22 | 'upload_success', |
||
23 | 'The file has been successfully uploaded. Input description and Insert.</a>.' |
||
24 | ), |
||
25 | 'upload_error' => __( |
||
26 | 'upload_error', |
||
27 | 'The file could not be uploaded. Please try again.' |
||
28 | ), |
||
29 | 'database_update_failed' => __( |
||
30 | 'database_update_failed', |
||
31 | 'Failed to update the database. Please try again.' |
||
32 | ), |
||
33 | 'file_missing' => __( |
||
34 | 'file_missing', |
||
35 | 'No file uploaded or the file is corrupted.' |
||
36 | ), |
||
37 | 'method_not_allowed' => __( |
||
38 | 'method_not_allowed', |
||
39 | 'Method not allowed.' |
||
40 | ), |
||
41 | 'file_not_found' => __( |
||
42 | 'file_not_found', |
||
43 | 'File not found.' |
||
44 | ), |
||
45 | 'update_success' => __( |
||
46 | 'update_success', |
||
47 | 'Your file has been successfully uploaded. You can now insert it into your post or add a description in the <a href="#" class="link-primary" id="switchToViewTab">Files List</a>.' |
||
48 | ), |
||
49 | 'update_failed' => __( |
||
50 | 'update_failed', |
||
51 | 'Failed to update the database. Please try again.' |
||
52 | ), |
||
53 | 'file_id_required' => __( |
||
54 | 'file_id_required', |
||
55 | 'File ID is required.' |
||
56 | ), |
||
57 | 'file_delete_failed' => __( |
||
58 | 'file_delete_failed', |
||
59 | 'Failed to delete the file.' |
||
60 | ), |
||
61 | 'db_update_failed' => __( |
||
62 | 'db_update_failed', |
||
63 | 'Failed to update the database.' |
||
64 | ), |
||
65 | 'file_delete_success' => __( |
||
66 | 'file_delete_success', |
||
67 | 'File has been deleted successfully.' |
||
68 | ), |
||
69 | 'unexpected_error' => __( |
||
70 | 'unexpected_error', |
||
71 | 'An unexpected error occurred. Please try again later.' |
||
72 | ), |
||
119 |