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