| Conditions | 1 |
| Paths | 1 |
| Total Lines | 65 |
| Code Lines | 44 |
| 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 |
||
| 58 | public function fields( array $fields ) { |
||
| 59 | // Storename. |
||
| 60 | $fields[] = array( |
||
| 61 | 'filter' => FILTER_UNSAFE_RAW, |
||
| 62 | 'section' => 'ems_ecommerce', |
||
| 63 | 'meta_key' => '_pronamic_gateway_ems_ecommerce_storename', |
||
| 64 | 'title' => _x( 'Storename', 'ems', 'pronamic_ideal' ), |
||
| 65 | 'type' => 'text', |
||
| 66 | 'classes' => array( 'code' ), |
||
| 67 | ); |
||
| 68 | |||
| 69 | // Shared secret. |
||
| 70 | $fields[] = array( |
||
| 71 | 'filter' => FILTER_UNSAFE_RAW, |
||
| 72 | 'section' => 'ems_ecommerce', |
||
| 73 | 'meta_key' => '_pronamic_gateway_ems_ecommerce_secret', |
||
| 74 | 'title' => _x( 'Shared Secret', 'ems', 'pronamic_ideal' ), |
||
| 75 | 'type' => 'text', |
||
| 76 | 'classes' => array( 'large-text', 'code' ), |
||
| 77 | ); |
||
| 78 | |||
| 79 | // Transaction feedback. |
||
| 80 | $fields[] = array( |
||
| 81 | 'section' => 'ems_ecommerce', |
||
| 82 | 'title' => __( 'Transaction feedback', 'pronamic_ideal' ), |
||
| 83 | 'type' => 'description', |
||
| 84 | 'html' => sprintf( |
||
| 85 | '<span class="dashicons dashicons-yes"></span> %s', |
||
| 86 | __( 'Payment status updates will be processed without any additional configuration.', 'pronamic_ideal' ) |
||
| 87 | ), |
||
| 88 | ); |
||
| 89 | |||
| 90 | // Purchase ID. |
||
| 91 | $fields[] = array( |
||
| 92 | 'filter' => array( |
||
| 93 | 'filter' => FILTER_SANITIZE_STRING, |
||
| 94 | 'flags' => FILTER_FLAG_NO_ENCODE_QUOTES, |
||
| 95 | ), |
||
| 96 | 'section' => 'ems_ecommerce_advanced', |
||
| 97 | 'meta_key' => '_pronamic_gateway_ems_ecommerce_order_id', |
||
| 98 | 'title' => __( 'Order ID', 'pronamic_ideal' ), |
||
| 99 | 'type' => 'text', |
||
| 100 | 'classes' => array( 'regular-text', 'code' ), |
||
| 101 | 'tooltip' => sprintf( |
||
| 102 | /* translators: %s: <code>{orderId}</code> */ |
||
| 103 | __( 'The EMS e-Commerce %s parameter.', 'pronamic_ideal' ), |
||
| 104 | sprintf( '<code>%s</code>', 'orderId' ) |
||
| 105 | ), |
||
| 106 | 'description' => sprintf( |
||
| 107 | '%s %s<br />%s', |
||
| 108 | __( 'Available tags:', 'pronamic_ideal' ), |
||
| 109 | sprintf( |
||
| 110 | '<code>%s</code> <code>%s</code>', |
||
| 111 | '{order_id}', |
||
| 112 | '{payment_id}' |
||
| 113 | ), |
||
| 114 | sprintf( |
||
| 115 | /* translators: %s: {order_id} */ |
||
| 116 | __( 'Default: <code>%s</code>', 'pronamic_ideal' ), |
||
| 117 | '{order_id}' |
||
| 118 | ) |
||
| 119 | ), |
||
| 120 | ); |
||
| 121 | |||
| 122 | return $fields; |
||
| 123 | } |
||
| 125 |