Conditions | 3 |
Paths | 14 |
Total Lines | 53 |
Code Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
85 | public function placeRequest(TransferInterface $transferObject) |
||
86 | { |
||
87 | /** @var ZendClient $client */ |
||
88 | $client = $this->httpClientFactory->create(); |
||
89 | $request = $transferObject->getBody(); |
||
90 | $url = $this->config->getApiUrl(); |
||
91 | $apiBearer = $this->config->getMerchantGatewayOauth(); |
||
92 | |||
93 | try { |
||
94 | $client->setUri($url.'/v1/payments/qrcode'); |
||
95 | $client->setConfig(['maxredirects' => 0, 'timeout' => 45000]); |
||
96 | $client->setHeaders('Authorization', 'Bearer '.$apiBearer); |
||
97 | $client->setRawData($this->json->serialize($request), 'application/json'); |
||
98 | $client->setMethod(ZendClient::POST); |
||
99 | |||
100 | $responseBody = $client->request()->getBody(); |
||
101 | $data = $this->json->unserialize($responseBody); |
||
102 | $response = array_merge( |
||
103 | [ |
||
104 | self::RESULT_CODE => 0, |
||
105 | ], |
||
106 | $data |
||
107 | ); |
||
108 | if (isset($data['payment_id'])) { |
||
109 | $response = array_merge( |
||
110 | [ |
||
111 | self::RESULT_CODE => 1, |
||
112 | self::EXT_ORD_ID => $data['payment_id'], |
||
113 | ], |
||
114 | $data |
||
115 | ); |
||
116 | } |
||
117 | $this->logger->debug( |
||
118 | [ |
||
119 | 'url' => $url.'v1/payments/qrcode', |
||
120 | 'request' => $this->json->serialize($transferObject->getBody()), |
||
121 | 'response' => $responseBody, |
||
122 | ] |
||
123 | ); |
||
124 | } catch (InvalidArgumentException $e) { |
||
125 | $this->logger->debug( |
||
126 | [ |
||
127 | 'url' => $url.'v1/payments/qrcode', |
||
128 | 'request' => $this->json->serialize($transferObject->getBody()), |
||
129 | 'response' => $responseBody, |
||
130 | 'error' => $e->getMessage(), |
||
131 | ] |
||
132 | ); |
||
133 | // phpcs:ignore Magento2.Exceptions.DirectThrow |
||
134 | throw new Exception('Invalid JSON was returned by the gateway'); |
||
135 | } |
||
136 | |||
137 | return $response; |
||
138 | } |
||
140 |
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