| Conditions | 1 |
| Paths | 1 |
| Total Lines | 83 |
| Code Lines | 56 |
| 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 |
||
| 68 | public function fields( array $fields ) { |
||
| 69 | // Website Key. |
||
| 70 | $fields[] = array( |
||
| 71 | 'filter' => FILTER_SANITIZE_STRING, |
||
| 72 | 'section' => 'buckaroo', |
||
| 73 | 'meta_key' => '_pronamic_gateway_buckaroo_website_key', |
||
| 74 | 'title' => __( 'Website Key', 'pronamic_ideal' ), |
||
| 75 | 'type' => 'text', |
||
| 76 | 'classes' => array( 'code' ), |
||
| 77 | 'tooltip' => __( 'Website key as mentioned in the Buckaroo dashboard on the page "Profile » Website".', 'pronamic_ideal' ), |
||
| 78 | ); |
||
| 79 | |||
| 80 | // Secret Key. |
||
| 81 | $fields[] = array( |
||
| 82 | 'filter' => FILTER_SANITIZE_STRING, |
||
| 83 | 'section' => 'buckaroo', |
||
| 84 | 'meta_key' => '_pronamic_gateway_buckaroo_secret_key', |
||
| 85 | 'title' => __( 'Secret Key', 'pronamic_ideal' ), |
||
| 86 | 'type' => 'text', |
||
| 87 | 'classes' => array( 'regular-text', 'code' ), |
||
| 88 | 'tooltip' => __( 'Secret key as mentioned in the Buckaroo dashboardb on the page "Configuration » Secret Key for Digital Signature".', 'pronamic_ideal' ), |
||
| 89 | ); |
||
| 90 | |||
| 91 | // Transaction feedback. |
||
| 92 | $fields[] = array( |
||
| 93 | 'section' => 'buckaroo', |
||
| 94 | 'title' => __( 'Transaction feedback', 'pronamic_ideal' ), |
||
| 95 | 'type' => 'description', |
||
| 96 | 'html' => sprintf( |
||
| 97 | '<span class="dashicons dashicons-yes"></span> %s', |
||
| 98 | __( 'Payment status updates will be processed without any additional configuration.', 'pronamic_ideal' ) |
||
| 99 | ), |
||
| 100 | ); |
||
| 101 | |||
| 102 | // Excluded services. |
||
| 103 | $fields[] = array( |
||
| 104 | 'filter' => FILTER_SANITIZE_STRING, |
||
| 105 | 'section' => 'buckaroo_advanced', |
||
| 106 | 'meta_key' => '_pronamic_gateway_buckaroo_excluded_services', |
||
| 107 | 'title' => __( 'Excluded services', 'pronamic_ideal' ), |
||
| 108 | 'type' => 'text', |
||
| 109 | 'classes' => array( 'regular-text', 'code' ), |
||
| 110 | 'tooltip' => sprintf( |
||
| 111 | /* translators: %s: <code>brq_exludedservices</code> */ |
||
| 112 | __( 'This controls the Buckaroo %s parameter.', 'pronamic_ideal' ), |
||
| 113 | sprintf( '<code>%s</code>', 'brq_exludedservices' ) |
||
| 114 | ), |
||
| 115 | ); |
||
| 116 | |||
| 117 | // Invoice number. |
||
| 118 | $fields[] = array( |
||
| 119 | 'filter' => FILTER_SANITIZE_STRING, |
||
| 120 | 'section' => 'buckaroo_advanced', |
||
| 121 | 'meta_key' => '_pronamic_gateway_buckaroo_invoice_number', |
||
| 122 | 'title' => __( 'Invoice number', 'pronamic_ideal' ), |
||
| 123 | 'type' => 'text', |
||
| 124 | 'classes' => array( 'regular-text', 'code' ), |
||
| 125 | 'tooltip' => sprintf( |
||
| 126 | /* translators: %s: <code>brq_invoicenumber</code> */ |
||
| 127 | __( 'This controls the Buckaroo %s parameter.', 'pronamic_ideal' ), |
||
| 128 | sprintf( '<code>%s</code>', 'brq_invoicenumber' ) |
||
| 129 | ), |
||
| 130 | 'description' => sprintf( |
||
| 131 | '%s<br />%s', |
||
| 132 | /* translators: %s: <code>{order_id}</code> <code>{payment_id}</code> */ |
||
| 133 | sprintf( __( 'Available tags: %s', 'pronamic_ideal' ), sprintf( '<code>%s</code> <code>%s</code>', '{order_id}', '{payment_id}' ) ), |
||
| 134 | /* translators: %s: <code>{payment_id}</code> */ |
||
| 135 | sprintf( __( 'Default: <code>%s</code>', 'pronamic_ideal' ), '{payment_id}' ) |
||
| 136 | ), |
||
| 137 | ); |
||
| 138 | |||
| 139 | // Push URL. |
||
| 140 | $fields[] = array( |
||
| 141 | 'section' => 'buckaroo_feedback', |
||
| 142 | 'title' => __( 'Push URL', 'pronamic_ideal' ), |
||
| 143 | 'type' => 'text', |
||
| 144 | 'classes' => array( 'large-text', 'code' ), |
||
| 145 | 'value' => add_query_arg( 'buckaroo_push', '', home_url( '/' ) ), |
||
| 146 | 'readonly' => true, |
||
| 147 | 'tooltip' => __( 'The Push URL as sent with each transaction to receive automatic payment status updates on.', 'pronamic_ideal' ), |
||
| 148 | ); |
||
| 149 | |||
| 150 | return $fields; |
||
| 151 | } |
||
| 153 |