Conditions | 1 |
Paths | 1 |
Total Lines | 55 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
13 | function ideas_init() { |
||
14 | |||
15 | $root = dirname(__FILE__); |
||
16 | elgg_register_library('ideas:utilities', "$root/lib/utilities.php"); |
||
17 | |||
18 | // actions |
||
19 | $action_base = "$root/actions/ideas"; |
||
20 | elgg_register_action('ideas/saveidea', "$action_base/saveidea.php"); |
||
21 | elgg_register_action('ideas/editidea', "$action_base/editidea.php"); |
||
22 | elgg_register_action("ideas/rateidea", "$action_base/rateidea.php"); |
||
23 | elgg_register_action('ideas/delete', "$action_base/deleteidea.php"); |
||
24 | elgg_register_action('ideas/settings', "$action_base/settings.php"); |
||
25 | |||
26 | elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'ideas_owner_block_menu'); |
||
27 | |||
28 | elgg_register_page_handler('ideas', 'ideas_page_handler'); |
||
29 | |||
30 | // Extend view |
||
31 | elgg_extend_view('css/elgg', 'ideas/css'); |
||
32 | elgg_extend_view('js/elgg', 'ideas/js'); |
||
33 | |||
34 | // Register widgets |
||
35 | elgg_register_widget_type( |
||
36 | 'ideas', |
||
37 | elgg_echo('ideas:widget:title'), |
||
38 | elgg_echo('ideas:widget:description') |
||
39 | ); |
||
40 | /* |
||
41 | elgg_register_widget_type( |
||
42 | 'points_left', |
||
43 | elgg_echo('ideas:widget:points_left:title'), |
||
44 | elgg_echo('ideas:widget:points_left:description'), |
||
45 | 'dashboard' |
||
46 | ); |
||
47 | */ |
||
48 | |||
49 | // Register granular notification for this type |
||
50 | register_notification_object('object', 'ideas', elgg_echo('ideas:new')); |
||
51 | |||
52 | // Listen to notification events and supply a more useful message |
||
53 | elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'ideas_notify_message'); |
||
54 | |||
55 | // Register a URL handler for ideas |
||
56 | elgg_register_entity_url_handler('object', 'idea', 'idea_url'); |
||
57 | |||
58 | // Register entity type for search |
||
59 | elgg_register_entity_type('object', 'idea'); |
||
60 | |||
61 | // Temporary disable notifications REMOVE THIS BEFORE SENDING TO PROD |
||
62 | // elgg_register_plugin_hook_handler('email', 'system', 'ideas_mailer'); |
||
63 | |||
64 | // Groups |
||
65 | add_group_tool_option('ideas', elgg_echo('ideas:enableideas'), true); |
||
66 | elgg_extend_view('groups/tool_latest', 'ideas/group_module'); |
||
67 | } |
||
68 | |||
220 |
The break statement is not necessary if it is preceded for example by a return statement:
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.