| Conditions | 15 |
| Paths | 96 |
| Total Lines | 51 |
| Code Lines | 33 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 | public function process_date_fields( $delete_options ) { |
||
| 46 | if ( ! empty( $delete_options['relative_date'] ) && 'custom' !== $delete_options['relative_date'] ) { |
||
| 47 | $delete_options['meta_value'] = date( 'c', strtotime( $delete_options['relative_date'] ) ); |
||
| 48 | } |
||
| 49 | |||
| 50 | if ( ! empty( $delete_options['date_unit'] ) && ! empty( $delete_options['date_type'] ) ) { |
||
| 51 | $interval_unit = $delete_options['date_unit']; |
||
| 52 | $interval_type = $delete_options['date_type']; |
||
| 53 | |||
| 54 | switch ( $delete_options['meta_op'] ) { |
||
| 55 | case '<': |
||
| 56 | case '<=': |
||
| 57 | $delete_options['meta_value'] = date( 'c', strtotime( '-' . $interval_unit . ' ' . $interval_type ) ); |
||
| 58 | break; |
||
| 59 | case '>': |
||
| 60 | case '>=': |
||
| 61 | case '=': |
||
| 62 | case '!=': |
||
| 63 | $delete_options['meta_value'] = date( 'c', strtotime( $interval_unit . ' ' . $interval_type ) ); |
||
| 64 | break; |
||
| 65 | } |
||
| 66 | } |
||
| 67 | |||
| 68 | // In v1.0 `date_format` was changed to `meta_value_date_format`. |
||
| 69 | // Needed? |
||
| 70 | if ( isset( $delete_options['date_format'] ) ) { |
||
| 71 | $delete_options['meta_value_date_format'] = $delete_options['date_format']; |
||
| 72 | } |
||
| 73 | $meta_query = array( |
||
| 74 | 'key' => $delete_options['meta_key'], |
||
| 75 | 'value' => $delete_options['meta_value'], |
||
| 76 | 'compare' => $delete_options['meta_op'], |
||
| 77 | 'type' => $delete_options['meta_type'], |
||
| 78 | ); |
||
| 79 | |||
| 80 | $options = array( |
||
| 81 | 'meta_query' => array( $meta_query ), |
||
| 82 | ); |
||
| 83 | |||
| 84 | if ( 'DATE' === $meta_query['type'] && ! empty( $delete_options['meta_value_date_format'] ) ) { |
||
| 85 | $options['cf_meta_value_date_format'] = $delete_options['meta_value_date_format']; |
||
| 86 | |||
| 87 | if ( ! empty( $delete_options['input_value_date_format'] ) ) { |
||
| 88 | $options['cf_input_value_date_format'] = $delete_options['input_value_date_format']; |
||
| 89 | } else { |
||
| 90 | $options['cf_input_value_date_format'] = '%Y-%m-%d'; |
||
| 91 | } |
||
| 92 | |||
| 93 | $this->load(); |
||
| 94 | } |
||
| 95 | return $options; |
||
| 96 | } |
||
| 165 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.