Conditions | 1 |
Paths | 1 |
Total Lines | 65 |
Code Lines | 54 |
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 |
||
28 | function opcache_menu() { |
||
29 | $items = array( |
||
30 | 'opcache/%/%/reset/%' => array( |
||
31 | 'type' => MENU_CALLBACK, |
||
32 | 'access callback' => 'opcache_router_access', |
||
33 | 'access arguments' => array(1, 2), |
||
34 | 'page callback' => 'opcache_router', |
||
35 | 'page arguments' => array(3, 4), |
||
36 | ), |
||
37 | 'opcache/%/%/invalidate/%' => array( |
||
38 | 'type' => MENU_CALLBACK, |
||
39 | 'access callback' => 'opcache_router_access', |
||
40 | 'access arguments' => array(1 ,2), |
||
41 | 'page callback' => 'opcache_router', |
||
42 | 'page arguments' => array(3, 4), |
||
43 | ), |
||
44 | 'opcache/%/%/status' => array( |
||
45 | 'type' => MENU_CALLBACK, |
||
46 | 'access callback' => 'opcache_router_access', |
||
47 | 'access arguments' => array(1, 2), |
||
48 | 'page callback' => 'opcache_router', |
||
49 | 'page arguments' => array(3), |
||
50 | ), |
||
51 | 'admin/config/development/performance/opcache' => array( |
||
52 | 'type' => MENU_LOCAL_TASK, |
||
53 | 'title' => 'OPcache', |
||
54 | 'page callback' => 'drupal_get_form', |
||
55 | 'page arguments' => array('opcache_admin_form'), |
||
56 | 'access arguments' => array('administer site configuration'), |
||
57 | 'file' => 'opcache.admin.inc', |
||
58 | 'weight' => 10, |
||
59 | ), |
||
60 | 'admin/config/development/performance/opcache/backends' => array( |
||
61 | 'title' => 'Backends', |
||
62 | 'type' => MENU_DEFAULT_LOCAL_TASK, |
||
63 | 'weight' => -10, |
||
64 | ), |
||
65 | 'admin/config/development/performance/opcache/status' => array( |
||
66 | 'title' => 'Status', |
||
67 | 'type' => MENU_LOCAL_TASK, |
||
68 | 'page callback' => 'opcache_admin_status', |
||
69 | 'access arguments' => array('administer site configuration'), |
||
70 | 'file' => 'opcache.admin.inc', |
||
71 | 'weight' => 0, |
||
72 | ), |
||
73 | 'admin/config/development/performance/opcache/configuration' => array( |
||
74 | 'title' => 'Configuration', |
||
75 | 'type' => MENU_LOCAL_TASK, |
||
76 | 'page callback' => 'opcache_admin_config', |
||
77 | 'access arguments' => array('administer site configuration'), |
||
78 | 'file' => 'opcache.admin.inc', |
||
79 | 'weight' => 1, |
||
80 | ), |
||
81 | 'admin/config/development/performance/opcache/scripts' => array( |
||
82 | 'title' => 'Scripts', |
||
83 | 'type' => MENU_LOCAL_TASK, |
||
84 | 'page callback' => 'opcache_admin_scripts', |
||
85 | 'access arguments' => array('administer site configuration'), |
||
86 | 'file' => 'opcache.admin.inc', |
||
87 | 'weight' => 0, |
||
88 | ), |
||
89 | ); |
||
90 | |||
91 | return $items; |
||
92 | } |
||
93 | |||
126 |
If an expression can have both
false
, andnull
as possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.