| Conditions | 10 |
| Paths | 12 |
| Total Lines | 27 |
| Code Lines | 18 |
| 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 |
||
| 55 | public function __call( $name, $arguments ) { |
||
| 56 | $deprecated_function_arr = array( |
||
| 57 | 'get_customer_by', |
||
| 58 | 'give_update_customer_email_on_user_update', |
||
| 59 | 'get_customers', |
||
| 60 | ); |
||
| 61 | |||
| 62 | if ( in_array( $name, $deprecated_function_arr ) ) { |
||
| 63 | switch ( $name ) { |
||
| 64 | case 'get_customers': |
||
| 65 | $args = ! empty( $arguments[0] ) ? $arguments[0] : array(); |
||
| 66 | |||
| 67 | return $this->get_donors( $args ); |
||
| 68 | case 'get_customer_by': |
||
| 69 | $field = ! empty( $arguments[0] ) ? $arguments[0] : 'id'; |
||
| 70 | $donor_id = ! empty( $arguments[1] ) ? $arguments[1] : 0; |
||
| 71 | |||
| 72 | return $this->get_donor_by( $field, $donor_id ); |
||
| 73 | |||
| 74 | case 'give_update_customer_email_on_user_update': |
||
| 75 | $user_id = ! empty( $arguments[0] ) ? $arguments[0] : 0; |
||
| 76 | $old_user_data = ! empty( $arguments[1] ) ? $arguments[1] : false; |
||
| 77 | |||
| 78 | return $this->update_donor_email_on_user_update( $user_id, $old_user_data ); |
||
| 79 | } |
||
| 80 | } |
||
| 81 | } |
||
| 82 | |||
| 156 |