Conditions | 6 |
Paths | 34 |
Total Lines | 59 |
Code Lines | 39 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
74 | public function placeRequest(TransferInterface $transferObject) |
||
75 | { |
||
76 | $client = $this->httpClientFactory->create(); |
||
77 | $request = $transferObject->getBody(); |
||
78 | $url = $this->config->getApiUrl(); |
||
79 | $apiBearer = $this->config->getMerchantGatewayOauth(); |
||
80 | $orderMoip = $request[self::MOIP_ORDER_ID]; |
||
81 | |||
82 | try { |
||
83 | $client->setUri($url.'orders/'.$orderMoip); |
||
84 | $client->setConfig(['maxredirects' => 0, 'timeout' => 120]); |
||
85 | $client->setHeaders('Authorization', 'Bearer '.$apiBearer); |
||
86 | $client->setMethod(ZendClient::GET); |
||
87 | |||
88 | $responseBody = $client->request()->getBody(); |
||
89 | $data = $this->json->unserialize($responseBody); |
||
90 | if (isset($data['status'])) { |
||
91 | $cancelDetailsAdmin = __('We did not record the payment.'); |
||
92 | $cancelDetailsCus = __('The payment deadline has been exceeded.'); |
||
93 | if (isset($data['payments'])) { |
||
94 | foreach ($data['payments'] as $payment) { |
||
95 | if (isset($payment['cancellationDetails'])) { |
||
96 | $cancelCode = $payment['cancellationDetails']['code']; |
||
97 | $cancelDescription = $payment['cancellationDetails']['description']; |
||
98 | $cancelBy = $payment['cancellationDetails']['cancelledBy']; |
||
99 | $cancelDetailsAdmin = __('%1, code %2, by %3', $cancelDescription, $cancelCode, $cancelBy); |
||
100 | $cancelDetailsCus = __('%1', $cancelDescription); |
||
101 | } |
||
102 | } |
||
103 | } |
||
104 | $response = array_merge( |
||
105 | [ |
||
106 | 'RESULT_CODE' => 1, |
||
107 | 'STATUS' => $data['status'], |
||
108 | 'CANCELLATION_DETAILS_CUSTOMER' => $cancelDetailsCus, |
||
109 | 'CANCELLATION_DETAILS_ADMIN' => $cancelDetailsAdmin, |
||
110 | ], |
||
111 | $data |
||
112 | ); |
||
113 | } else { |
||
114 | $response = array_merge( |
||
115 | [ |
||
116 | 'RESULT_CODE' => 0, |
||
117 | ], |
||
118 | $data |
||
119 | ); |
||
120 | } |
||
121 | $this->logger->debug( |
||
122 | [ |
||
123 | 'url' => $url.'orders/'.$orderMoip, |
||
124 | 'response' => $responseBody, |
||
125 | ] |
||
126 | ); |
||
127 | } catch (InvalidArgumentException $e) { |
||
128 | // phpcs:ignore Magento2.Exceptions.DirectThrow |
||
129 | throw new \Exception('Invalid JSON was returned by the gateway'); |
||
130 | } |
||
131 | |||
132 | return $response; |
||
133 | } |
||
135 |
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