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