| Conditions | 4 |
| Paths | 4 |
| Total Lines | 197 |
| 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 get_settings() { |
||
| 49 | $settings = array(); |
||
| 50 | $current_section = give_get_current_setting_section(); |
||
| 51 | |||
| 52 | switch ( $current_section ) { |
||
| 53 | case 'paypal-standard': |
||
| 54 | $settings = array( |
||
| 55 | // Section 2: PayPal Standard. |
||
| 56 | array( |
||
| 57 | 'type' => 'title', |
||
| 58 | 'id' => 'give_title_gateway_settings_2', |
||
| 59 | ), |
||
| 60 | array( |
||
| 61 | 'name' => __( 'PayPal Email', 'give' ), |
||
| 62 | 'desc' => __( 'Enter your PayPal account\'s email.', 'give' ), |
||
| 63 | 'id' => 'paypal_email', |
||
| 64 | 'type' => 'email', |
||
| 65 | ), |
||
| 66 | array( |
||
| 67 | 'name' => __( 'PayPal Page Style', 'give' ), |
||
| 68 | 'desc' => __( 'Enter the name of the PayPal page style to use, or leave blank to use the default.', 'give' ), |
||
| 69 | 'id' => 'paypal_page_style', |
||
| 70 | 'type' => 'text', |
||
| 71 | ), |
||
| 72 | array( |
||
| 73 | 'name' => __( 'PayPal Transaction Type', 'give' ), |
||
| 74 | 'desc' => __( 'Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give' ), |
||
| 75 | 'id' => 'paypal_button_type', |
||
| 76 | 'type' => 'radio_inline', |
||
| 77 | 'options' => array( |
||
| 78 | 'donation' => __( 'Donation', 'give' ), |
||
| 79 | 'standard' => __( 'Standard Transaction', 'give' ) |
||
| 80 | ), |
||
| 81 | 'default' => 'donation', |
||
| 82 | ), |
||
| 83 | array( |
||
| 84 | 'name' => __( 'Billing Details', 'give' ), |
||
| 85 | 'desc' => __( 'This option will enable the billing details section for PayPal Standard which requires the donor\'s address to complete the donation. These fields are not required by PayPal to process the transaction, but you may have a need to collect the data.', 'give' ), |
||
| 86 | 'id' => 'paypal_standard_billing_details', |
||
| 87 | 'type' => 'radio_inline', |
||
| 88 | 'default' => 'disabled', |
||
| 89 | 'options' => array( |
||
| 90 | 'enabled' => __( 'Enabled', 'give' ), |
||
| 91 | 'disabled' => __( 'Disabled', 'give' ), |
||
| 92 | ) |
||
| 93 | ), |
||
| 94 | array( |
||
| 95 | 'name' => __( 'PayPal IPN Verification', 'give' ), |
||
| 96 | 'desc' => __( 'If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give' ), |
||
| 97 | 'id' => 'paypal_verification', |
||
| 98 | 'type' => 'radio_inline', |
||
| 99 | 'default' => 'enabled', |
||
| 100 | 'options' => array( |
||
| 101 | 'enabled' => __( 'Enabled', 'give' ), |
||
| 102 | 'disabled' => __( 'Disabled', 'give' ), |
||
| 103 | ) |
||
| 104 | ), |
||
| 105 | array( |
||
| 106 | 'name' => __( 'PayPal Standard Gateway Settings Docs Link', 'give' ), |
||
| 107 | 'id' => 'paypal_standard_gateway_settings_docs_link', |
||
| 108 | 'url' => esc_url( 'http://docs.givewp.com/settings-gateway-paypal-standard' ), |
||
| 109 | 'title' => __( 'PayPal Standard Gateway Settings', 'give' ), |
||
| 110 | 'type' => 'give_docs_link', |
||
| 111 | ), |
||
| 112 | array( |
||
| 113 | 'type' => 'sectionend', |
||
| 114 | 'id' => 'give_title_gateway_settings_2', |
||
| 115 | ) |
||
| 116 | ); |
||
| 117 | break; |
||
| 118 | |||
| 119 | case 'offline-donations' : |
||
| 120 | $settings = array( |
||
| 121 | // Section 3: Offline gateway. |
||
| 122 | array( |
||
| 123 | 'type' => 'title', |
||
| 124 | 'id' => 'give_title_gateway_settings_3', |
||
| 125 | ), |
||
| 126 | array( |
||
| 127 | 'name' => __( 'Collect Billing Details', 'give' ), |
||
| 128 | 'desc' => __( 'Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give' ), |
||
| 129 | 'id' => 'give_offline_donation_enable_billing_fields', |
||
| 130 | 'type' => 'radio_inline', |
||
| 131 | 'default' => 'disabled', |
||
| 132 | 'options' => array( |
||
| 133 | 'enabled' => __( 'Enabled', 'give' ), |
||
| 134 | 'disabled' => __( 'Disabled', 'give' ) |
||
| 135 | ) |
||
| 136 | ), |
||
| 137 | array( |
||
| 138 | 'name' => __( 'Offline Donation Instructions', 'give' ), |
||
| 139 | 'desc' => __( 'The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give' ), |
||
| 140 | 'id' => 'global_offline_donation_content', |
||
| 141 | 'default' => give_get_default_offline_donation_content(), |
||
| 142 | 'type' => 'wysiwyg', |
||
| 143 | 'options' => array( |
||
| 144 | 'textarea_rows' => 6, |
||
| 145 | ) |
||
| 146 | ), |
||
| 147 | array( |
||
| 148 | 'name' => esc_html__( 'Offline Donations Settings Docs Link', 'give' ), |
||
| 149 | 'id' => 'offline_gateway_settings_docs_link', |
||
| 150 | 'url' => esc_url( 'http://docs.givewp.com/offlinegateway' ), |
||
| 151 | 'title' => __( 'Offline Gateway Settings', 'give' ), |
||
| 152 | 'type' => 'give_docs_link', |
||
| 153 | ), |
||
| 154 | array( |
||
| 155 | 'type' => 'sectionend', |
||
| 156 | 'id' => 'give_title_gateway_settings_3', |
||
| 157 | ) |
||
| 158 | ); |
||
| 159 | break; |
||
| 160 | |||
| 161 | case 'gateways-settings': |
||
| 162 | $settings = array( |
||
| 163 | // Section 1: Gateways. |
||
| 164 | array( |
||
| 165 | 'id' => 'give_title_gateway_settings_1', |
||
| 166 | 'type' => 'title' |
||
| 167 | ), |
||
| 168 | array( |
||
| 169 | 'name' => __( 'Test Mode', 'give' ), |
||
| 170 | 'desc' => __( 'While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give' ), |
||
| 171 | 'id' => 'test_mode', |
||
| 172 | 'type' => 'radio_inline', |
||
| 173 | 'default' => 'disabled', |
||
| 174 | 'options' => array( |
||
| 175 | 'enabled' => __( 'Enabled', 'give' ), |
||
| 176 | 'disabled' => __( 'Disabled', 'give' ), |
||
| 177 | ) |
||
| 178 | ), |
||
| 179 | array( |
||
| 180 | 'name' => __( 'Enabled Gateways', 'give' ), |
||
| 181 | 'desc' => __( 'Enable your payment gateway. Can be ordered by dragging.', 'give' ), |
||
| 182 | 'id' => 'gateways', |
||
| 183 | 'type' => 'enabled_gateways' |
||
| 184 | ), |
||
| 185 | |||
| 186 | /** |
||
| 187 | * "Enabled Gateways" setting field contains gateways label setting but when you save gateway settings then label will not save |
||
| 188 | * because this is not registered setting API and code will not recognize them. |
||
| 189 | * |
||
| 190 | * This setting will not render on admin setting screen but help internal code to recognize "gateways_label" setting and add them to give setting when save. |
||
| 191 | */ |
||
| 192 | array( |
||
| 193 | 'name' => __( 'Gateways Label', 'give' ), |
||
| 194 | 'desc' => '', |
||
| 195 | 'id' => 'gateways_label', |
||
| 196 | 'type' => 'gateways_label_hidden' |
||
| 197 | ), |
||
| 198 | |||
| 199 | /** |
||
| 200 | * "Enabled Gateways" setting field contains default gateway setting but when you save gateway settings then this setting will not save |
||
| 201 | * because this is not registered setting API and code will not recognize them. |
||
| 202 | * |
||
| 203 | * This setting will not render on admin setting screen but help internal code to recognize "default_gateway" setting and add them to give setting when save. |
||
| 204 | */ |
||
| 205 | array( |
||
| 206 | 'name' => __( 'Default Gateway', 'give' ), |
||
| 207 | 'desc' => __( 'The gateway that will be selected by default.', 'give' ), |
||
| 208 | 'id' => 'default_gateway', |
||
| 209 | 'type' => 'default_gateway_hidden' |
||
| 210 | ), |
||
| 211 | |||
| 212 | array( |
||
| 213 | 'name' => __( 'Gateways Docs Link', 'give' ), |
||
| 214 | 'id' => 'gateway_settings_docs_link', |
||
| 215 | 'url' => esc_url( 'http://docs.givewp.com/settings-gateways' ), |
||
| 216 | 'title' => __( 'Gateway Settings', 'give' ), |
||
| 217 | 'type' => 'give_docs_link', |
||
| 218 | ), |
||
| 219 | array( |
||
| 220 | 'id' => 'give_title_gateway_settings_1', |
||
| 221 | 'type' => 'sectionend' |
||
| 222 | ), |
||
| 223 | ); |
||
| 224 | break; |
||
| 225 | } |
||
| 226 | |||
| 227 | /** |
||
| 228 | * Filter the payment gateways settings. |
||
| 229 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
||
| 230 | */ |
||
| 231 | $settings = apply_filters( 'give_settings_gateways', $settings ); |
||
| 232 | |||
| 233 | /** |
||
| 234 | * Filter the settings. |
||
| 235 | * |
||
| 236 | * @since 1.8 |
||
| 237 | * |
||
| 238 | * @param array $settings |
||
| 239 | */ |
||
| 240 | $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
||
| 241 | |||
| 242 | // Output. |
||
| 243 | return $settings; |
||
| 244 | } |
||
| 245 | |||
| 353 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: