Conditions | 1 |
Paths | 1 |
Total Lines | 96 |
Code Lines | 66 |
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 |
||
48 | public function fields( array $fields ) { |
||
49 | // Merchant ID |
||
50 | $fields[] = array( |
||
51 | 'filter' => FILTER_SANITIZE_STRING, |
||
52 | 'section' => 'icepay', |
||
53 | 'meta_key' => '_pronamic_gateway_icepay_merchant_id', |
||
54 | 'title' => _x( 'Merchant ID', 'icepay', 'pronamic_ideal' ), |
||
55 | 'type' => 'text', |
||
56 | 'tooltip' => __( 'Merchant ID as mentioned in the ICEPAY dashboard at the "My websites" page.', 'pronamic_ideal' ), |
||
57 | ); |
||
58 | |||
59 | // Secret Code |
||
60 | $fields[] = array( |
||
61 | 'filter' => FILTER_SANITIZE_STRING, |
||
62 | 'section' => 'icepay', |
||
63 | 'meta_key' => '_pronamic_gateway_icepay_secret_code', |
||
64 | 'title' => _x( 'Secret Code', 'icepay', 'pronamic_ideal' ), |
||
65 | 'type' => 'text', |
||
66 | 'classes' => array( 'regular-text', 'code' ), |
||
67 | 'tooltip' => __( 'Secret Code as mentioned in the ICEPAY dashboard at the "My websites" page.', 'pronamic_ideal' ), |
||
68 | ); |
||
69 | |||
70 | // Transaction feedback |
||
71 | $fields[] = array( |
||
72 | 'section' => 'icepay', |
||
73 | 'title' => __( 'Transaction feedback', 'pronamic_ideal' ), |
||
74 | 'type' => 'description', |
||
75 | 'html' => sprintf( |
||
76 | '<span class="dashicons dashicons-warning"></span> %s', |
||
77 | __( 'Receiving payment status updates needs additional configuration, if not yet completed.', 'pronamic_ideal' ) |
||
78 | ), |
||
79 | ); |
||
80 | |||
81 | // Purchase ID |
||
82 | $fields[] = array( |
||
83 | 'filter' => array( |
||
84 | 'filter' => FILTER_SANITIZE_STRING, |
||
85 | 'flags' => FILTER_FLAG_NO_ENCODE_QUOTES, |
||
86 | ), |
||
87 | 'section' => 'icepay_advanced', |
||
88 | 'meta_key' => '_pronamic_gateway_icepay_order_id', |
||
89 | 'title' => __( 'Order ID', 'pronamic_ideal' ), |
||
90 | 'type' => 'text', |
||
91 | 'classes' => array( 'regular-text', 'code' ), |
||
92 | 'tooltip' => sprintf( |
||
93 | /* translators: %s: <code>OrderID</code> */ |
||
94 | __( 'The Icepay %s parameter.', 'pronamic_ideal' ), |
||
95 | sprintf( '<code>%s</code>', 'OrderID' ) |
||
96 | ), |
||
97 | 'description' => sprintf( |
||
98 | '%s %s<br />%s', |
||
99 | __( 'Available tags:', 'pronamic_ideal' ), |
||
100 | sprintf( |
||
101 | '<code>%s</code> <code>%s</code>', |
||
102 | '{order_id}', |
||
103 | '{payment_id}' |
||
104 | ), |
||
105 | sprintf( |
||
106 | /* translators: %s: <code>{payment_id}</code> */ |
||
107 | __( 'Default: <code>%s</code>', 'pronamic_ideal' ), |
||
108 | '{payment_id}' |
||
109 | ) |
||
110 | ), |
||
111 | ); |
||
112 | |||
113 | // Thank you page URL |
||
114 | $fields[] = array( |
||
115 | 'section' => 'icepay_feedback', |
||
116 | 'title' => __( 'Thank you page URL', 'pronamic_ideal' ), |
||
117 | 'type' => 'text', |
||
118 | 'classes' => array( 'regular-text', 'code' ), |
||
119 | 'value' => home_url( '/' ), |
||
120 | 'readonly' => true, |
||
121 | ); |
||
122 | |||
123 | // Error page URL |
||
124 | $fields[] = array( |
||
125 | 'section' => 'icepay_feedback', |
||
126 | 'title' => __( 'Error page URL', 'pronamic_ideal' ), |
||
127 | 'type' => 'text', |
||
128 | 'classes' => array( 'regular-text', 'code' ), |
||
129 | 'value' => home_url( '/' ), |
||
130 | 'readonly' => true, |
||
131 | ); |
||
132 | |||
133 | // Postback URL |
||
134 | $fields[] = array( |
||
135 | 'section' => 'icepay_feedback', |
||
136 | 'title' => __( 'Postback URL', 'pronamic_ideal' ), |
||
137 | 'type' => 'text', |
||
138 | 'classes' => array( 'regular-text', 'code' ), |
||
139 | 'value' => home_url( '/' ), |
||
140 | 'readonly' => true, |
||
141 | ); |
||
142 | |||
143 | return $fields; |
||
144 | } |
||
146 |