| Conditions | 18 |
| Paths | 29 |
| Total Lines | 55 |
| Code Lines | 33 |
| 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 |
||
| 45 | private function setup_args( $args ) { |
||
|
|
|||
| 46 | // If the 'download' URL parameter is set, a WXR export file is baked and returned. |
||
| 47 | if ( isset( $_GET['download'] ) ) { |
||
| 48 | $args = array(); |
||
| 49 | |||
| 50 | if ( ! isset( $_GET['content'] ) || 'all' == $_GET['content'] ) { |
||
| 51 | $args['content'] = 'all'; |
||
| 52 | } elseif ( 'posts' == $_GET['content'] ) { |
||
| 53 | $args['content'] = 'post'; |
||
| 54 | |||
| 55 | if ( $_GET['cat'] ) { |
||
| 56 | $args['category'] = (int) $_GET['cat']; |
||
| 57 | } |
||
| 58 | |||
| 59 | if ( $_GET['post_author'] ) { |
||
| 60 | $args['author'] = (int) $_GET['post_author']; |
||
| 61 | } |
||
| 62 | |||
| 63 | if ( $_GET['post_start_date'] || $_GET['post_end_date'] ) { |
||
| 64 | $args['start_date'] = $_GET['post_start_date']; |
||
| 65 | $args['end_date'] = $_GET['post_end_date']; |
||
| 66 | } |
||
| 67 | |||
| 68 | if ( $_GET['post_status'] ) { |
||
| 69 | $args['status'] = $_GET['post_status']; |
||
| 70 | } |
||
| 71 | } elseif ( 'pages' == $_GET['content'] ) { |
||
| 72 | $args['content'] = 'page'; |
||
| 73 | |||
| 74 | if ( $_GET['page_author'] ) { |
||
| 75 | $args['author'] = (int) $_GET['page_author']; |
||
| 76 | } |
||
| 77 | |||
| 78 | if ( $_GET['page_start_date'] || $_GET['page_end_date'] ) { |
||
| 79 | $args['start_date'] = $_GET['page_start_date']; |
||
| 80 | $args['end_date'] = $_GET['page_end_date']; |
||
| 81 | } |
||
| 82 | |||
| 83 | if ( $_GET['page_status'] ) { |
||
| 84 | $args['status'] = $_GET['page_status']; |
||
| 85 | } |
||
| 86 | } elseif ( 'attachment' == $_GET['content'] ) { |
||
| 87 | $args['content'] = 'attachment'; |
||
| 88 | |||
| 89 | if ( $_GET['attachment_start_date'] || $_GET['attachment_end_date'] ) { |
||
| 90 | $args['start_date'] = $_GET['attachment_start_date']; |
||
| 91 | $args['end_date'] = $_GET['attachment_end_date']; |
||
| 92 | } |
||
| 93 | } else { |
||
| 94 | $args['content'] = $_GET['content']; |
||
| 95 | } |
||
| 96 | |||
| 97 | return $args; |
||
| 98 | } |
||
| 99 | } |
||
| 100 | } |
||
| 101 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.