| Conditions | 1 |
| Paths | 1 |
| Total Lines | 271 |
| 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 |
||
| 145 | function get_submenu_fixture() { |
||
| 146 | return array( |
||
| 147 | 'index.php' => array( |
||
| 148 | 0 => array( |
||
| 149 | 'Home', |
||
| 150 | 'read', |
||
| 151 | 'index.php', |
||
| 152 | ), |
||
| 153 | 10 => array( |
||
| 154 | 'Updates <span class="update-plugins count-4"><span class="update-count">4</span></span>', |
||
| 155 | 'update_core', |
||
| 156 | 'update-core.php', |
||
| 157 | ), |
||
| 158 | ), |
||
| 159 | 'upload.php' => array( |
||
| 160 | 5 => array( |
||
| 161 | 'Library', |
||
| 162 | 'upload_files', |
||
| 163 | 'upload.php', |
||
| 164 | ), |
||
| 165 | 10 => array( |
||
| 166 | 'Add New', |
||
| 167 | 'upload_files', |
||
| 168 | 'media-new.php', |
||
| 169 | ), |
||
| 170 | ), |
||
| 171 | 'edit-comments.php' => array( |
||
| 172 | 0 => array( |
||
| 173 | 'All Comments', |
||
| 174 | 'edit_posts', |
||
| 175 | 'edit-comments.php', |
||
| 176 | ), |
||
| 177 | ), |
||
| 178 | 'edit.php' => array( |
||
| 179 | 5 => array( |
||
| 180 | 'All Posts', |
||
| 181 | 'edit_posts', |
||
| 182 | 'edit.php', |
||
| 183 | ), |
||
| 184 | 10 => array( |
||
| 185 | 'Add New', |
||
| 186 | 'edit_posts', |
||
| 187 | 'post-new.php', |
||
| 188 | ), |
||
| 189 | 15 => array( |
||
| 190 | 'Categories', |
||
| 191 | 'manage_categories', |
||
| 192 | 'edit-tags.php?taxonomy=category', |
||
| 193 | ), |
||
| 194 | 16 => array( |
||
| 195 | 'Tags', |
||
| 196 | 'manage_post_tags', |
||
| 197 | 'edit-tags.php?taxonomy=post_tag', |
||
| 198 | ), |
||
| 199 | ), |
||
| 200 | 'edit.php?post_type=page' => array( |
||
| 201 | 5 => array( |
||
| 202 | 'All Pages', |
||
| 203 | 'edit_pages', |
||
| 204 | 'edit.php?post_type=page', |
||
| 205 | ), |
||
| 206 | 10 => array( |
||
| 207 | 'Add New', |
||
| 208 | 'edit_pages', |
||
| 209 | 'post-new.php?post_type=page', |
||
| 210 | ), |
||
| 211 | ), |
||
| 212 | 'themes.php' => array( |
||
| 213 | 5 => array( |
||
| 214 | 'Themes', |
||
| 215 | 'switch_themes', |
||
| 216 | 'themes.php', |
||
| 217 | ), |
||
| 218 | 6 => array( |
||
| 219 | 'Customize', |
||
| 220 | 'customize', |
||
| 221 | 'customize.php?return=%2Ftrunk%2Fwp-admin%2Fadmin.php%3Fpage%3Djetpack', |
||
| 222 | '', |
||
| 223 | 'hide-if-no-customize', |
||
| 224 | ), |
||
| 225 | 10 => array( |
||
| 226 | 'Menus', |
||
| 227 | 'edit_theme_options', |
||
| 228 | 'nav-menus.php', |
||
| 229 | ), |
||
| 230 | 11 => array( |
||
| 231 | 'Widgets', |
||
| 232 | 'edit_theme_options', |
||
| 233 | 'gutenberg-widgets', |
||
| 234 | 'Widgets', |
||
| 235 | ), |
||
| 236 | 13 => array( |
||
| 237 | 'Theme Editor', |
||
| 238 | 'edit_themes', |
||
| 239 | 'theme-editor.php', |
||
| 240 | 'Theme Editor', |
||
| 241 | ), |
||
| 242 | ), |
||
| 243 | 'plugins.php' => array( |
||
| 244 | 5 => array( |
||
| 245 | 'Installed Plugins', |
||
| 246 | 'activate_plugins', |
||
| 247 | 'plugins.php', |
||
| 248 | ), |
||
| 249 | 10 => array( |
||
| 250 | 'Add New', |
||
| 251 | 'install_plugins', |
||
| 252 | 'plugin-install.php', |
||
| 253 | ), |
||
| 254 | 15 => array( |
||
| 255 | 'Plugin Editor', |
||
| 256 | 'edit_plugins', |
||
| 257 | 'plugin-editor.php', |
||
| 258 | ), |
||
| 259 | ), |
||
| 260 | 'users.php' => array( |
||
| 261 | 5 => array( |
||
| 262 | 'All Users', |
||
| 263 | 'list_users', |
||
| 264 | 'users.php', |
||
| 265 | ), |
||
| 266 | 10 => array( |
||
| 267 | 'Add New', |
||
| 268 | 'create_users', |
||
| 269 | 'user-new.php', |
||
| 270 | ), |
||
| 271 | 15 => array( |
||
| 272 | 'Profile', |
||
| 273 | 'read', |
||
| 274 | 'profile.php', |
||
| 275 | ), |
||
| 276 | ), |
||
| 277 | 'tools.php' => array( |
||
| 278 | 5 => array( |
||
| 279 | 'Available Tools', |
||
| 280 | 'edit_posts', |
||
| 281 | 'tools.php', |
||
| 282 | ), |
||
| 283 | 10 => array( |
||
| 284 | 'Import', |
||
| 285 | 'import', |
||
| 286 | 'import.php', |
||
| 287 | ), |
||
| 288 | 15 => array( |
||
| 289 | 'Export', |
||
| 290 | 'export', |
||
| 291 | 'export.php', |
||
| 292 | ), |
||
| 293 | 20 => array( |
||
| 294 | 'Site Health', |
||
| 295 | 'view_site_health_checks', |
||
| 296 | 'site-health.php', |
||
| 297 | ), |
||
| 298 | 25 => array( |
||
| 299 | 'Export Personal Data', |
||
| 300 | 'export_others_personal_data', |
||
| 301 | 'export-personal-data.php', |
||
| 302 | ), |
||
| 303 | 30 => array( |
||
| 304 | 'Erase Personal Data', |
||
| 305 | 'erase_others_personal_data', |
||
| 306 | 'erase-personal-data.php', |
||
| 307 | ), |
||
| 308 | ), |
||
| 309 | 'options-general.php' => array( |
||
| 310 | 10 => array( |
||
| 311 | 'General', |
||
| 312 | 'manage_options', |
||
| 313 | 'options-general.php', |
||
| 314 | ), |
||
| 315 | 15 => array( |
||
| 316 | 'Writing', |
||
| 317 | 'manage_options', |
||
| 318 | 'options-writing.php', |
||
| 319 | ), |
||
| 320 | 20 => array( |
||
| 321 | 'Reading', |
||
| 322 | 'manage_options', |
||
| 323 | 'options-reading.php', |
||
| 324 | ), |
||
| 325 | 25 => array( |
||
| 326 | 'Discussion', |
||
| 327 | 'manage_options', |
||
| 328 | 'options-discussion.php', |
||
| 329 | ), |
||
| 330 | 30 => array( |
||
| 331 | 'Media', |
||
| 332 | 'manage_options', |
||
| 333 | 'options-media.php', |
||
| 334 | ), |
||
| 335 | 40 => array( |
||
| 336 | 'Permalinks', |
||
| 337 | 'manage_options', |
||
| 338 | 'options-permalink.php', |
||
| 339 | ), |
||
| 340 | 45 => array( |
||
| 341 | 'Privacy', |
||
| 342 | 'manage_privacy_options', |
||
| 343 | 'options-privacy.php', |
||
| 344 | ), |
||
| 345 | 46 => array( |
||
| 346 | 'Approve User', |
||
| 347 | 'promote_users', |
||
| 348 | 'wp-approve-user', |
||
| 349 | 'Approve User', |
||
| 350 | ), |
||
| 351 | 47 => array( |
||
| 352 | '', |
||
| 353 | 'manage_options', |
||
| 354 | 'sharing', |
||
| 355 | '', |
||
| 356 | ), |
||
| 357 | ), |
||
| 358 | 'edit-tags.php?taxonomy=link_category' => array( |
||
| 359 | 15 => array( |
||
| 360 | 'Link Categories', |
||
| 361 | 'manage_categories', |
||
| 362 | 'edit-tags.php?taxonomy=link_category', |
||
| 363 | ), |
||
| 364 | ), |
||
| 365 | |||
| 366 | '' => array( |
||
| 367 | 0 => array( |
||
| 368 | '', |
||
| 369 | 'manage_options', |
||
| 370 | 'jetpack-debugger', |
||
| 371 | 'Debugging Center', |
||
| 372 | ), |
||
| 373 | 1 => array( |
||
| 374 | 'Settings', |
||
| 375 | 'jetpack_manage_modules', |
||
| 376 | 'jetpack_modules', |
||
| 377 | 'Jetpack Settings', |
||
| 378 | ), |
||
| 379 | 2 => array( |
||
| 380 | '', |
||
| 381 | 'jetpack_admin_page', |
||
| 382 | 'jetpack_about', |
||
| 383 | 'About Jetpack', |
||
| 384 | ), |
||
| 385 | ), |
||
| 386 | 'edit.php?post_type=feedback' => array( |
||
| 387 | 0 => array( |
||
| 388 | 'Feedback', |
||
| 389 | 'edit_pages', |
||
| 390 | 'edit.php?post_type=feedback', |
||
| 391 | '', |
||
| 392 | ), |
||
| 393 | 1 => array( |
||
| 394 | 'Export CSV', |
||
| 395 | 'export', |
||
| 396 | 'feedback-export', |
||
| 397 | 'Export feedback as CSV', |
||
| 398 | ), |
||
| 399 | ), |
||
| 400 | 'jetpack' => array( |
||
| 401 | 1 => array( |
||
| 402 | 'Dashboard', |
||
| 403 | 'jetpack_admin_page', |
||
| 404 | 'jetpack#/dashboard', |
||
| 405 | 'Dashboard', |
||
| 406 | ), |
||
| 407 | 2 => array( |
||
| 408 | 'Settings', |
||
| 409 | 'jetpack_admin_page', |
||
| 410 | 'jetpack#/settings', |
||
| 411 | 'Settings', |
||
| 412 | ), |
||
| 413 | ), |
||
| 414 | ); |
||
| 415 | } |
||
| 416 |