Conditions | 3 |
Paths | 3 |
Total Lines | 58 |
Code Lines | 34 |
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 |
||
59 | public function start( Payment $payment ) { |
||
60 | $url = 'https://checkout-test.adyen.com/v40/paymentMethods'; |
||
61 | |||
62 | $data = (object) array( |
||
63 | 'merchantAccount' => $this->config->merchant_account, |
||
64 | 'allowedPaymentMethods' => array( |
||
65 | // 'ideal', |
||
66 | ), |
||
67 | ); |
||
68 | |||
69 | $response = wp_remote_post( $url, array( |
||
70 | 'headers' => array( |
||
71 | 'X-API-key' => $this->config->api_key, |
||
72 | 'Content-Type' => 'application/json', |
||
73 | ), |
||
74 | 'body' => wp_json_encode( $data ), |
||
75 | ) ); |
||
76 | |||
77 | $body = wp_remote_retrieve_body( $response ); |
||
78 | |||
79 | $result = json_decode( $body ); |
||
80 | |||
81 | $payment_methods = $result->paymentMethods; |
||
82 | $payment_method = reset( $payment_methods ); |
||
83 | |||
84 | $url = 'https://checkout-test.adyen.com/v40/payments'; |
||
85 | |||
86 | $data = (object) array( |
||
87 | 'amount' => (object) array( |
||
88 | 'currency' => $payment->get_total_amount()->get_currency()->get_alphabetic_code(), |
||
89 | 'value' => $payment->get_total_amount()->get_cents(), |
||
90 | ), |
||
91 | 'reference' => $payment->get_id(), |
||
92 | 'paymentMethod' => (object) array( |
||
93 | 'type' => 'ideal', |
||
94 | ), |
||
95 | 'returnUrl' => $payment->get_return_url(), |
||
96 | 'merchantAccount' => $this->config->merchant_account, |
||
97 | ); |
||
98 | |||
99 | $response = wp_remote_post( $url, array( |
||
100 | 'headers' => array( |
||
101 | 'X-API-key' => $this->config->api_key, |
||
102 | 'Content-Type' => 'application/json', |
||
103 | ), |
||
104 | 'body' => wp_json_encode( $data ), |
||
105 | ) ); |
||
106 | |||
107 | if ( '200' !== strval( wp_remote_retrieve_response_code( $response ) ) ) { |
||
108 | return; |
||
109 | } |
||
110 | |||
111 | $body = wp_remote_retrieve_body( $response ); |
||
112 | |||
113 | $result = json_decode( $body ); |
||
114 | |||
115 | if ( isset( $result->redirect, $result->redirect->url ) ) { |
||
116 | $payment->set_action_url( $result->redirect->url ); |
||
117 | } |
||
131 |
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