| Conditions | 21 |
| Paths | > 20000 |
| Total Lines | 91 |
| 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 |
||
| 21 | public static function prepareFields(array $input, $mutation_name) |
||
| 22 | { |
||
| 23 | |||
| 24 | $args = []; |
||
| 25 | |||
| 26 | if (! empty($input['name'])) { |
||
| 27 | $args['VNU_name'] = sanitize_text_field($input['name']); |
||
| 28 | } |
||
| 29 | |||
| 30 | if (! empty($input['description'])) { |
||
| 31 | $args['VNU_desc'] = wp_kses_post($input['description']); |
||
| 32 | } |
||
| 33 | |||
| 34 | if (! empty($input['shortDescription'])) { |
||
| 35 | $args['VNU_short_desc'] = sanitize_text_field($input['shortDescription']); |
||
| 36 | } |
||
| 37 | |||
| 38 | if (! empty($input['identifier'])) { |
||
| 39 | $args['VNU_identifier'] = sanitize_title($input['identifier']); |
||
| 40 | } |
||
| 41 | |||
| 42 | if (! empty($input['created'])) { |
||
| 43 | $args['VNU_created'] = new DateTime(sanitize_text_field($input['created'])); |
||
| 44 | } |
||
| 45 | |||
| 46 | if (! empty($input['order'])) { |
||
| 47 | $args['VNU_order'] = absint($input['order']); |
||
| 48 | } |
||
| 49 | |||
| 50 | if (! empty($input['wpUser'])) { |
||
| 51 | $args['VNU_wp_user'] = absint($input['wpUser']); |
||
| 52 | } |
||
| 53 | |||
| 54 | if (! empty($input['address'])) { |
||
| 55 | $args['VNU_address'] = sanitize_text_field($input['address']); |
||
| 56 | } |
||
| 57 | |||
| 58 | if (! empty($input['address2'])) { |
||
| 59 | $args['VNU_address2'] = sanitize_text_field($input['address2']); |
||
| 60 | } |
||
| 61 | |||
| 62 | if (! empty($input['city'])) { |
||
| 63 | $args['VNU_city'] = sanitize_text_field($input['city']); |
||
| 64 | } |
||
| 65 | |||
| 66 | if (! empty($input['state'])) { |
||
| 67 | $args['STA_ID'] = absint($input['state']); |
||
| 68 | } |
||
| 69 | |||
| 70 | if (! empty($input['country'])) { |
||
| 71 | $args['CNT_ISO'] = sanitize_text_field($input['country']); |
||
| 72 | } |
||
| 73 | |||
| 74 | if (! empty($input['zip'])) { |
||
| 75 | $args['VNU_zip'] = sanitize_text_field($input['zip']); |
||
| 76 | } |
||
| 77 | |||
| 78 | if (! empty($input['capacity'])) { |
||
| 79 | $args['VNU_capacity'] = absint($input['capacity']); |
||
| 80 | } |
||
| 81 | |||
| 82 | if (! empty($input['phone'])) { |
||
| 83 | $args['VNU_phone'] = sanitize_text_field($input['phone']); |
||
| 84 | } |
||
| 85 | |||
| 86 | if (! empty($input['virtualPhone'])) { |
||
| 87 | $args['VNU_virtual_phone'] = sanitize_text_field($input['virtualPhone']); |
||
| 88 | } |
||
| 89 | |||
| 90 | if (! empty($input['url'])) { |
||
| 91 | $args['VNU_url'] = sanitize_text_field($input['url']); |
||
| 92 | } |
||
| 93 | |||
| 94 | if (! empty($input['virtualUrl'])) { |
||
| 95 | $args['VNU_virtual_url'] = sanitize_text_field($input['virtualUrl']); |
||
| 96 | } |
||
| 97 | |||
| 98 | if (! empty($input['googleMapLink'])) { |
||
| 99 | $args['VNU_google_map_link'] = sanitize_text_field($input['googleMapLink']); |
||
| 100 | } |
||
| 101 | |||
| 102 | if (! empty($input['enableForGmap'])) { |
||
| 103 | $args['VNU_enable_for_gmap'] = (bool) $input['enableForGmap']; |
||
| 104 | } |
||
| 105 | |||
| 106 | return apply_filters( |
||
| 107 | 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__venue_args', |
||
| 108 | $args, |
||
| 109 | $input |
||
| 110 | ); |
||
| 111 | } |
||
| 112 | } |
||
| 113 |