Conditions | 5 |
Paths | 11 |
Total Lines | 53 |
Code Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
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 |
||
106 | public function placeRequest(TransferInterface $transferObject) |
||
107 | { |
||
108 | /** @var ZendClient $client */ |
||
109 | $client = $this->httpClientFactory->create(); |
||
110 | $request = $transferObject->getBody(); |
||
111 | $url = $this->config->getApiUrl(); |
||
112 | $storeId = $request[self::STORE_ID]; |
||
113 | $url = $this->config->getApiUrl($storeId); |
||
114 | $apiBearer = $this->config->getMerchantGatewayOauth($storeId); |
||
115 | unset($request[self::STORE_ID]); |
||
116 | $response = ['RESULT_CODE' => 0]; |
||
117 | |||
118 | if ($request[self::ORDER_STATE] !== Order::STATE_NEW) { |
||
119 | // phpcs:ignore Magento2.Exceptions.DirectThrow |
||
120 | throw new InvalidArgumentException('Payment is not New.'); |
||
121 | } |
||
122 | |||
123 | try { |
||
124 | $client->setUri($url.'v1/payments/qrcode/'.$getnetPaymentId); |
||
125 | $client->setConfig(['maxredirects' => 0, 'timeout' => 45000]); |
||
126 | $client->setHeaders( |
||
127 | [ |
||
128 | 'Authorization' => 'Bearer '.$apiBearer, |
||
129 | 'x-transaction-channel-entry' => 'MG', |
||
130 | ] |
||
131 | ); |
||
132 | $client->setMethod(ZendClient::GET); |
||
133 | |||
134 | $responseBody = $client->request()->getBody(); |
||
135 | $data = $this->json->unserialize($responseBody); |
||
136 | $status = $data[self::RESPONSE_STATUS]; |
||
137 | if ($status === self::RESPONSE_DENIED || $status === self::RESPONSE_APPROVED) { |
||
138 | $response = array_merge( |
||
139 | [ |
||
140 | 'RESULT_CODE' => 1, |
||
141 | 'GETNET_ORDER_ID' => $getnetPaymentId, |
||
142 | 'STATUS' => $status, |
||
143 | ], |
||
144 | $data |
||
145 | ); |
||
146 | } |
||
147 | } catch (InvalidArgumentException $e) { |
||
148 | // phpcs:ignore Magento2.Exceptions.DirectThrow |
||
149 | throw new Exception('Invalid JSON was returned by the gateway'); |
||
150 | } |
||
151 | $this->logger->debug( |
||
152 | [ |
||
153 | 'url' => $url.'v1/payments/qrcode/'.$getnetPaymentId, |
||
154 | 'response' => $responseBody, |
||
155 | ] |
||
156 | ); |
||
157 | |||
158 | return $response; |
||
159 | } |
||
161 |
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