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 |
||
38 | public function fields( array $fields ) { |
||
39 | // Account ID |
||
40 | $fields[] = array( |
||
41 | 'filter' => FILTER_SANITIZE_STRING, |
||
42 | 'section' => 'multisafepay', |
||
43 | 'meta_key' => '_pronamic_gateway_multisafepay_account_id', |
||
44 | 'title' => __( 'Account ID', 'pronamic_ideal' ), |
||
45 | 'type' => 'text', |
||
46 | 'classes' => array( 'code' ), |
||
47 | 'methods' => array( 'multisafepay_connect' ), |
||
48 | 'tooltip' => sprintf( |
||
49 | '%s %s.', |
||
50 | __( 'Account ID', 'pronamic_ideal' ), |
||
51 | /* translators: %s: MultiSafepay */ |
||
52 | sprintf( __( 'as mentioned in the %s dashboard', 'pronamic_ideal' ), __( 'MultiSafepay', 'pronamic_ideal' ) ) |
||
53 | ), |
||
54 | ); |
||
55 | |||
56 | // Site ID |
||
57 | $fields[] = array( |
||
58 | 'filter' => FILTER_SANITIZE_STRING, |
||
59 | 'section' => 'multisafepay', |
||
60 | 'meta_key' => '_pronamic_gateway_multisafepay_site_id', |
||
61 | 'title' => __( 'Site ID', 'pronamic_ideal' ), |
||
62 | 'type' => 'text', |
||
63 | 'classes' => array( 'code' ), |
||
64 | 'methods' => array( 'multisafepay_connect' ), |
||
65 | 'tooltip' => sprintf( |
||
66 | '%s %s.', |
||
67 | __( 'Site ID', 'pronamic_ideal' ), |
||
68 | /* translators: %s: MultiSafepay */ |
||
69 | sprintf( __( 'as mentioned in the %s dashboard', 'pronamic_ideal' ), __( 'MultiSafepay', 'pronamic_ideal' ) ) |
||
70 | ), |
||
71 | ); |
||
72 | |||
73 | // Site Security Code |
||
74 | $fields[] = array( |
||
75 | 'filter' => FILTER_SANITIZE_STRING, |
||
76 | 'section' => 'multisafepay', |
||
77 | 'meta_key' => '_pronamic_gateway_multisafepay_site_code', |
||
78 | 'title' => __( 'Site Security Code', 'pronamic_ideal' ), |
||
79 | 'type' => 'text', |
||
80 | 'classes' => array( 'code' ), |
||
81 | 'methods' => array( 'multisafepay_connect' ), |
||
82 | 'tooltip' => sprintf( |
||
83 | '%s %s.', |
||
84 | __( 'Site Security Code', 'pronamic_ideal' ), |
||
85 | /* translators: %s: MultiSafepay */ |
||
86 | sprintf( __( 'as mentioned in the %s dashboard', 'pronamic_ideal' ), __( 'MultiSafepay', 'pronamic_ideal' ) ) |
||
87 | ), |
||
88 | ); |
||
89 | |||
90 | // Transaction feedback |
||
91 | $fields[] = array( |
||
92 | 'section' => 'multisafepay', |
||
93 | 'title' => __( 'Transaction feedback', 'pronamic_ideal' ), |
||
94 | 'type' => 'description', |
||
95 | 'html' => sprintf( |
||
96 | '<span class="dashicons dashicons-yes"></span> %s', |
||
97 | __( 'Payment status updates will be processed without any additional configuration.', 'pronamic_ideal' ) |
||
98 | ), |
||
99 | ); |
||
100 | |||
101 | // Return fields |
||
102 | return $fields; |
||
103 | } |
||
105 |