| Conditions | 10 |
| Paths | 248 |
| Total Lines | 88 |
| 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 |
||
| 170 | public function start( Payment $payment ) { |
||
| 171 | try { |
||
| 172 | /* |
||
| 173 | * Order ID |
||
| 174 | * Your unique order number. |
||
| 175 | * This can be auto incremental number from your payments table |
||
| 176 | * |
||
| 177 | * Data type = String |
||
| 178 | * Max length = 10 |
||
| 179 | * Required = Yes |
||
| 180 | */ |
||
| 181 | |||
| 182 | // Payment object. |
||
| 183 | $payment_object = new Icepay_PaymentObject(); |
||
| 184 | $payment_object |
||
| 185 | ->setAmount( $payment->get_total_amount()->get_cents() ) |
||
| 186 | ->setReference( $payment->get_order_id() ) |
||
| 187 | ->setDescription( $payment->get_description() ) |
||
| 188 | ->setCurrency( $payment->get_total_amount()->get_currency()->get_alphabetic_code() ) |
||
| 189 | ->setIssuer( $payment->get_issuer() ) |
||
| 190 | ->setOrderID( $payment->format_string( $this->config->order_id ) ); |
||
| 191 | |||
| 192 | if ( null !== $payment->get_customer() ) { |
||
| 193 | // Language. |
||
| 194 | $language = strtoupper( $payment->get_customer()->get_language() ); |
||
| 195 | |||
| 196 | $payment_object->setLanguage( $language ); |
||
| 197 | |||
| 198 | // Country. |
||
| 199 | $locale = $payment->get_customer()->get_locale(); |
||
| 200 | |||
| 201 | $country = strtoupper( substr( $locale, 3, 2 ) ); |
||
| 202 | |||
| 203 | $payment_object->setCountry( $country ); |
||
| 204 | } |
||
| 205 | |||
| 206 | /* |
||
| 207 | * Payment method |
||
| 208 | * @since 1.2.0 |
||
| 209 | */ |
||
| 210 | $icepay_method = null; |
||
| 211 | |||
| 212 | switch ( $payment->get_method() ) { |
||
| 213 | case PaymentMethods::CREDIT_CARD: |
||
| 214 | // @link https://github.com/icepay/icepay/blob/2.4.0/api/paymentmethods/creditcard.php |
||
| 215 | $icepay_method = new Icepay_Paymentmethod_Creditcard(); |
||
| 216 | |||
| 217 | break; |
||
| 218 | case PaymentMethods::DIRECT_DEBIT: |
||
| 219 | // @link https://github.com/icepay/icepay/blob/2.4.0/api/paymentmethods/ddebit.php |
||
| 220 | $icepay_method = new Icepay_Paymentmethod_Ddebit(); |
||
| 221 | |||
| 222 | break; |
||
| 223 | case PaymentMethods::IDEAL: |
||
| 224 | // @link https://github.com/icepay/icepay/blob/2.4.0/api/paymentmethods/ideal.php |
||
| 225 | $icepay_method = new Icepay_Paymentmethod_Ideal(); |
||
| 226 | |||
| 227 | break; |
||
| 228 | case PaymentMethods::BANCONTACT: |
||
| 229 | case PaymentMethods::MISTER_CASH: |
||
| 230 | // @link https://github.com/icepay/icepay/blob/2.4.0/api/paymentmethods/mistercash.php |
||
| 231 | $icepay_method = new Icepay_Paymentmethod_Mistercash(); |
||
| 232 | |||
| 233 | break; |
||
| 234 | } |
||
| 235 | |||
| 236 | if ( isset( $icepay_method ) ) { |
||
| 237 | // @link https://github.com/icepay/icepay/blob/2.4.0/api/icepay_api_base.php#L342-L353 |
||
| 238 | $payment_object->setPaymentMethod( $icepay_method->getCode() ); |
||
| 239 | } |
||
| 240 | |||
| 241 | // Protocol. |
||
| 242 | $protocol = is_ssl() ? 'https' : 'http'; |
||
| 243 | |||
| 244 | // Basic mode. |
||
| 245 | $basicmode = Icepay_Basicmode::getInstance(); |
||
| 246 | $basicmode |
||
| 247 | ->setMerchantID( $this->config->merchant_id ) |
||
| 248 | ->setSecretCode( $this->config->secret_code ) |
||
| 249 | ->setProtocol( $protocol ) |
||
| 250 | ->setSuccessURL( $payment->get_return_url() ) |
||
| 251 | ->setErrorURL( $payment->get_return_url() ) |
||
| 252 | ->validatePayment( $payment_object ); |
||
| 253 | |||
| 254 | // Action URL. |
||
| 255 | $payment->set_action_url( $basicmode->getURL() ); |
||
| 256 | } catch ( Exception $exception ) { |
||
| 257 | $this->error = new WP_Error( 'icepay_error', $exception->getMessage(), $exception ); |
||
| 258 | } |
||
| 299 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths